Fixed switcing to alternate buffer and cursor saving

master
Yevgen Muntyan 2005-07-17 04:38:09 +00:00
parent 9944b0da7e
commit 8bebdfe18d
7 changed files with 131 additions and 143 deletions

View File

@ -59,6 +59,7 @@ enum {
CURSOR = 2
};
typedef enum {
CURSOR_BLOCK,
CURSOR_UNDERLINE
@ -87,7 +88,17 @@ struct _MooTermPrivate {
guint cursor_row;
guint cursor_col;
GArray *saved_cursor;
struct {
guint cursor_row, cursor_col;
MooTermTextAttr attr;
int GL, GR;
gboolean autowrap;
gboolean decom;
guint top_margin, bottom_margin;
/* TODO: Selective erase attribute ??? */
int single_shift;
} saved_cursor;
TermSelection *selection;
@ -222,6 +233,9 @@ void moo_term_set_mode (MooTerm *term,
gboolean set);
void moo_term_set_ca_mode (MooTerm *term,
gboolean set);
void moo_term_decsc (MooTerm *term);
void moo_term_decrc (MooTerm *term);
/* these two are in mootermdraw.c */
void moo_term_invert_colors (MooTerm *term,
gboolean invert);

View File

@ -75,8 +75,8 @@ G_STMT_START { \
#define VT_IL(n) moo_term_buffer_insert_line (parser->term->priv->buffer, n)
#define VT_CUP(r,c) moo_term_buffer_cup (parser->term->priv->buffer, (r)-1, (c)-1)
#define VT_DECSTBM(t,b) moo_term_buffer_set_scrolling_region (parser->term->priv->buffer, (t)-1, (b)-1);
#define VT_DECSC moo_term_buffer_decsc (parser->term->priv->buffer)
#define VT_DECRC moo_term_buffer_decrc (parser->term->priv->buffer)
#define VT_DECSC moo_term_decsc (parser->term)
#define VT_DECRC moo_term_decrc (parser->term)
#define VT_DECSET moo_term_set_dec_modes (parser->term, \
(int*) parser->numbers->data, \
parser->numbers->len, \

View File

@ -62,6 +62,8 @@ static void im_preedit_end (MooTerm *term);
static void child_died (MooTerm *term);
static void clear_saved_cursor (MooTerm *term);
enum {
SET_SCROLL_ADJUSTMENTS,
@ -180,7 +182,7 @@ static void moo_term_init (MooTerm *term)
term->priv->alternate_buffer = moo_term_buffer_new (80, 24);
term->priv->buffer = term->priv->primary_buffer;
term->priv->saved_cursor = g_array_new (FALSE, FALSE, sizeof(guint));
clear_saved_cursor (term);
term->priv->width = 80;
term->priv->height = 24;
@ -261,8 +263,6 @@ static void moo_term_finalize (GObject *object)
term_selection_free (term->priv->selection);
term_font_info_free (term->priv->font_info);
g_array_free (term->priv->saved_cursor, TRUE);
g_object_unref (term->priv->back_pixmap);
if (term->priv->changed_content)
@ -1079,30 +1079,54 @@ void moo_term_set_mode (MooTerm *term,
}
static void save_cursor (MooTerm *term)
static void clear_saved_cursor (MooTerm *term)
{
g_array_append_val (term->priv->saved_cursor,
term->priv->cursor_row);
g_array_append_val (term->priv->saved_cursor,
term->priv->cursor_col);
term->priv->saved_cursor.cursor_row = 0;
term->priv->saved_cursor.cursor_col = 0;
term->priv->saved_cursor.attr.mask = 0;
term->priv->saved_cursor.GL = 0;
term->priv->saved_cursor.GR = 4;
term->priv->saved_cursor.autowrap = DEFAULT_MODE_DECAWM;
term->priv->saved_cursor.decom = DEFAULT_MODE_DECOM;
term->priv->saved_cursor.top_margin = 0,
term->priv->saved_cursor.bottom_margin = 999;
term->priv->saved_cursor.single_shift = -1;
}
static void restore_cursor (MooTerm *term)
{
guint row = 0;
guint col = 0;
if (term->priv->saved_cursor->len)
void moo_term_decsc (MooTerm *term)
{
row = g_array_index (term->priv->saved_cursor, guint,
term->priv->saved_cursor->len - 2);
col = g_array_index (term->priv->saved_cursor, guint,
term->priv->saved_cursor->len - 1);
g_array_set_size (term->priv->saved_cursor,
term->priv->saved_cursor->len - 2);
MooTermBuffer *buf = term->priv->buffer;
term->priv->saved_cursor.cursor_row = term->priv->cursor_row;
term->priv->saved_cursor.cursor_col = term->priv->cursor_col;
term->priv->saved_cursor.attr = buf->priv->current_attr;
term->priv->saved_cursor.GL = buf->priv->GL[0];
term->priv->saved_cursor.GR = buf->priv->GL[1];
term->priv->saved_cursor.autowrap = term_get_mode (MODE_DECAWM);
term->priv->saved_cursor.decom = term_get_mode (MODE_DECOM);
term->priv->saved_cursor.top_margin = buf->priv->top_margin;
term->priv->saved_cursor.bottom_margin = buf->priv->bottom_margin;
term->priv->saved_cursor.single_shift = buf->priv->single_shift;
}
moo_term_buffer_cursor_move_to (term->priv->buffer, row, col);
void moo_term_decrc (MooTerm *term)
{
MooTermBuffer *buf = term->priv->buffer;
moo_term_buffer_cursor_move_to (term->priv->buffer,
term->priv->saved_cursor.cursor_row,
term->priv->saved_cursor.cursor_col);
buf->priv->current_attr = term->priv->saved_cursor.attr;
buf->priv->GL[0] = term->priv->saved_cursor.GL;
buf->priv->GL[1] = term->priv->saved_cursor.GR;
moo_term_set_mode (term, MODE_DECAWM, term->priv->saved_cursor.autowrap);
moo_term_set_mode (term, MODE_DECOM, term->priv->saved_cursor.decom);
moo_term_buffer_set_scrolling_region (buf,
term->priv->saved_cursor.top_margin,
term->priv->saved_cursor.bottom_margin);
buf->priv->single_shift = term->priv->saved_cursor.single_shift;
}
@ -1111,7 +1135,7 @@ void moo_term_set_ca_mode (MooTerm *term,
{
if (set)
{
save_cursor (term);
moo_term_decsc (term);
moo_term_set_alternate_buffer (term, TRUE);
moo_term_buffer_erase_in_display (term->priv->buffer, 2);
moo_term_buffer_set_ca_mode (term->priv->buffer, TRUE);
@ -1120,7 +1144,7 @@ void moo_term_set_ca_mode (MooTerm *term,
{
moo_term_set_alternate_buffer (term, FALSE);
moo_term_buffer_set_ca_mode (term->priv->buffer, FALSE);
restore_cursor (term);
moo_term_decrc (term);
}
}
@ -1218,6 +1242,7 @@ void moo_term_reset (MooTerm *term)
moo_term_buffer_reset (term->priv->alternate_buffer);
set_default_modes (term->priv->modes);
set_default_modes (term->priv->saved_modes);
clear_saved_cursor (term);
moo_term_buffer_thaw_changed_notify (term->priv->primary_buffer);
moo_term_buffer_thaw_cursor_notify (term->priv->primary_buffer);

View File

@ -120,6 +120,8 @@ static gunichar ASCII_DRAWING_SET[MAX_GRAPH + 1] = {
static gunichar DRAWING_SET[MAX_GRAPH + 1];
static gunichar *graph_sets[5];
static void init_drawing_sets (void)
{
guint i;
@ -134,6 +136,9 @@ static void init_drawing_sets (void)
if (!ASCII_DRAWING_SET[i] && '\040' <= i && i <= '\176')
ASCII_DRAWING_SET[i] = i;
}
graph_sets[0] = graph_sets[2] = DRAWING_SET;
graph_sets[1] = graph_sets[3] = graph_sets[4] = NULL;
}

View File

@ -26,6 +26,15 @@
G_BEGIN_DECLS
typedef enum {
CHARSET_DRAWING = 0,
CHARSET_ACRSSS = 1,
CHARSET_ACRSPS = 2,
CHARSET_UK = 3,
CHARSET_ASCII = 4
} CharsetType;
struct _MooTermBufferPrivate {
gboolean constructed;
@ -35,9 +44,8 @@ struct _MooTermBufferPrivate {
MooTermTextAttr current_attr;
int single_shift;
gunichar *graph_sets[4];
gunichar *current_graph_set;
gboolean use_ascii_graphics;
CharsetType GL[4];
CharsetType current_graph_set;
/* these are real position and
dimensions of the screen */
@ -54,18 +62,6 @@ struct _MooTermBufferPrivate {
guint cursor_row;
guint cursor_col;
/* TODO: is it per-terminal or per-buffer? */
struct {
guint cursor_row, cursor_col;
MooTermTextAttr attr;
gunichar *GL, *GR;
gboolean autowrap;
gboolean decom;
guint top_margin, bottom_margin;
/* TODO: Selective erase attribute ??? */
int single_shift;
} saved;
GList *tab_stops;
GdkRegion *changed;
@ -319,10 +315,6 @@ void moo_term_buffer_cup (MooTermBuffer *buf,
guint row,
guint col);
void moo_term_buffer_clear_saved (MooTermBuffer *buf);
void moo_term_buffer_decsc (MooTermBuffer *buf);
void moo_term_buffer_decrc (MooTermBuffer *buf);
void moo_term_buffer_decaln (MooTermBuffer *buf);

View File

@ -149,7 +149,6 @@ static void moo_term_buffer_init (MooTermBuffer *buf)
buf->priv->changed_all = FALSE;
set_defaults (buf);
moo_term_buffer_clear_saved (buf);
}
@ -520,20 +519,23 @@ static void buf_print_unichar_real (MooTermBuffer *buf,
{
if (buf->priv->single_shift >= 0)
{
if (buf->priv->graph_sets[buf->priv->single_shift])
g_assert (buf->priv->single_shift < 4);
if (graph_sets[buf->priv->GL[buf->priv->single_shift]])
{
if (buf->priv->graph_sets[buf->priv->single_shift][c])
c = buf->priv->graph_sets[buf->priv->single_shift][c];
if (graph_sets[buf->priv->GL[buf->priv->single_shift]][c])
c = graph_sets[buf->priv->GL[buf->priv->single_shift]][c];
else
g_warning ("%s: using regular character while in "
"graphics mode", G_STRLOC);
}
buf->priv->single_shift = -1;
}
else if (buf->priv->current_graph_set)
else if (graph_sets[buf->priv->current_graph_set])
{
if (buf->priv->current_graph_set[c])
c = buf->priv->current_graph_set[c];
if (graph_sets[buf->priv->current_graph_set][c])
c = graph_sets[buf->priv->current_graph_set][c];
else
g_warning ("%s: using regular character while in "
"graphics mode", G_STRLOC);
@ -729,42 +731,36 @@ void moo_term_buffer_set_tab_stop (MooTermBuffer *buf)
void moo_term_buffer_select_charset (MooTermBuffer *buf,
guint set_num,
guint charset)
CharsetType charset)
{
g_return_if_fail (set_num < 4 && charset < 5);
switch (charset)
{
case 0:
if (buf->priv->use_ascii_graphics)
buf->priv->graph_sets[set_num] = ASCII_DRAWING_SET;
else
buf->priv->graph_sets[set_num] = DRAWING_SET;
case CHARSET_DRAWING:
buf->priv->GL[set_num] = CHARSET_DRAWING;
break;
case 2:
case CHARSET_ACRSPS:
g_warning ("%s: choosing graphics instead of"
"Alternate Character ROM Special Set", G_STRLOC);
if (buf->priv->use_ascii_graphics)
buf->priv->graph_sets[set_num] = ASCII_DRAWING_SET;
else
buf->priv->graph_sets[set_num] = DRAWING_SET;
buf->priv->GL[set_num] = CHARSET_DRAWING;
break;
case 1:
case CHARSET_ACRSSS:
g_warning ("%s: choosing regular charset instead of"
"Alternate Character ROM Standard Set", G_STRLOC);
buf->priv->graph_sets[set_num] = NULL;
buf->priv->GL[set_num] = CHARSET_ASCII;
break;
case 3:
case CHARSET_UK:
g_warning ("%s: choosing regular charset instead of"
"United Kingdom", G_STRLOC);
buf->priv->graph_sets[set_num] = NULL;
buf->priv->GL[set_num] = CHARSET_ASCII;
break;
case 4:
buf->priv->graph_sets[set_num] = NULL;
case CHARSET_ASCII:
buf->priv->GL[set_num] = CHARSET_ASCII;
break;
}
}
@ -774,7 +770,7 @@ void moo_term_buffer_shift (MooTermBuffer *buf,
guint set)
{
g_return_if_fail (set < 4);
buf->priv->current_graph_set = buf->priv->graph_sets[set];
buf->priv->current_graph_set = buf->priv->GL[set];
}
@ -1414,57 +1410,6 @@ void moo_term_buffer_insert_line (MooTermBuffer *buf,
}
void moo_term_buffer_decsc (MooTermBuffer *buf)
{
g_message ("DECSC");
buf->priv->saved.cursor_row = buf->priv->cursor_row;
buf->priv->saved.cursor_col = buf->priv->cursor_col;
buf->priv->saved.attr = buf->priv->current_attr;
buf->priv->saved.GL = buf->priv->graph_sets[0];
buf->priv->saved.GR = buf->priv->graph_sets[1];
buf->priv->saved.autowrap = buf_get_mode (MODE_DECAWM);
buf->priv->saved.decom = buf_get_mode (MODE_DECOM);
buf->priv->saved.top_margin = buf->priv->top_margin;
buf->priv->saved.bottom_margin = buf->priv->bottom_margin;
buf->priv->saved.single_shift = buf->priv->single_shift;
}
void moo_term_buffer_decrc (MooTermBuffer *buf)
{
g_message ("DECRC");
buf->priv->cursor_row = buf->priv->saved.cursor_row;
buf->priv->cursor_col = buf->priv->saved.cursor_col;
buf->priv->current_attr = buf->priv->saved.attr;
buf->priv->graph_sets[0] = buf->priv->saved.GL;
buf->priv->graph_sets[1] = buf->priv->saved.GR;
moo_term_buffer_set_mode (buf, MODE_DECAWM, buf->priv->saved.autowrap);
moo_term_buffer_set_mode (buf, MODE_DECOM, buf->priv->saved.decom);
moo_term_buffer_set_scrolling_region (buf, buf->priv->top_margin,
buf->priv->bottom_margin);
buf->priv->single_shift = buf->priv->saved.single_shift;
}
void moo_term_buffer_clear_saved (MooTermBuffer *buf)
{
buf->priv->saved.cursor_row = 0;
buf->priv->saved.cursor_col = 0;
buf->priv->saved.attr.mask = 0;
buf->priv->saved.autowrap = DEFAULT_MODE_DECAWM;
buf->priv->saved.decom = DEFAULT_MODE_DECOM;
buf->priv->saved.top_margin = 0;
buf->priv->saved.bottom_margin = buf_screen_height (buf) - 1;
buf->priv->saved.single_shift = -1;
buf->priv->saved.GL = NULL;
if (buf->priv->use_ascii_graphics)
buf->priv->saved.GR = ASCII_DRAWING_SET;
else
buf->priv->saved.GR = DRAWING_SET;
}
void moo_term_buffer_set_mode (MooTermBuffer *buf,
guint mode,
gboolean set)
@ -1475,10 +1420,19 @@ void moo_term_buffer_set_mode (MooTermBuffer *buf,
moo_term_buffer_set_ca_mode (buf, set);
break;
/* xterm does this */
case MODE_DECANM:
if (set)
{
buf->priv->GL[0] = buf->priv->GL[1] = CHARSET_ASCII;
buf->priv->GL[2] = buf->priv->GL[3] = CHARSET_ASCII;
}
buf->priv->modes[mode] = set;
break;
/* these do not require anything special, just record the value */
case MODE_IRM:
case MODE_LNM:
case MODE_DECANM:
case MODE_DECOM:
case MODE_DECAWM:
case MODE_REVERSE_WRAPAROUND: /* TODO*/
@ -1524,11 +1478,9 @@ static void set_defaults (MooTermBuffer *buf)
set_default_modes (buf->priv->modes);
buf->priv->current_attr.mask = 0;
buf->priv->single_shift = -1;
buf->priv->graph_sets[0] = buf->priv->graph_sets[1] =
buf->priv->graph_sets[2] = buf->priv->graph_sets[3] = NULL;
buf->priv->current_graph_set = NULL;
moo_term_buffer_clear_saved (buf);
buf->priv->GL[0] = buf->priv->GL[2] = buf->priv->GL[3] = CHARSET_ASCII;
buf->priv->GL[1] = CHARSET_DRAWING;
buf->priv->current_graph_set = CHARSET_ASCII;
}
@ -1566,9 +1518,9 @@ void moo_term_buffer_soft_reset (MooTermBuffer *buf)
buf->priv->current_attr.mask = 0;
buf->priv->single_shift = -1;
buf->priv->graph_sets[0] = buf->priv->graph_sets[1] =
buf->priv->graph_sets[2] = buf->priv->graph_sets[3] = NULL;
buf->priv->current_graph_set = NULL;
buf->priv->GL[0] = buf->priv->GL[2] = buf->priv->GL[3] = CHARSET_ASCII;
buf->priv->GL[1] = CHARSET_DRAWING;
buf->priv->current_graph_set = CHARSET_ASCII;
buf_changed_set_all (buf);
moo_term_buffer_changed (buf);

View File

@ -24,7 +24,7 @@
</ignoreparts>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description/>
<description></description>
<secondaryLanguages>
<language>C</language>
</secondaryLanguages>
@ -39,7 +39,7 @@
<mainprogram>tests/mterm</mainprogram>
<directoryradio>executable</directoryradio>
<customdirectory>/</customdirectory>
<programargs/>
<programargs></programargs>
<terminal>false</terminal>
<autocompile>true</autocompile>
<envvars/>
@ -141,18 +141,18 @@
<abortonerror>true</abortonerror>
<numberofjobs>1</numberofjobs>
<dontact>false</dontact>
<makebin/>
<makebin></makebin>
<prio>0</prio>
</make>
</kdevautoproject>
<kdevdebugger>
<general>
<dbgshell>libtool</dbgshell>
<programargs>--g-fatal-warnings --debug bash</programargs>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<programargs>--g-fatal-warnings bash</programargs>
<gdbpath></gdbpath>
<configGdbScript></configGdbScript>
<runShellScript></runShellScript>
<runGdbScript></runGdbScript>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>true</floatingtoolbar>
@ -217,16 +217,16 @@
</kdevdoctreeview>
<kdevfilecreate>
<filetypes>
<type icon="source" ext="g" create="template" name="GAP source" >
<type icon="source" ext="g" name="GAP source" create="template" >
<descr>A new empty GAP source file</descr>
</type>
<type icon="source_cpp" ext="cpp" create="template" name="C++ Source" >
<type icon="source_cpp" ext="cpp" name="C++ Source" create="template" >
<descr>A new empty C++ file.</descr>
</type>
<type icon="source_h" ext="h" create="template" name="C/C++ Header" >
<type icon="source_h" ext="h" name="C/C++ Header" create="template" >
<descr>A new empty header file for C/C++.</descr>
</type>
<type icon="source_c" ext="c" create="template" name="C Source" >
<type icon="source_c" ext="c" name="C Source" create="template" >
<descr>A new empty C file.</descr>
</type>
</filetypes>
@ -253,7 +253,7 @@
</codecompletion>
<references/>
<creategettersetter>
<prefixGet/>
<prefixGet></prefixGet>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>