mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
[qwaq] Add char get/put/insert methods to EditBuffer
This commit is contained in:
parent
48bf6fff13
commit
5892008306
3 changed files with 56 additions and 1 deletions
|
@ -810,6 +810,50 @@ bi_i_EditBuffer__readString_ (progs_t *pr)
|
||||||
RETURN_STRING (pr, str);
|
RETURN_STRING (pr, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bi_i_EditBuffer__getChar_ (progs_t *pr)
|
||||||
|
{
|
||||||
|
qwaq_ebresources_t *res = PR_Resources_Find (pr, "qwaq-editbuffer");
|
||||||
|
int buffer_id = P_STRUCT (pr, qwaq_editbuffer_t, 0).buffer;
|
||||||
|
editbuffer_t *buffer = get_editbuffer (res, __FUNCTION__, buffer_id);
|
||||||
|
unsigned ptr = P_UINT (pr, 2);
|
||||||
|
|
||||||
|
if (ptr >= buffer->txtbuffer->textSize) {
|
||||||
|
PR_RunError (pr, "EditBuffer: character index out of bounds\n");
|
||||||
|
}
|
||||||
|
R_INT (pr) = (byte) getChar (buffer->txtbuffer, ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bi_i_EditBuffer__putChar_at_ (progs_t *pr)
|
||||||
|
{
|
||||||
|
qwaq_ebresources_t *res = PR_Resources_Find (pr, "qwaq-editbuffer");
|
||||||
|
int buffer_id = P_STRUCT (pr, qwaq_editbuffer_t, 0).buffer;
|
||||||
|
editbuffer_t *buffer = get_editbuffer (res, __FUNCTION__, buffer_id);
|
||||||
|
int chr = P_UINT (pr, 2);
|
||||||
|
unsigned ptr = P_UINT (pr, 3);
|
||||||
|
|
||||||
|
if (ptr >= buffer->txtbuffer->textSize) {
|
||||||
|
PR_RunError (pr, "EditBuffer: character index out of bounds\n");
|
||||||
|
}
|
||||||
|
buffer->txtbuffer->text[spanGap (buffer->txtbuffer, ptr)] = chr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bi_i_EditBuffer__insertChar_at_ (progs_t *pr)
|
||||||
|
{
|
||||||
|
qwaq_ebresources_t *res = PR_Resources_Find (pr, "qwaq-editbuffer");
|
||||||
|
int buffer_id = P_STRUCT (pr, qwaq_editbuffer_t, 0).buffer;
|
||||||
|
editbuffer_t *buffer = get_editbuffer (res, __FUNCTION__, buffer_id);
|
||||||
|
char chr = P_UINT (pr, 2);
|
||||||
|
unsigned ptr = P_UINT (pr, 3);
|
||||||
|
|
||||||
|
if (ptr > buffer->txtbuffer->textSize) {
|
||||||
|
PR_RunError (pr, "EditBuffer: character index out of bounds\n");
|
||||||
|
}
|
||||||
|
TextBuffer_InsertAt (buffer->txtbuffer, ptr, &chr, 1);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
bi_i_EditBuffer__countLines_ (progs_t *pr)
|
bi_i_EditBuffer__countLines_ (progs_t *pr)
|
||||||
{
|
{
|
||||||
|
@ -939,13 +983,16 @@ static builtin_t builtins[] = {
|
||||||
{"_i_EditBuffer__getBOT", bi_i_EditBuffer__getBOT, -1},
|
{"_i_EditBuffer__getBOT", bi_i_EditBuffer__getBOT, -1},
|
||||||
{"_i_EditBuffer__getEOT", bi_i_EditBuffer__getEOT, -1},
|
{"_i_EditBuffer__getEOT", bi_i_EditBuffer__getEOT, -1},
|
||||||
{"_i_EditBuffer__readString_", bi_i_EditBuffer__readString_, -1},
|
{"_i_EditBuffer__readString_", bi_i_EditBuffer__readString_, -1},
|
||||||
|
{"_i_EditBuffer__getChar_", bi_i_EditBuffer__getChar_, -1},
|
||||||
|
{"_i_EditBuffer__putChar_at_", bi_i_EditBuffer__putChar_at_, -1},
|
||||||
|
{"_i_EditBuffer__insertChar_at_", bi_i_EditBuffer__insertChar_at_,-1},
|
||||||
{"_i_EditBuffer__countLines_", bi_i_EditBuffer__countLines_, -1},
|
{"_i_EditBuffer__countLines_", bi_i_EditBuffer__countLines_, -1},
|
||||||
{"_i_EditBuffer__search_for_direction_",
|
{"_i_EditBuffer__search_for_direction_",
|
||||||
bi_i_EditBuffer__search_for_direction_, -1},
|
bi_i_EditBuffer__search_for_direction_, -1},
|
||||||
{"_i_EditBuffer__isearch_for_direction_",
|
{"_i_EditBuffer__isearch_for_direction_",
|
||||||
bi_i_EditBuffer__isearch_for_direction_,-1},
|
bi_i_EditBuffer__isearch_for_direction_,-1},
|
||||||
{"_i_EditBuffer__formatLine_from_into_width_highlight_colors_",
|
{"_i_EditBuffer__formatLine_from_into_width_highlight_colors_",
|
||||||
bi_i_EditBuffer__formatLine_from_into_width_highlight_colors_, -1},
|
bi_i_EditBuffer__formatLine_from_into_width_highlight_colors_, -1},
|
||||||
{"_i_EditBuffer__modified", bi_i_EditBuffer__modified, -1},
|
{"_i_EditBuffer__modified", bi_i_EditBuffer__modified, -1},
|
||||||
{"_i_EditBuffer__textSize", bi_i_EditBuffer__textSize, -1},
|
{"_i_EditBuffer__textSize", bi_i_EditBuffer__textSize, -1},
|
||||||
{"_i_EditBuffer__saveFile_", bi_i_EditBuffer__saveFile_, -1},
|
{"_i_EditBuffer__saveFile_", bi_i_EditBuffer__saveFile_, -1},
|
||||||
|
|
|
@ -50,7 +50,11 @@ typedef struct eb_color_s {
|
||||||
- (unsigned) getEOL: (unsigned) linePtr;
|
- (unsigned) getEOL: (unsigned) linePtr;
|
||||||
- (unsigned) getBOT;
|
- (unsigned) getBOT;
|
||||||
- (unsigned) getEOT;
|
- (unsigned) getEOT;
|
||||||
|
|
||||||
- (string) readString: (eb_sel_t) selection;
|
- (string) readString: (eb_sel_t) selection;
|
||||||
|
- (int) getChar: (unsigned) charPtr;
|
||||||
|
- (void) putChar: (int) char at:(unsigned) charPtr;
|
||||||
|
- (void) insertChar: (int) char at:(unsigned) charPtr;
|
||||||
|
|
||||||
- (unsigned) countLines: (eb_sel_t) selection;
|
- (unsigned) countLines: (eb_sel_t) selection;
|
||||||
- (eb_sel_t) search: (eb_sel_t) selection
|
- (eb_sel_t) search: (eb_sel_t) selection
|
||||||
|
|
|
@ -36,7 +36,11 @@
|
||||||
- (unsigned) getEOL: (unsigned) linePtr = #0;
|
- (unsigned) getEOL: (unsigned) linePtr = #0;
|
||||||
- (unsigned) getBOT = #0;
|
- (unsigned) getBOT = #0;
|
||||||
- (unsigned) getEOT = #0;
|
- (unsigned) getEOT = #0;
|
||||||
|
|
||||||
- (string) readString: (eb_sel_t) selection = #0;
|
- (string) readString: (eb_sel_t) selection = #0;
|
||||||
|
- (int) getChar: (unsigned) charPtr = #0;
|
||||||
|
- (void) putChar: (int) char at:(unsigned) charPtr = #0;
|
||||||
|
- (void) insertChar: (int) char at:(unsigned) charPtr = #0;
|
||||||
|
|
||||||
- (unsigned) countLines: (eb_sel_t) selection = #0;
|
- (unsigned) countLines: (eb_sel_t) selection = #0;
|
||||||
- (eb_sel_t) search: (eb_sel_t) selection
|
- (eb_sel_t) search: (eb_sel_t) selection
|
||||||
|
|
Loading…
Reference in a new issue