Hello, I made a new patch --- forget my former patch. - I moved the code from zvtterm.c to update.c, it seems to be more natural to have it there. - Aron Griffis suggested to mimic cutToBeginningOfLine xterm-behavior. (triple clicking to select a line selects only from the current word forward). John GOTTS want's this to be configurable, which I second. I made this is a runtime configurable option, defaulting to the classic "select whole line". To use this feature you need a patched gnome-terminal, with an extended Settings-dialog. - Someone suggested to mimic MS-IE behavior. In my opinion this behavior is neither logical nor useful: I refuse to do this. Attached are two patches, one against 'gnome-libs-1.2.13' containing the libzvt-changes and one against 'gnome-core' containing the patched gnome-terminal. MfG bmg -- "Des is völlig wurscht, was heut beschlos- | M G Berberich sen wird: I bin sowieso dagegn!" | berberic fmi uni-passau de (SPD-Stadtrat Kurt Schindler; Regensburg) |
diff -Naur gnome-libs-1.2.13/zvt/update.c gnome-libs-1.2.13-bmg/zvt/update.c --- gnome-libs-1.2.13/zvt/update.c Sun Aug 27 16:22:23 2000 +++ gnome-libs-1.2.13-bmg/zvt/update.c Wed May 16 08:29:32 2001 @@ -853,6 +853,24 @@ d( printf("wordclass: "); for(i=0;i<sizeof(vx->wordclass);i++) printf("%2.2x", vx->wordclass[i]); printf("\n") ); } +/* + scan back over word chars. +*/ +static int vt_scan_back_word(struct _vtx *vx, struct vt_line *s, int a) +{ + if ((s->data[a]&VTATTR_DATAMASK)==0 || (s->data[a]&VTATTR_DATAMASK)==9) { + while ((a>0) && ((s->data[a]&VTATTR_DATAMASK) == 0)) + a--; + if (a && ((s->data[a])&VTATTR_DATAMASK)!=0x09) /* 'compress' tabs */ + a++; + } else { + while ((a>0) && (( (vt_in_wordclass(vx, s->data[a]))))) + a--; + if (!vt_in_wordclass(vx, s->data[a])) + a++; + } + return a; +} /* fixes up the selection boundaries made by the mouse, so they @@ -903,36 +921,40 @@ s = (struct vt_line *)vt_list_index(sy<0?(&vx->vt.scrollback):(&vx->vt.lines), sy); e = (struct vt_line *)vt_list_index(ey<0?(&vx->vt.scrollback):(&vx->vt.lines), ey); + /* make sure initial point is in selection */ + if (ey<vx->selinity || (ey==vx->selinity && ex<vx->selinitx)) { + ex = vx->selinitx; + ey = vx->selinity; + } + if (sy>vx->selinity || (sy==vx->selinity && sx>vx->selinitx)) { + sx = vx->selinitx; + sy = vx->selinity; + } + /* if we didn't find it ... umm? FIXME: do something? */ switch(vx->selectiontype & VT_SELTYPE_MASK) { case VT_SELTYPE_LINE: d(printf("selecting by line\n")); - sx=0; + + if (vx->cut_to_begin) { + sx = vt_scan_back_word(vx, s, sx); + } else { + sx=0; + } ex=e->width; break; case VT_SELTYPE_WORD: d(printf("selecting by word\n")); - /* scan back over word chars */ - d(printf("startx = %d %p-> \n", sx, s->data)); + d(printf("startx = %d %p-> \n", sx, s->data)); + if (ex==sx && ex<e->width && sy==ey) ex++; - if ((s->data[sx]&VTATTR_DATAMASK)==0 || (s->data[sx]&VTATTR_DATAMASK)==9) { - while ((sx>0) && ((s->data[sx]&VTATTR_DATAMASK) == 0)) - sx--; - if (sx && - ((s->data[sx])&VTATTR_DATAMASK)!=0x09) /* 'compress' tabs */ - sx++; - } else { - while ((sx>0) && - (( (vt_in_wordclass(vx, s->data[sx]))))) - sx--; - if (!vt_in_wordclass(vx, s->data[sx])) - sx++; - } - d(printf("%d\n", sx)); + sx = vt_scan_back_word(vx, s, sx); + d(printf("%d\n", sx)); + /* scan forward over word chars */ /* special cases for tabs and 'blank' character select */ if ( !((ex >0) && ((e->data[ex-1]&VTATTR_DATAMASK) != 0)) ) @@ -1666,6 +1688,7 @@ vx->selection_size = 0; vx->selected = 0; vx->selectiontype = VT_SELTYPE_NONE; + vx->cut_to_begin = FALSE; vx->scroll_type = VT_SCROLL_ALWAYS; diff -Naur gnome-libs-1.2.13/zvt/vtx.h gnome-libs-1.2.13-bmg/zvt/vtx.h --- gnome-libs-1.2.13/zvt/vtx.h Fri Nov 19 01:50:17 1999 +++ gnome-libs-1.2.13-bmg/zvt/vtx.h Wed May 16 08:23:00 2001 @@ -82,7 +82,9 @@ int selstartx, selstarty; int selendx, selendy; - + int selinitx, selinity; + int cut_to_begin; /* mimic xterms cutToBeginningOfLine */ + /* previously rendered values */ int selstartxold, selstartyold; int selendxold, selendyold; diff -Naur gnome-libs-1.2.13/zvt/zvtterm.c gnome-libs-1.2.13-bmg/zvt/zvtterm.c --- gnome-libs-1.2.13/zvt/zvtterm.c Fri Mar 9 07:22:04 2001 +++ gnome-libs-1.2.13-bmg/zvt/zvtterm.c Wed May 16 08:24:26 2001 @@ -429,6 +429,20 @@ vt_set_wordclass(term->vx, class); } +/** + * zvt_term_set_cut_to_begin + * + * if TRUE mimic xterms cutToBeginningOfLine behavior + */ +void zvt_term_set_cut_to_begin(ZvtTerm *term, int state) +{ + g_return_if_fail (term != NULL); + g_return_if_fail (ZVT_IS_TERM (term)); + + term->vx->cut_to_begin = (state != 0); +} + + static void term_force_size(ZvtTerm *term) { @@ -1548,6 +1562,8 @@ vx->selstarty = y; vx->selendx = x; vx->selendy = y; + vx->selinitx = x; + vx->selinity = y; /* reset 'drawn' screen (to avoid mis-refreshes) */ if (!vx->selected) { diff -Naur gnome-libs-1.2.13/zvt/zvtterm.h gnome-libs-1.2.13-bmg/zvt/zvtterm.h --- gnome-libs-1.2.13/zvt/zvtterm.h Fri Mar 9 07:22:04 2001 +++ gnome-libs-1.2.13-bmg/zvt/zvtterm.h Wed May 16 08:20:41 2001 @@ -221,6 +221,7 @@ void zvt_term_set_del_key_swap (ZvtTerm *term, int state); void zvt_term_set_del_is_del (ZvtTerm *term, int state); void zvt_term_set_wordclass (ZvtTerm *term, unsigned char *klass); +void zvt_term_set_cut_to_begin (ZvtTerm *term, int state); /* regular expression matching - automagically! */ int zvt_term_match_add (ZvtTerm *term, char *regex,
diff -Naur gnome-core/acconfig.h gnome-core-bmg/acconfig.h --- gnome-core/acconfig.h Wed Apr 18 22:03:38 2001 +++ gnome-core-bmg/acconfig.h Wed May 16 09:42:59 2001 @@ -44,6 +44,7 @@ #undef HAVE_ZVT_TERM_RESET #undef HAVE_ZVT_DEL_IS_DEL +#undef HAVE_ZVT_CUT_TO_BEGIN #undef HAVE_HOSTS_ACCESS diff -Naur gnome-core/gnome-terminal/gnome-terminal.c gnome-core-bmg/gnome-terminal/gnome-terminal.c --- gnome-core/gnome-terminal/gnome-terminal.c Thu Apr 19 19:46:47 2001 +++ gnome-core-bmg/gnome-terminal/gnome-terminal.c Wed May 16 09:52:57 2001 @@ -109,6 +109,9 @@ #ifdef HAVE_ZVT_DEL_IS_DEL int del_is_del :1; /* Generates Delete DEL/^H? */ #endif +#ifdef HAVE_ZVT_CUT_TO_BEGIN + int cut_to_begin :1; /* cutToBeginningOfLine */ +#endif enum palette_enum color_type; /* The color mode */ enum color_set_enum color_set; char *font; /* Font used by the terminals */ @@ -163,6 +166,9 @@ #ifdef HAVE_ZVT_DEL_IS_DEL GtkWidget *del_is_del_checkbox; #endif +#ifdef HAVE_ZVT_CUT_TO_BEGIN + GtkWidget *cut_to_begin_checkbox; +#endif GtkWidget *login_by_default_checkbox; GtkWidget *use_bold_checkbox; GtkWidget *wordclass_entry; @@ -525,6 +531,9 @@ #ifdef HAVE_ZVT_DEL_IS_DEL cfg->del_is_del = gnome_config_get_bool ("del_is_del=0"); #endif +#ifdef HAVE_ZVT_CUT_TO_BEGIN + cfg->cut_to_begin = gnome_config_get_bool ("cut_to_begin=0"); +#endif cfg->login_by_default = gnome_config_get_bool ("login_by_default=0"); cfg->use_bold = gnome_config_get_bool ("use_bold=true"); @@ -596,6 +605,9 @@ #ifdef HAVE_ZVT_DEL_IS_DEL newcfg->del_is_del = GTK_TOGGLE_BUTTON (prefs->del_is_del_checkbox)->active; #endif +#ifdef HAVE_ZVT_CUT_TO_BEGIN + newcfg->cut_to_begin = GTK_TOGGLE_BUTTON (prefs->cut_to_begin_checkbox)->active; +#endif newcfg->menubar_hidden = GTK_TOGGLE_BUTTON (prefs->menubar_checkbox)->active; newcfg->scroll_out = GTK_TOGGLE_BUTTON (prefs->scroll_out_checkbox)->active; newcfg->scroll_key = GTK_TOGGLE_BUTTON (prefs->scroll_kbd_checkbox)->active; @@ -688,6 +700,9 @@ zvt_term_set_del_key_swap (term, cfg->swap_keys); #ifdef HAVE_ZVT_DEL_IS_DEL zvt_term_set_del_is_del (term, cfg->del_is_del); +#endif# +#ifdef HAVE_ZVT_CUT_TO_BEGIN + zvt_term_set_cut_to_begin (term, cfg->cut_to_begin); #endif if (zvt_pixmap_support && cfg->background_pixmap) { @@ -1028,6 +1043,9 @@ #ifdef HAVE_ZVT_DEL_IS_DEL gnome_config_set_bool ("del_is_del", cfg->del_is_del); #endif +#ifdef HAVE_ZVT_CUT_TO_BEGIN + gnome_config_set_bool ("cut_to_begin", cfg->cut_to_begin); +#endif gnome_config_set_bool ("login_by_default", cfg->login_by_default); gnome_config_set_bool ("use_bold", cfg->use_bold); gnome_config_set_int ("scrollbacklines", cfg->scrollback); @@ -1233,6 +1251,14 @@ gtk_signal_connect (GTK_OBJECT (prefs->del_is_del_checkbox), "toggled", GTK_SIGNAL_FUNC (prop_changed), prefs); #endif +#ifdef HAVE_ZVT_CUT_TO_BEGIN + /* mimic xterm cutToBeginningOfLine */ + prefs->cut_to_begin_checkbox = glade_xml_get_widget (gui, "cut-to-begin-checkbox"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs->cut_to_begin_checkbox), + cfg->cut_to_begin ? 1 : 0); + gtk_signal_connect (GTK_OBJECT (prefs->cut_to_begin_checkbox), "toggled", + GTK_SIGNAL_FUNC (prop_changed), prefs); +#endif /* --login by default */ prefs->login_by_default_checkbox = glade_xml_get_widget (gui, "login-by-default-checkbox"); @@ -2192,6 +2218,9 @@ zvt_term_set_del_key_swap (term, cfg->swap_keys); #ifdef HAVE_ZVT_DEL_IS_DEL zvt_term_set_del_is_del (term, cfg->del_is_del); +#endif +#ifdef HAVE_ZVT_CUT_TO_BEGIN + zvt_term_set_cut_to_begin (term, cfg->cut_to_begin); #endif gtk_signal_connect (GTK_OBJECT (term), "child_died", diff -Naur gnome-core/gnome-terminal/gnome-terminal.glade gnome-core-bmg/gnome-terminal/gnome-terminal.glade --- gnome-core/gnome-terminal/gnome-terminal.glade Wed May 16 09:18:26 2001 +++ gnome-core-bmg/gnome-terminal/gnome-terminal.glade Wed May 16 09:52:23 2001 @@ -426,6 +426,29 @@ <yfill>False</yfill> </child> </widget> + + <widget> + <class>GtkCheckButton</class> + <name>cut-to-begin-checkbox</name> + <can_focus>True</can_focus> + <label>Cut to beginning of line</label> + <active>False</active> + <draw_indicator>True</draw_indicator> + <child> + <left_attach>1</left_attach> + <right_attach>2</right_attach> + <top_attach>3</top_attach> + <bottom_attach>4</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> </widget> </widget> diff -Naur gnome-core/gnome-terminal/gnome-terminal.glade.h gnome-core-bmg/gnome-terminal/gnome-terminal.glade.h --- gnome-core/gnome-terminal/gnome-terminal.glade.h Wed May 16 09:16:43 2001 +++ gnome-core-bmg/gnome-terminal/gnome-terminal.glade.h Wed May 16 09:52:23 2001 @@ -17,6 +17,7 @@ gchar *s = N_("Use --login by default"); gchar *s = N_("Delete generates DEL/^H"); gchar *s = N_("Select-by-word characters:"); +gchar *s = N_("Cut to beginning of line"); gchar *s = N_("General"); gchar *s = N_("Background type"); gchar *s = N_("Background pixmap");
Attachment:
pgpgc4WeoXOKQ.pgp
Description: PGP signature