mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
[qwaq] Implement rectangular region clearing
You'd think ncurses would have this, but I guess it's too window-oriented.
This commit is contained in:
parent
c6746fa391
commit
8997c81bd1
9 changed files with 153 additions and 1 deletions
|
@ -84,6 +84,7 @@ typedef enum qwaq_commands_e {
|
|||
qwaq_cmd_mvwblit_line,
|
||||
qwaq_cmd_wresize,
|
||||
qwaq_cmd_resizeterm,
|
||||
qwaq_cmd_mvwhline,
|
||||
} qwaq_commands;
|
||||
|
||||
static const char *qwaq_command_names[]= {
|
||||
|
@ -116,6 +117,7 @@ static const char *qwaq_command_names[]= {
|
|||
"mvwblit_line",
|
||||
"wresize",
|
||||
"resizeterm",
|
||||
"mvwhline"
|
||||
};
|
||||
|
||||
static window_t *
|
||||
|
@ -600,10 +602,23 @@ cmd_resizeterm (qwaq_resources_t *res)
|
|||
resizeterm (height, width);
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_mvwhline (qwaq_resources_t *res)
|
||||
{
|
||||
int window_id = RB_PEEK_DATA (res->command_queue, 2);
|
||||
int x = RB_PEEK_DATA (res->command_queue, 3);
|
||||
int y = RB_PEEK_DATA (res->command_queue, 4);
|
||||
int ch = RB_PEEK_DATA (res->command_queue, 5);
|
||||
int n = RB_PEEK_DATA (res->command_queue, 6);
|
||||
|
||||
window_t *window = get_window (res, __FUNCTION__, window_id);
|
||||
mvwhline (window->win, y, x, ch, n);
|
||||
}
|
||||
|
||||
static void
|
||||
dump_command (qwaq_resources_t *res, int len)
|
||||
{
|
||||
if (0) {
|
||||
if (1) {
|
||||
qwaq_commands cmd = RB_PEEK_DATA (res->command_queue, 0);
|
||||
Sys_Printf ("%s[%d]", qwaq_command_names[cmd], len);
|
||||
for (int i = 2; i < len; i++) {
|
||||
|
@ -739,6 +754,9 @@ process_commands (qwaq_resources_t *res)
|
|||
case qwaq_cmd_resizeterm:
|
||||
cmd_resizeterm (res);
|
||||
break;
|
||||
case qwaq_cmd_mvwhline:
|
||||
cmd_mvwhline (res);
|
||||
break;
|
||||
}
|
||||
pthread_mutex_lock (&res->command_cond.mut);
|
||||
RB_DROP_DATA (res->command_queue, len);
|
||||
|
@ -1064,6 +1082,33 @@ bi_resizeterm (progs_t *pr)
|
|||
qwaq_resizeterm (pr, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
qwaq_mvwhline (progs_t *pr, int window_id, int x, int y, int ch, int n)
|
||||
{
|
||||
qwaq_resources_t *res = PR_Resources_Find (pr, "qwaq");
|
||||
|
||||
if (get_window (res, __FUNCTION__, window_id)) {
|
||||
int command[] = {
|
||||
qwaq_cmd_mvwhline, 0,
|
||||
window_id, x, y, ch, n
|
||||
};
|
||||
|
||||
command[1] = CMD_SIZE(command);
|
||||
qwaq_submit_command (res, command);
|
||||
}
|
||||
}
|
||||
static void
|
||||
bi_mvwhline (progs_t *pr)
|
||||
{
|
||||
int window_id = P_STRUCT (pr, qwaq_textcontext_t, 0).window;
|
||||
int x = P_INT (pr, 1);
|
||||
int y = P_INT (pr, 2);
|
||||
int ch = P_INT (pr, 3);
|
||||
int n = P_INT (pr, 4);
|
||||
|
||||
qwaq_mvwhline (pr, window_id, x, y, ch, n);
|
||||
}
|
||||
|
||||
static void
|
||||
qwaq_mvwaddstr (progs_t *pr, int window_id, int x, int y, const char *str)
|
||||
{
|
||||
|
@ -1764,6 +1809,18 @@ bi_i_TextContext__border_ (progs_t *pr)
|
|||
qwaq_wborder (pr, window_id, sides, corns);
|
||||
}
|
||||
|
||||
static void
|
||||
bi_i_TextContext__mvhline_ (progs_t *pr)
|
||||
{
|
||||
__auto_type self = &P_STRUCT (pr, qwaq_textcontext_t, 0);
|
||||
int window_id = self->window;
|
||||
__auto_type pos = &P_PACKED (pr, Point, 2);
|
||||
int ch = P_INT (pr, 3);
|
||||
int n = P_INT (pr, 4);
|
||||
|
||||
qwaq_mvwhline (pr, window_id, pos->x, pos->y, ch, n);
|
||||
}
|
||||
|
||||
static void
|
||||
bi_qwaq_clear (progs_t *pr, void *data)
|
||||
{
|
||||
|
@ -1817,6 +1874,7 @@ static builtin_t builtins[] = {
|
|||
{"mvwblit_line", bi_mvwblit_line, -1},
|
||||
{"wresize", bi_wresize, -1},
|
||||
{"resizeterm", bi_resizeterm, -1},
|
||||
{"mvwhline", bi_mvwhline, -1},
|
||||
|
||||
{"_c_TextContext__is_initialized", bi_c_TextContext__is_initialized, -1},
|
||||
{"_c_TextContext__max_colors", bi_c_TextContext__max_colors, -1},
|
||||
|
@ -1841,6 +1899,7 @@ static builtin_t builtins[] = {
|
|||
{"_i_TextContext__clear", bi_i_TextContext__clear, -1},
|
||||
{"_i_TextContext__scrollok_", bi_i_TextContext__scrollok_, -1},
|
||||
{"_i_TextContext__border_", bi_i_TextContext__border_, -1},
|
||||
{"_i_TextContext__mvhline_", bi_i_TextContext__mvhline_, -1},
|
||||
|
||||
{0}
|
||||
};
|
||||
|
|
|
@ -98,6 +98,7 @@ void mvwaddch (window_t win, int x, int y, int ch);
|
|||
void waddch (window_t win, int ch);
|
||||
void mvwaddstr (window_t win, int x, int y, string str);
|
||||
void waddstr (window_t win, string str);
|
||||
void mvwhline (window_t win, int x, int y, int ch, int n);
|
||||
|
||||
panel_t create_panel (window_t window);
|
||||
void destroy_panel (panel_t panel);
|
||||
|
|
|
@ -123,6 +123,7 @@ update_current_func (Debugger *self, unsigned fnum)
|
|||
return;
|
||||
}
|
||||
qdb_get_data (debug_target, func.local_data, func.local_size, local_data);
|
||||
[locals_view clear];
|
||||
if (!local_defs) {
|
||||
[locals_view mvprintf:{0,0}, "%d", func.local_size];
|
||||
for (int y = 1; y < [locals_view size].height; y++) {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
@protocol TextContext
|
||||
- blitFromBuffer: (DrawBuffer *) srcBuffer to: (Point) pos from: (Rect) rect;
|
||||
- clearReact: (Rect) rect;
|
||||
- (Extent) size;
|
||||
- (void) resizeTo: (Extent) newSize; // absolute size
|
||||
|
||||
|
|
|
@ -86,6 +86,47 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- clearReact: (Rect) rect
|
||||
{
|
||||
Point pos = rect.offset;
|
||||
int len = rect.extent.width;
|
||||
int count = rect.extent.height;
|
||||
|
||||
if (pos.x + len > size.width) {
|
||||
len = size.width - pos.x;
|
||||
}
|
||||
if (pos.x < 0) {
|
||||
len += pos.x;
|
||||
pos.x = 0;
|
||||
}
|
||||
if (len < 1) {
|
||||
return self;
|
||||
}
|
||||
if (pos.y + count > size.height) {
|
||||
count = size.height - pos.y;
|
||||
}
|
||||
if (pos.y < 0) {
|
||||
count += pos.y;
|
||||
pos.y = 0;
|
||||
}
|
||||
if (count < 1) {
|
||||
return self;
|
||||
}
|
||||
int width = size.width;
|
||||
int ch = background;
|
||||
if (!(ch & 0xff)) {
|
||||
ch |= ' ';
|
||||
}
|
||||
while (count-- > 0) {
|
||||
int *p = buffer + pos.y * width + pos.x;
|
||||
for (int i = 0; i < len; i++) {
|
||||
*p++ = ch;
|
||||
}
|
||||
pos.y++;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) bkgd: (int) ch
|
||||
{
|
||||
background = ch;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
int ylen;
|
||||
};
|
||||
};
|
||||
int background;
|
||||
}
|
||||
+ (int) max_colors;
|
||||
+ (int) max_color_pairs;
|
||||
|
@ -49,6 +50,8 @@
|
|||
- (void) bkgd: (int) ch;
|
||||
- (void) scrollok: (int) flag;
|
||||
- (void) border: (box_sides_t) sides, box_corners_t corners;
|
||||
- (void) mvhline: (Point) pos, int ch, int n;
|
||||
-clearReact: (Rect) rect;
|
||||
@end
|
||||
|
||||
#else
|
||||
|
|
|
@ -101,6 +101,43 @@ static TextContext *screen;
|
|||
return self;
|
||||
}
|
||||
|
||||
-clearReact: (Rect) rect
|
||||
{
|
||||
Point pos = rect.offset;
|
||||
int len = rect.extent.width;
|
||||
int count = rect.extent.height;
|
||||
|
||||
if (pos.x + len > xlen) {
|
||||
len = xlen - pos.x;
|
||||
}
|
||||
if (pos.x < 0) {
|
||||
len += pos.x;
|
||||
pos.x = 0;
|
||||
}
|
||||
if (len < 1) {
|
||||
return self;
|
||||
}
|
||||
if (pos.y + count > ylen) {
|
||||
count = ylen - pos.y;
|
||||
}
|
||||
if (pos.y < 0) {
|
||||
count += pos.y;
|
||||
pos.y = 0;
|
||||
}
|
||||
if (count < 1) {
|
||||
return self;
|
||||
}
|
||||
int ch = background;
|
||||
if (!(ch & 0xff)) {
|
||||
ch |= ' ';
|
||||
}
|
||||
while (count-- > 0) {
|
||||
[self mvhline:pos, ch, len];
|
||||
pos.y++;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) printf: (string) fmt, ... = #0;
|
||||
- (void) vprintf: (string) mft, @va_list args = #0;
|
||||
- (void) addch: (int) ch = #0;
|
||||
|
@ -110,6 +147,7 @@ static TextContext *screen;
|
|||
- (void) mvvprintf: (Point) pos, string mft, @va_list args = #0;
|
||||
- (void) mvaddch: (Point) pos, int ch = #0;
|
||||
- (void) mvaddstr: (Point) pos, string str = #0;
|
||||
- (void) mvhline: (Point) pos, int ch, int n = #0;
|
||||
|
||||
- (void) resizeTo: (Extent) newSize = #0; // absolute size
|
||||
- (void) refresh = #0;
|
||||
|
@ -164,5 +202,6 @@ void mvwblit_line (window_t window, int x, int y, int *wch, int len) = #0;
|
|||
void wresize (window_t window, int width, int height) = #0;
|
||||
void resizeterm (int width, int height) = #0;
|
||||
Rect getwrect (window_t window) = #0;
|
||||
void mvwhline (window_t win, int x, int y, int ch, int n) = #0;
|
||||
|
||||
void printf(string fmt, ...) = #0;
|
||||
|
|
|
@ -83,6 +83,7 @@ enum {
|
|||
- (void) mvprintf: (Point) pos, string fmt, ...;
|
||||
- (void) mvvprintf: (Point) pos, string fmt, @va_list args;
|
||||
- (void) mvaddch: (Point) pos, int ch;
|
||||
-clear;
|
||||
@end
|
||||
|
||||
@interface View: Object <View>
|
||||
|
|
|
@ -213,6 +213,12 @@ updateScreenCursor (View *view)
|
|||
[textContext mvaddstr: pos, str];
|
||||
}
|
||||
|
||||
-clear
|
||||
{
|
||||
[textContext clearReact:rect];
|
||||
return self;
|
||||
}
|
||||
|
||||
-move: (Point) delta
|
||||
{
|
||||
xpos += delta.x;
|
||||
|
|
Loading…
Reference in a new issue