mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 05:00:35 +00:00
Get inputlines mostly working.
It should be only behind-the-scenes updates that are still a problem.
This commit is contained in:
parent
652b434e7b
commit
8ac5079ada
7 changed files with 33 additions and 34 deletions
|
@ -63,6 +63,9 @@ typedef struct inputline_s
|
|||
void (*complete)(struct inputline_s *); // tab key pressed
|
||||
void (*enter)(struct inputline_s *); // enter key pressed
|
||||
void (*draw)(struct inputline_s *); // draw input line to screen
|
||||
|
||||
int x, y; // coordinates depend on display
|
||||
int cursor; // is the cursor active (drawn?)
|
||||
} inputline_t;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -123,7 +123,6 @@ bi_inputline_enter (inputline_t *il)
|
|||
progs_t *pr = data->pr;
|
||||
const char *line = il->line;
|
||||
|
||||
Sys_Printf ("enter\n");
|
||||
if (!data->enter)
|
||||
return; // no callback defined
|
||||
|
||||
|
@ -172,6 +171,7 @@ bi_InputLine_Create (progs_t *pr)
|
|||
res->lines->prev = &data->next;
|
||||
res->lines = data;
|
||||
data->line = line;
|
||||
data->pr = pr;
|
||||
|
||||
line->draw = res->draw;
|
||||
line->enter = bi_inputline_enter;
|
||||
|
@ -181,13 +181,20 @@ bi_InputLine_Create (progs_t *pr)
|
|||
}
|
||||
|
||||
static void
|
||||
bi_InputLine_SetUserData (progs_t *pr)
|
||||
bi_InputLine_SetPos (progs_t *pr)
|
||||
{
|
||||
il_data_t *line = get_inputline (pr, P_INT (pr, 0),
|
||||
"InputLine_SetUserData");
|
||||
pr_type_t *data = P_GPOINTER (pr, 1);
|
||||
"InputLine_SetPos");
|
||||
line->line->x = P_INT (pr, 1);
|
||||
line->line->y = P_INT (pr, 2);
|
||||
}
|
||||
|
||||
line->line->user_data = data;
|
||||
static void
|
||||
bi_InputLine_SetCursor (progs_t *pr)
|
||||
{
|
||||
il_data_t *line = get_inputline (pr, P_INT (pr, 0),
|
||||
"InputLine_SetCursor");
|
||||
line->line->cursor = P_INT (pr, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -296,7 +303,8 @@ bi_InputLine_Draw (progs_t *pr)
|
|||
|
||||
static builtin_t builtins[] = {
|
||||
{"InputLine_Create", bi_InputLine_Create, -1},
|
||||
{"InputLine_SetUserData", bi_InputLine_SetUserData, -1},
|
||||
{"InputLine_SetPos", bi_InputLine_SetPos, -1},
|
||||
{"InputLine_SetCursor", bi_InputLine_SetCursor, -1},
|
||||
{"InputLine_SetEnter|^{tag _inputline_t=}(v*^v)^v",
|
||||
bi_InputLine_SetEnter, -1},
|
||||
{"InputLine_SetEnter|^{tag _inputline_t=}(@@:.)@:",
|
||||
|
|
|
@ -66,12 +66,6 @@ static __attribute__ ((used)) const char rcsid[] =
|
|||
|
||||
#include "compat.h"
|
||||
|
||||
// XXX check InputLine.h in ruamoko/include/gui
|
||||
typedef struct {
|
||||
int x, y;
|
||||
int cursor;
|
||||
} il_data_t;
|
||||
|
||||
static general_data_t plugin_info_general_data;
|
||||
console_data_t con_data;
|
||||
|
||||
|
@ -574,8 +568,7 @@ DrawInputLine (int x, int y, int cursor, inputline_t *il)
|
|||
void
|
||||
C_DrawInputLine (inputline_t *il)
|
||||
{
|
||||
il_data_t *data = il->user_data;
|
||||
DrawInputLine (data->x, data->y, data->cursor, il);
|
||||
DrawInputLine (il->x, il->y, il->cursor, il);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -76,6 +76,7 @@ Con_CreateInputLine (int lines, int lsize, char prompt)
|
|||
for (i = 0; i < inputline->num_lines; i++)
|
||||
inputline->lines[i][0] = prompt;
|
||||
inputline->linepos = 1;
|
||||
inputline->cursor = 1;
|
||||
return inputline;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
|
||||
-enter: (string) line
|
||||
{
|
||||
if (line)
|
||||
[cvstring setString: line];
|
||||
[cvstring setString: line];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -56,6 +55,11 @@
|
|||
[ilb cursor: NO];
|
||||
} else {
|
||||
[ilb processInput:(key >= 256 ? key : unicode)];
|
||||
if (key == QFK_RETURN) {
|
||||
[self update];
|
||||
active = 0;
|
||||
[ilb cursor: NO];
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include "draw.h"
|
||||
#include "debug.h"
|
||||
#include "gui/InputLine.h"
|
||||
#include "gui/Rect.h"
|
||||
|
||||
inputline_t (int lines, int size, int prompt) InputLine_Create = #0;
|
||||
void InputLine_SetUserData (inputline_t il, void *data) = #0;
|
||||
void InputLine_SetPos (inputline_t il, int x, int y) = #0;
|
||||
void InputLine_SetCursor (inputline_t il, int cursorr) = #0;
|
||||
@overload void InputLine_SetEnter (inputline_t il, void (f)(string, void*), void *data) = #0;
|
||||
@overload void InputLine_SetEnter (inputline_t il, IMP imp, id obj, SEL sel) = #0;
|
||||
void (inputline_t il, int width) InputLine_SetWidth = #0;
|
||||
|
@ -20,12 +20,10 @@ string (inputline_t il) InputLine_GetText = #0;
|
|||
- (id) initWithBounds: (Rect)aRect promptCharacter: (int)char
|
||||
{
|
||||
self = [super initWithComponents:aRect.origin.x :aRect.origin.y :aRect.size.width * 8 :8];
|
||||
control.x = xabs;
|
||||
control.y = yabs;
|
||||
control.cursor = NO;
|
||||
|
||||
il = InputLine_Create (aRect.size.height, aRect.size.width, char);
|
||||
InputLine_SetUserData (il, &control);
|
||||
InputLine_SetPos (il, xabs, yabs);
|
||||
InputLine_SetCursor (il, NO);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -39,8 +37,7 @@ string (inputline_t il) InputLine_GetText = #0;
|
|||
- (void) setBasePosFromView: (View *) view
|
||||
{
|
||||
[super setBasePosFromView: view];
|
||||
control.x = xabs;
|
||||
control.y = yabs;
|
||||
InputLine_SetPos (il, xabs, yabs);
|
||||
}
|
||||
|
||||
- (void) setWidth: (int)width
|
||||
|
@ -50,10 +47,8 @@ string (inputline_t il) InputLine_GetText = #0;
|
|||
|
||||
- (void) setEnter: obj message:(SEL) msg
|
||||
{
|
||||
traceon();
|
||||
IMP imp = [obj methodForSelector: msg];
|
||||
InputLine_SetEnter (il, imp, obj, msg);
|
||||
traceoff();
|
||||
}
|
||||
|
||||
- (void) processInput: (int)key
|
||||
|
@ -63,7 +58,7 @@ traceoff();
|
|||
|
||||
- (void) cursor: (BOOL)cursor
|
||||
{
|
||||
control.cursor = cursor;
|
||||
InputLine_SetCursor (il, cursor);
|
||||
}
|
||||
|
||||
- (void) draw
|
||||
|
|
|
@ -7,7 +7,8 @@ struct _inputline_t {}; // opaque type :)
|
|||
typedef struct _inputline_t *inputline_t;
|
||||
|
||||
@extern inputline_t (int lines, int size, int prompt) InputLine_Create;
|
||||
@extern void InputLine_SetUserData (inputline_t il, void *data);
|
||||
@extern void InputLine_SetPos (inputline_t il, int x, int y);
|
||||
@extern void InputLine_SetCursor (inputline_t il, int cursorr);
|
||||
@extern @overload void InputLine_SetEnter (inputline_t il, void (f)(string, void*), void *data);
|
||||
@extern @overload void InputLine_SetEnter (inputline_t il, IMP imp, id obj, SEL sel);
|
||||
@extern void (inputline_t il, int width) InputLine_SetWidth;
|
||||
|
@ -18,14 +19,8 @@ typedef struct _inputline_t *inputline_t;
|
|||
@extern void (inputline_t il, string str) InputLine_SetText;
|
||||
@extern string (inputline_t il) InputLine_GetText;
|
||||
|
||||
struct il_data_t {
|
||||
int x, y;
|
||||
BOOL cursor;
|
||||
};
|
||||
|
||||
@interface InputLine: View
|
||||
{
|
||||
struct il_data_t control;
|
||||
inputline_t il;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue