mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
Fix the API for inputline->enter().
Pass the inputline object rather than the input text, allowing access to both user_data and the input text.
This commit is contained in:
parent
30bd1c0134
commit
c8e1d7b45a
4 changed files with 25 additions and 8 deletions
|
@ -57,10 +57,11 @@ typedef struct inputline_s
|
||||||
int history_line; // current history line
|
int history_line; // current history line
|
||||||
size_t linepos; // cursor position within the current edit line
|
size_t linepos; // cursor position within the current edit line
|
||||||
size_t scroll; // beginning of displayed line
|
size_t scroll; // beginning of displayed line
|
||||||
size_t width; // viewable widht for horizontal scrolling
|
size_t width; // viewable width for horizontal scrolling
|
||||||
|
const char *line;
|
||||||
void *user_data; // eg: window pointer
|
void *user_data; // eg: window pointer
|
||||||
void (*complete)(struct inputline_s *); // tab key pressed
|
void (*complete)(struct inputline_s *); // tab key pressed
|
||||||
void (*enter)(const char *line); // enter key pressed
|
void (*enter)(struct inputline_s *); // enter key pressed
|
||||||
void (*draw)(struct inputline_s *); // draw input line to screen
|
void (*draw)(struct inputline_s *); // draw input line to screen
|
||||||
} inputline_t;
|
} inputline_t;
|
||||||
|
|
||||||
|
|
|
@ -326,8 +326,9 @@ cl_conmode_f (cvar_t *var)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
C_Say (const char *line)
|
C_Say (inputline_t *il)
|
||||||
{
|
{
|
||||||
|
const char *line = il->line;
|
||||||
if (!*line)
|
if (!*line)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -339,8 +340,9 @@ C_Say (const char *line)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
C_SayTeam (const char *line)
|
C_SayTeam (inputline_t *il)
|
||||||
{
|
{
|
||||||
|
const char *line = il->line;
|
||||||
if (!*line)
|
if (!*line)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -797,6 +799,12 @@ C_GIB_HUD_Disable_f (void)
|
||||||
hud_view->visible = 0;
|
hud_view->visible = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
exec_line (inputline_t *il)
|
||||||
|
{
|
||||||
|
Con_ExecLine (il->line);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
C_Init (void)
|
C_Init (void)
|
||||||
{
|
{
|
||||||
|
@ -875,7 +883,7 @@ C_Init (void)
|
||||||
|
|
||||||
input_line = Con_CreateInputLine (32, MAXCMDLINE, ']');
|
input_line = Con_CreateInputLine (32, MAXCMDLINE, ']');
|
||||||
input_line->complete = Con_BasicCompleteCommandLine;
|
input_line->complete = Con_BasicCompleteCommandLine;
|
||||||
input_line->enter = Con_ExecLine;
|
input_line->enter = exec_line;
|
||||||
input_line->width = con_linewidth;
|
input_line->width = con_linewidth;
|
||||||
input_line->user_data = 0;
|
input_line->user_data = 0;
|
||||||
input_line->draw = 0;
|
input_line->draw = 0;
|
||||||
|
|
|
@ -105,8 +105,10 @@ Con_ProcessInputLine (inputline_t *il, int ch)
|
||||||
|
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case QFK_RETURN:
|
case QFK_RETURN:
|
||||||
if (il->enter)
|
if (il->enter) {
|
||||||
il->enter (il->lines[il->edit_line] + 1);
|
il->line = il->lines[il->edit_line] + 1;
|
||||||
|
il->enter (il);
|
||||||
|
}
|
||||||
Con_ClearTyping (il, 1);
|
Con_ClearTyping (il, 1);
|
||||||
break;
|
break;
|
||||||
case QFK_TAB:
|
case QFK_TAB:
|
||||||
|
|
|
@ -544,6 +544,12 @@ create_window (view_t *parent, int xpos, int ypos, int xlen, int ylen,
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
exec_line (inputline_t *il)
|
||||||
|
{
|
||||||
|
Con_ExecLine (il->line);
|
||||||
|
}
|
||||||
|
|
||||||
static inputline_t *
|
static inputline_t *
|
||||||
create_input_line (int width)
|
create_input_line (int width)
|
||||||
{
|
{
|
||||||
|
@ -551,7 +557,7 @@ create_input_line (int width)
|
||||||
|
|
||||||
input_line = Con_CreateInputLine (16, MAXCMDLINE, ']');
|
input_line = Con_CreateInputLine (16, MAXCMDLINE, ']');
|
||||||
input_line->complete = sv_complete;
|
input_line->complete = sv_complete;
|
||||||
input_line->enter = Con_ExecLine;
|
input_line->enter = exec_line;
|
||||||
input_line->user_data = input;
|
input_line->user_data = input;
|
||||||
input_line->draw = draw_input_line;
|
input_line->draw = draw_input_line;
|
||||||
input_line->width = width;
|
input_line->width = width;
|
||||||
|
|
Loading…
Reference in a new issue