# vile 9.5c - patch 2005/11/23 - Thomas Dickey # ------------------------------------------------------------------------------ # CHANGES | 40 ++ # MANIFEST | 8 # ansi.c | 5 # basic.c | 13 # bind.c | 26 + # borland.c | 677 +++++++++++++++++++++++------------------------- # chgdfunc.h | 3 # configure | 2 # configure.in | 6 # curses.c | 170 +++--------- # display.c | 8 # doc/macros.doc | 8 # dumbterm.c | 5 # estruct.h | 170 +----------- # exec.c | 11 # file.c | 5 # filters/filters.rc | 8 # filters/rubyfilt.c | 4 # filters/sed-filt.c | 4 # macros/modes.rc | 14 # macros/vileinit.rc | 68 +++- # macros/vilemenu.rc | 14 # main.c | 49 ++- # makefile.in | 5 # map.c | 74 ++--- # menu.c | 8 # modes.c | 21 + # modetbl | 3 # npopen.c | 6 # ntconio.c | 5 # ntwinio.c | 5 # os2vio.c | 5 # patchlev.h | 2 # proto.h | 41 +- # regexp.c | 165 ++++++++--- # revlist | 94 +++--- # spawn.c | 4 # tcap.c | 442 ++----------------------------- # tcap.h | 16 + # termio.c | 23 + # trace.h | 19 + # vile-9.5c/vl_alloc.h | 48 +++ # vile-9.5c/vl_ctype.h | 197 +++++++++++++ # vile-9.5c/vl_regex.h | 93 ++++++ # vile-9.5c/xterm.c | 285 ++++++++++++++++++++ # vile-9.5c/xtermkeys.h | 209 ++++++++++++++ # vile.hlp | 6 # vmsvt.c | 5 # x11.c | 5 # 49 files changed, 1824 insertions(+), 1280 deletions(-) # ------------------------------------------------------------------------------ # Please remove the following file before applying this patch. # (You can feed this patch to 'sh' to do so.) rm -f ibmpc.c exit Index: CHANGES --- vile-9.5b+/CHANGES 2005-10-03 00:13:03.000000000 +0000 +++ vile-9.5c/CHANGES 2005-11-24 01:33:01.000000000 +0000 @@ -1,5 +1,45 @@ Changes for vile 9.6 (released ??? ??? ?? ????) + 20051123 (c) + > Clark Morgan: + + remove an obsolete comment in macros.doc regarding underscore in + macro names. + > Paul Fox: + + correct logic for check_percent_crlf(), ensuring that empty buffers + are not counted as having CRLF endings. + > Tom Dickey: + + fix to_tabstop() function used for :describe-bindings to ensure that + a binding that happens to be 8 columns will still have a tab after + it. + + add a fflush() to ensure that the control string to reset xterm mouse + mode is written during ^Z handling (report by Fabien Coutant). + + add a call to term.kopen() in rtfrmshell(), making ^Z/resume work + properly with the curses driver (report by Fabien Coutant). + + make mouse work for curses driver just like the termcap/terminfo + driver. + + split xterm-specific code out of tcap.c as xterm.c, to share with + curses.c + + indent'd borland.c + + remove ibmpc.c + + check if stdout is not a tty on startup, print error message and + exit (request by Paul Fox). + + add mode xterm-fkeys, to allow termcap driver to generate + shift/control/alt modifiers for function keys. + + modify regexp.c so tab is not matched by \p or [[:print:]] for + consistency with POSIX regular expressions. + + modified regexp.c, add headers vl_regex.h, vl_alloc.h and vl_ctype.h + to allow it to be easily built outside vile (request by Adrian Kole). + + add KEY_BackTab to the output of show-key-names + + fix kcod2prc() so that a shifted-tab is converted to "Shift+^I" + rather than emitting a literal tab in the result. + + update vilemenu.rc fonts to work on Debian/testing. + + improve scrollbar/cursor tracking in winvile by calling + gui_update_scrollbar() when WFMOVE flag is set (report by Deraj + Puma). + + add a simple csvmode for ".csv" files. + + add ".ebuild" suffix for shmode. + + improve mode-pathname for xresmode to handle things like KOI8Term. + 20051002 (b) > Tom Dickey: + update config.guess, config.sub Index: MANIFEST --- vile-9.5b+/MANIFEST 2005-10-03 00:22:06.000000000 +0000 +++ vile-9.5c/MANIFEST 2005-11-24 01:48:22.000000000 +0000 @@ -1,4 +1,4 @@ -MANIFEST for vile, version v9_5b +MANIFEST for vile, version v9_5c -------------------------------------------------------------------------------- MANIFEST this file CHANGES Change-log for VILE @@ -55,7 +55,6 @@ globals.c ed/vi/ex style global commands gppconio.c patched console I/O support for DJGCC history.c command-history -ibmpc.c IBM PC terminal driver (direct I/O) input.c various input-routines insert.c functions for character-insertion install.sh install-script, needed for configure @@ -119,6 +118,9 @@ vile.1 man-page for VILE vile.hlp help-file vile.wmconfig windowmaker config file for vile +vl_alloc.h malloc-macros for vile +vl_ctype.h character-set tests for vile +vl_regex.h interface for vile's regexp.c vms2unix.c VMS/UNIX compatibility support functions vmsbuild.com VAX/VMS DCL build script vmspipe.c pipe-filter support for VMS @@ -145,6 +147,8 @@ x11.c X11 (Xt, Motif or Openlook) terminal driver x11menu.c X11-specific part of menu support xshell.sh wrapper/sample script for xvile +xterm.c xterm-specific I/O driver support +xtermkeys.h generate bindings for xterm key-modifiers xvile.wmconfig windowmaker config file for xvile doc subdirectory doc/Vileserv.doc overview of Vileserv and vileget scripts Index: ansi.c Prereq: 1.45 --- vile-9.5b+/ansi.c 2004-06-07 21:57:41.000000000 +0000 +++ vile-9.5c/ansi.c 2005-11-23 12:19:35.000000000 +0000 @@ -4,7 +4,7 @@ * "termio.c". It compiles into nothing if not an ANSI device. * * - * $Header: /usr/build/vile/vile/RCS/ansi.c,v 1.45 2004/06/07 21:57:41 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/ansi.c,v 1.46 2005/11/23 12:19:35 tom Exp $ */ #include "estruct.h" @@ -371,6 +371,9 @@ nullterm_watchfd, nullterm_unwatchfd, nullterm_cursorvis, + nullterm_mopen, + nullterm_mclose, + nullterm_mevent, }; #endif /* DISP_ANSI */ Index: basic.c Prereq: 1.122 --- vile-9.5b+/basic.c 2005-05-27 21:48:44.000000000 +0000 +++ vile-9.5c/basic.c 2005-11-16 01:22:08.000000000 +0000 @@ -5,7 +5,7 @@ * functions that adjust the top line in the window and invalidate the * framing, are hard. * - * $Header: /usr/build/vile/vile/RCS/basic.c,v 1.122 2005/05/27 21:48:44 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/basic.c,v 1.123 2005/11/16 01:22:08 tom Exp $ * */ @@ -291,7 +291,9 @@ int gotobos(int f, int n) { + LINE *last = DOT.l; int nn = curwp->w_ntrows; + if (!f || n <= 0) n = 1; @@ -303,7 +305,7 @@ DOT.l = lforw(DOT.l); } - if (nn <= 0) /* we went past the end of window */ + if (DOT.l != last) curwp->w_flag |= WFMOVE; return firstnonwhite(FALSE, 1); } @@ -317,6 +319,7 @@ int gotomos(int f GCC_UNUSED, int n) { + LINE *last = DOT.l; LINE *lp, *head; int half = (curwp->w_ntrows + 1) / 2; @@ -336,6 +339,8 @@ } } + if (DOT.l != last) + curwp->w_flag |= WFMOVE; return firstnonwhite(FALSE, 1); } @@ -347,7 +352,9 @@ int gotoeos(int f, int n) { + LINE *last = DOT.l; int nn; + if (f == FALSE || n <= 0) n = 1; @@ -373,6 +380,8 @@ break; DOT.l = lback(DOT.l); } + if (DOT.l != last) + curwp->w_flag |= WFMOVE; return firstnonwhite(FALSE, 1); } Index: bind.c Prereq: 1.285 --- vile-9.5b+/bind.c 2005-10-02 21:15:05.000000000 +0000 +++ vile-9.5c/bind.c 2005-11-24 01:30:54.000000000 +0000 @@ -3,7 +3,7 @@ * * written 11-feb-86 by Daniel Lawrence * - * $Header: /usr/build/vile/vile/RCS/bind.c,v 1.285 2005/09/22 22:05:18 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/bind.c,v 1.290 2005/11/24 01:30:54 tom Exp $ * */ @@ -618,6 +618,9 @@ { KBIND *kbp; /* pointer into a binding table */ + TRACE(("install_bind(%#x, %s(%s), %s)\n", + c, TRACE_CMDFUNC(kcmd), TRACE_BINDINGS(bs))); + if (c < 0) return FALSE; /* not a legal key-code */ @@ -841,6 +844,7 @@ { KEY_Next, "KEY_Next" }, { KEY_Prior, "KEY_Prior" }, { KEY_Select, "KEY_Select" }, + { KEY_BackTab, "KEY_BackTab" }, { 0, 0 }, { KEY_F1, "KEY_F1" }, { KEY_F2, "KEY_F2" }, @@ -1010,8 +1014,9 @@ static char * to_tabstop(char *buffer) { + unsigned len = strlen(buffer); unsigned cpos = converted_len(buffer); - if (cpos & 7) + if (cpos & 7 || (len != 0 && !isBlank(buffer[len - 1]))) (void) strcat(buffer, "\t"); return skip_string(buffer); } @@ -1594,7 +1599,10 @@ } #endif -/* translate a keycode to its binding-string */ +/* + * Translate a keycode to its binding-string. + * seq[0] gets the length of the result. + */ char * kcod2pstr(int c, char *seq, int limit) { @@ -1720,16 +1728,16 @@ kcod2prc(int c, char *seq) { char temp[NSTRING]; + int length; - (void) kcod2pstr(c, temp, sizeof(temp)); + length = kcod2pstr(c, temp, sizeof(temp))[0]; #if OPT_KEY_MODIFY - if (c & mod_KEY) { - /* Translation is complete, by defn. */ - - strcpy(seq, temp + 1); + if ((c & mod_KEY) != 0 && length != 0) { + (void) strcpy(seq, temp + 1); + (void) bytes2prc(seq + length - 1, temp + length, 1); } else #endif - (void) bytes2prc(seq, temp + 1, (int) *temp); + (void) bytes2prc(seq, temp + 1, length); TRACE(("kcod2prc(%#x) ->%s\n", c, seq)); return seq; } Index: borland.c Prereq: 1.32 --- vile-9.5b+/borland.c 2002-12-22 18:23:59.000000000 +0000 +++ vile-9.5c/borland.c 2005-11-23 12:23:49.000000000 +0000 @@ -9,7 +9,7 @@ * Note: Visual flashes are not yet supported. * * - * $Header: /usr/build/vile/vile/RCS/borland.c,v 1.32 2002/12/22 18:23:59 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/borland.c,v 1.33 2005/11/23 12:23:49 tom Exp $ * */ @@ -23,150 +23,85 @@ #undef OPT_COLOR #endif /* SYS_OS2 */ - #if !DISP_BORLAND || DISP_IBMPC #error misconfigured: DISP_BORLAND should be defined if using borland.c #error (and DISP_IBMPC should not be defined) #endif -#define NROW 50 /* Max Screen size. */ -#define NCOL 80 /* Edit if you want to. */ -#define NPAUSE 200 /* # times thru update to pause */ -#define SPACE 32 /* space character */ +#define NROW 50 /* Max Screen size. */ +#define NCOL 80 /* Edit if you want to. */ +#define NPAUSE 200 /* # times thru update to pause */ +#define SPACE 32 /* space character */ /* We assume that most users have a color display. */ #include -static void borflush (void); -static void bormove (int,int); -static void boreeol (void); -static void boreeop (void); -static void borbeep (void); -static void boropen (void); -static void borrev (UINT); -static int borcres (const char *); -static void borclose (void); -static void borputc (int); -static void borkopen (void); -static void borkclose (void); +static void borflush(void); -#if OPT_COLOR -static void borfcol (int); -static void borbcol (int); -static void borspal (const char *); -#endif - -#if OPT_ICURSOR -static void boricursor(int); -#endif - -int cfcolor = -1; /* current forground color */ -int cbcolor = -1; /* current background color */ +static int cfcolor = -1; /* current forground color */ +static int cbcolor = -1; /* current background color */ /* ansi to ibm color translation table */ -static const char *initpalettestr = "0 4 2 6 1 5 3 7 8 12 10 14 9 13 11 15"; +static const char *initpalettestr = "0 4 2 6 1 5 3 7 8 12 10 14 9 13 11 15"; /* black, red, green, yellow, blue, magenta, cyan, white */ -static void borscroll (int,int,int); - -static int scinit (int); - - -static char linebuf[128]; -static int bufpos = 0; +static int scinit(int); +static char linebuf[128]; +static int bufpos = 0; +/* *INDENT-OFF* */ static struct { - char *seq; - int code; + char *seq; + int code; } keyseqs[] = { - /* Arrow keys */ - {"\0\110", KEY_Up}, - {"\0\120", KEY_Down}, - {"\0\115", KEY_Right}, - {"\0\113", KEY_Left}, - /* page scroll */ - {"\0\121", KEY_Next}, - {"\0\111", KEY_Prior}, - {"\0\107", KEY_Home}, - {"\0\117", KEY_End}, - /* editing */ - {"\0R", KEY_Insert}, - {"\0\123", KEY_Delete}, - /* function keys */ - {"\0;", KEY_F1}, - {"\0<", KEY_F2}, - {"\0=", KEY_F3}, - {"\0>", KEY_F4}, - {"\0?", KEY_F5}, - {"\0@", KEY_F6}, - {"\0A", KEY_F7}, - {"\0B", KEY_F8}, - {"\0C", KEY_F9}, - {"\0D", KEY_F10}, + /* Arrow keys */ + {"\0\110", KEY_Up}, + {"\0\120", KEY_Down}, + {"\0\115", KEY_Right}, + {"\0\113", KEY_Left}, + /* page scroll */ + {"\0\121", KEY_Next}, + {"\0\111", KEY_Prior}, + {"\0\107", KEY_Home}, + {"\0\117", KEY_End}, + /* editing */ + {"\0R", KEY_Insert}, + {"\0\123", KEY_Delete}, + /* function keys */ + {"\0;", KEY_F1}, + {"\0<", KEY_F2}, + {"\0=", KEY_F3}, + {"\0>", KEY_F4}, + {"\0?", KEY_F5}, + {"\0@", KEY_F6}, + {"\0A", KEY_F7}, + {"\0B", KEY_F8}, + {"\0C", KEY_F9}, + {"\0D", KEY_F10}, }; +/* *INDENT-ON* */ -int ibmtype; +static int ibmtype; static int borlastchar = -1; static int bortttypahead(void); static int borttgetc(void); -/* - * Standard terminal interface dispatch table. Most of the fields point into - * "termio" code. - */ -TERM term = { - NROW, - NROW, - NCOL, - NCOL, - NPAUSE, - boropen, - borclose, - borkopen, - borkclose, - borttgetc, - borputc, - bortttypahead, - borflush, - bormove, - boreeol, - boreeop, - borbeep, - borrev, - borcres, -#if OPT_COLOR - borfcol, - borbcol, - borspal, -#else - nullterm_setfore, - nullterm_setback, - nullterm_setpal, -#endif - nullterm_setccol, - borscroll, - nullterm_pflush, -#if OPT_ICURSOR - boricursor, -#else - nullterm_icursor, -#endif - nullterm_settitle, - nullterm_watchfd, - nullterm_unwatchfd, - nullterm_cursorvis, -}; - #if OPT_ICURSOR static void boricursor(int cmode) { - switch (cmode) { - case -1: _setcursortype( _NOCURSOR); break; - case 0: _setcursortype( _NORMALCURSOR); break; - case 1: _setcursortype( _SOLIDCURSOR); break; - } + switch (cmode) { + case -1: + _setcursortype(_NOCURSOR); + break; + case 0: + _setcursortype(_NORMALCURSOR); + break; + case 1: + _setcursortype(_SOLIDCURSOR); + break; + } } #endif @@ -174,339 +109,337 @@ static void borfcol(int color) /* set the current output color */ { - if (color < 0) - color = C_WHITE; - cfcolor = ctrans[color]; - textcolor(cfcolor & 15); + if (color < 0) + color = C_WHITE; + cfcolor = ctrans[color]; + textcolor(cfcolor & 15); } static void borbcol(int color) /* set the current background color */ { - if (color < 0) - color = C_BLACK; - cbcolor = ctrans[color]; - textbackground(cbcolor & 7); + if (color < 0) + color = C_BLACK; + cbcolor = ctrans[color]; + textbackground(cbcolor & 7); } static void borspal(const char *thePalette) /* reset the palette registers */ { - borflush(); - set_ctrans(thePalette); + borflush(); + set_ctrans(thePalette); } static void setup_colors(void) { - borfcol(gfcolor); - borbcol(gbcolor); + borfcol(gfcolor); + borbcol(gbcolor); } static void reset_colors(void) { - borfcol(7 /* not necessarily C_WHITE */); - borbcol(C_BLACK); + borfcol(7 /* not necessarily C_WHITE */ ); + borbcol(C_BLACK); } + #else -#define setup_colors() /* nothing */ -#define reset_colors() /* nothing */ +#define setup_colors() /* nothing */ +#define reset_colors() /* nothing */ #endif static void borflush(void) { - if (bufpos) { - linebuf[bufpos] = '\0'; - cputs(linebuf); - bufpos = 0; - } + if (bufpos) { + linebuf[bufpos] = '\0'; + cputs(linebuf); + bufpos = 0; + } } static void bormove(int row, int col) { - borflush(); - gotoxy(col+1, row+1); + borflush(); + gotoxy(col + 1, row + 1); } /* erase to the end of the line */ static void boreeol(void) { - borflush(); - clreol(); /* pointer to the destination line */ + borflush(); + clreol(); /* pointer to the destination line */ } /* put a character at the current position in the current colors */ static void borputc(int ch) { - linebuf[bufpos++] = ch; + linebuf[bufpos++] = ch; } - static void boreeop(void) { - int x, y, i; - struct text_info t; + int x, y, i; + struct text_info t; - borflush(); - x = wherex(); - y = wherey(); - gettextinfo(&t); + borflush(); + x = wherex(); + y = wherey(); + gettextinfo(&t); + clreol(); + for (i = x + 1; i <= t.screenheight; i++) { + gotoxy(1, i); clreol(); - for (i = x + 1; i <= t.screenheight; i++) { - gotoxy(1, i); - clreol(); - } - gotoxy(x, y); + } + gotoxy(x, y); } static void borrev(UINT reverse) /* change reverse video state */ { - borflush(); - if (reverse) { - textbackground(cfcolor & 7); - textcolor(cbcolor & 15); - } else { - textbackground(cbcolor & 7); - textcolor(cfcolor & 15); - } + borflush(); + if (reverse) { + textbackground(cfcolor & 7); + textcolor(cbcolor & 15); + } else { + textbackground(cbcolor & 7); + textcolor(cfcolor & 15); + } } static int borcres(const char *res) /* change screen resolution */ { - char *dst; - register int i; /* index */ - int status = FALSE; - - strcpy(current_res_name, res); - borflush(); - /* find the default configuration */ - if (!strcmp(res, "?")) { - status = scinit(-1); - } else { /* specify a number */ - if ((i = (int)strtol(res, &dst, 0)) >= 0 && !*dst) - { - /* only allow valid row selections */ - /* Are these all valid under dos? */ - if (i==2) status=scinit(25); - if (i==4) status=scinit(43); - if (i==5) status=scinit(50); - if (i==6) status=scinit(60); - - if (i>6 && i<28) - status=scinit(25); - - if (i>=28 && i<43) - status=scinit(28); - - if (i>=43 && i<50) - status=scinit(43); + char *dst; + register int i; /* index */ + int status = FALSE; + + strcpy(current_res_name, res); + borflush(); + /* find the default configuration */ + if (!strcmp(res, "?")) { + status = scinit(-1); + } else { /* specify a number */ + if ((i = (int) strtol(res, &dst, 0)) >= 0 && !*dst) { + /* only allow valid row selections */ + /* Are these all valid under dos? */ + if (i == 2) + status = scinit(25); + if (i == 4) + status = scinit(43); + if (i == 5) + status = scinit(50); + if (i == 6) + status = scinit(60); + + if (i > 6 && i < 28) + status = scinit(25); + + if (i >= 28 && i < 43) + status = scinit(28); - if (i>=50 && i<60) - status=scinit(50); + if (i >= 43 && i < 50) + status = scinit(43); - if (i>=60) - status=scinit(60); + if (i >= 50 && i < 60) + status = scinit(50); + + if (i >= 60) + status = scinit(60); - } } - sgarbf = TRUE; - return status; + } + sgarbf = TRUE; + return status; } - static void borbeep(void) { - putch('\a'); + putch('\a'); } - static void boropen(void) { - int i; + int i; - set_palette(initpalettestr); - setup_colors(); + set_palette(initpalettestr); + setup_colors(); - if (!borcres(current_res_name)) - (void)scinit(-1); - ttopen(); - for (i = TABLESIZE(keyseqs) - 1; i >= 0; i--) - addtosysmap(keyseqs[i].seq, 2, keyseqs[i].code); + if (!borcres(current_res_name)) + (void) scinit(-1); + ttopen(); + for (i = TABLESIZE(keyseqs) - 1; i >= 0; i--) + addtosysmap(keyseqs[i].seq, 2, keyseqs[i].code); } - static void borclose(void) { - int current_type = ibmtype; + int current_type = ibmtype; - borflush(); + borflush(); #if OPT_ICURSOR - _setcursortype(_NORMALCURSOR); + _setcursortype(_NORMALCURSOR); #endif - ibmtype = current_type; /* ...so subsequent term.open restores us */ + ibmtype = current_type; /* ...so subsequent term.open restores us */ - reset_colors(); - kbd_erase_to_end(0); - kbd_flush(); + reset_colors(); + kbd_erase_to_end(0); + kbd_flush(); } static void -borkopen(void) /* open the keyboard */ +borkopen(void) /* open the keyboard */ { - setup_colors(); - term.curmove(term.rows-1, 0); /* cf: dumbterm.c */ - term.eeol(); + setup_colors(); + term.curmove(term.rows - 1, 0); /* cf: dumbterm.c */ + term.eeol(); - /* ms_install(); */ + /* ms_install(); */ } static void -borkclose(void) /* close the keyboard */ +borkclose(void) /* close the keyboard */ { - /* ms_deinstall(); */ + /* ms_deinstall(); */ - reset_colors(); - term.curmove(term.rows-1, 0); /* cf: dumbterm.c */ - term.eeol(); + reset_colors(); + term.curmove(term.rows - 1, 0); /* cf: dumbterm.c */ + term.eeol(); } static -int borttgetc(void) +int +borttgetc(void) { - return (borlastchar = ttgetc()); + return (borlastchar = ttgetc()); } - /* bortttypahead: Check to see if any characters are already in the * keyboard buffer.In Borland C OS/2 1.5, kbhit doesn't return non-zero for * the 2nd part of an extended character, but 1st part is still 0 so use * that as indicator as well (why it's saved in borttgetc). -*/ + */ static int bortttypahead(void) { - return (kbhit() != 0 || borlastchar == 0); + return (kbhit() != 0 || borlastchar == 0); } -#if SYS_OS2 /* all modes are available under OS/2 */ +#if SYS_OS2 /* all modes are available under OS/2 */ static int -scinit(int rows) /* initialize the screen head pointers */ +scinit(int rows) /* initialize the screen head pointers */ { - /* and set up the various parameters as needed */ - - if (rows == -1) - { - struct text_info ti; - gettextinfo(&ti); - rows = ti.screenheight; - } + /* and set up the various parameters as needed */ - switch (rows) { + if (rows == -1) { + struct text_info ti; + gettextinfo(&ti); + rows = ti.screenheight; + } -/* these are enum's, and thus cannot easily be checked, ie. #ifdef C80X21 */ - case 21: /* color C80X21 */ - textmode(C80X21); - newscreensize(21, term.cols); - (void)strcpy(screen_desc, "C80X21"); - break; - - default: - case 25: /* Color graphics adapter */ - textmode(C80); - newscreensize(25, term.cols); - (void)strcpy(screen_desc, "C80"); - break; - - case 28: /* Enhanced graphics adapter */ - textmode(C80X28); - newscreensize(28, term.cols); - (void)strcpy(screen_desc, "C80X28"); - break; - - case 43: /* Enhanced graphics adapter */ - textmode(C80X43); - newscreensize(43, term.cols); - (void)strcpy(screen_desc, "C80X43"); - break; - - case 50: /* VGA adapter */ - textmode(C80X50); - newscreensize(50, term.cols); - (void)strcpy(screen_desc, "C80X50"); - break; - - case 60: /* Enhanced graphics adapter */ - textmode(C80X60); - newscreensize(60, term.cols); - (void)strcpy(screen_desc, "C80X60"); - break; + switch (rows) { + /* these are enum's, and thus cannot easily be checked, ie. #ifdef C80X21 */ + case 21: /* color C80X21 */ + textmode(C80X21); + newscreensize(21, term.cols); + (void) strcpy(screen_desc, "C80X21"); + break; + + default: + case 25: /* Color graphics adapter */ + textmode(C80); + newscreensize(25, term.cols); + (void) strcpy(screen_desc, "C80"); + break; + + case 28: /* Enhanced graphics adapter */ + textmode(C80X28); + newscreensize(28, term.cols); + (void) strcpy(screen_desc, "C80X28"); + break; + + case 43: /* Enhanced graphics adapter */ + textmode(C80X43); + newscreensize(43, term.cols); + (void) strcpy(screen_desc, "C80X43"); + break; + + case 50: /* VGA adapter */ + textmode(C80X50); + newscreensize(50, term.cols); + (void) strcpy(screen_desc, "C80X50"); + break; + + case 60: /* Enhanced graphics adapter */ + textmode(C80X60); + newscreensize(60, term.cols); + (void) strcpy(screen_desc, "C80X60"); + break; - } + } - ibmtype = rows; + ibmtype = rows; - return(TRUE); + return (TRUE); } #else /* SYS_OS2 */ static int -scinit(int rows) /* initialize the screen head pointers */ +scinit(int rows) /* initialize the screen head pointers */ { - /* and set up the various parameters as needed */ + /* and set up the various parameters as needed */ - struct text_info ti; - int oldrows; + struct text_info ti; + int oldrows; + + gettextinfo(&ti); + oldrows = ti.screenheight; + if (rows == -1) + rows = oldrows; + + switch (rows) { + + /* DOS has only BW40, C40, BW80, C80, MONO, and C4350 */ + + default: + case 25: /* Color graphics adapter */ + if (oldrows != 25) + textmode(C80); + newscreensize(25, term.cols); + (void) strcpy(screen_desc, "C80"); + break; + case 43: + case 50: + case 60: + if (rows != oldrows) + textmode(C4350); gettextinfo(&ti); - oldrows = ti.screenheight; - if (rows == -1) - rows = oldrows; - - switch (rows) { - -/* DOS has only BW40, C40, BW80, C80, MONO, and C4350 */ - - default: - case 25: /* Color graphics adapter */ - if (oldrows != 25) - textmode(C80); - newscreensize(25, term.cols); - (void)strcpy(screen_desc, "C80"); - break; - - case 43: - case 50: - case 60: - if (rows != oldrows) - textmode(C4350); - gettextinfo(&ti); - rows = ti.screenheight; - newscreensize(rows, term.cols); - sprintf(screen_desc, "C80X%d", rows); - break; + rows = ti.screenheight; + newscreensize(rows, term.cols); + sprintf(screen_desc, "C80X%d", rows); + break; - } + } - ibmtype = rows; + ibmtype = rows; - return(TRUE); + return (TRUE); } #endif /* SYS_OS2 */ @@ -520,42 +453,92 @@ /* move howmany lines starting at from to to */ static void -borscroll(int from, int to,int n) +borscroll(int from, int to, int n) { - int i; - struct text_info t; + int i; + struct text_info t; - borflush(); - if (to == from) return; + borflush(); + if (to == from) + return; #if OPT_PRETTIER_SCROLL - if (absol(from-to) > 1) { - borscroll(from, (from 1) { + borscroll(from, (from < to) ? to - 1 : to + 1, n); + if (from < to) + from = to - 1; + else + from = to + 1; + } #endif - gettextinfo(&t); - if (to < from) { - window(1, to + 1, t.screenwidth, from + n); - gotoxy(1, 1); - for (i = from - to; i > 0; i--) - delline(); - gotoxy(1, n + 1); - for (i = from - to; i > 0; i--) - insline(); - } else { - window(1, from + 1, t.screenwidth, to + n); - gotoxy(1, n + 1); - for (i = to - from; i > 0; i--) - delline(); - gotoxy(1, 1); - for (i = to - from; i > 0; i--) - insline(); - } - window(1, 1, t.screenwidth, t.screenheight); + gettextinfo(&t); + if (to < from) { + window(1, to + 1, t.screenwidth, from + n); + gotoxy(1, 1); + for (i = from - to; i > 0; i--) + delline(); + gotoxy(1, n + 1); + for (i = from - to; i > 0; i--) + insline(); + } else { + window(1, from + 1, t.screenwidth, to + n); + gotoxy(1, n + 1); + for (i = to - from; i > 0; i--) + delline(); + gotoxy(1, 1); + for (i = to - from; i > 0; i--) + insline(); + } + window(1, 1, t.screenwidth, t.screenheight); } /*--------------------------------------------------------------------------*/ - +/* + * Standard terminal interface dispatch table. Most of the fields point into + * "termio" code. + */ +TERM term = +{ + NROW, + NROW, + NCOL, + NCOL, + NPAUSE, + boropen, + borclose, + borkopen, + borkclose, + borttgetc, + borputc, + bortttypahead, + borflush, + bormove, + boreeol, + boreeop, + borbeep, + borrev, + borcres, +#if OPT_COLOR + borfcol, + borbcol, + borspal, +#else + nullterm_setfore, + nullterm_setback, + nullterm_setpal, +#endif + nullterm_setccol, + borscroll, + nullterm_pflush, +#if OPT_ICURSOR + boricursor, +#else + nullterm_icursor, +#endif + nullterm_settitle, + nullterm_watchfd, + nullterm_unwatchfd, + nullterm_cursorvis, + nullterm_mopen, + nullterm_mclose, + nullterm_mevent, +}; Index: chgdfunc.h Prereq: 1.17 --- vile-9.5b+/chgdfunc.h 2005-01-15 16:33:33.000000000 +0000 +++ vile-9.5c/chgdfunc.h 2005-11-21 00:53:26.000000000 +0000 @@ -2,7 +2,7 @@ * Prototypes for functions in the mode-tables (must be declared before the * point at which proto.h is included). * - * $Header: /usr/build/vile/vile/RCS/chgdfunc.h,v 1.17 2005/01/15 16:33:33 cmorgan Exp $ + * $Header: /usr/build/vile/vile/RCS/chgdfunc.h,v 1.18 2005/11/21 00:53:26 tom Exp $ */ extern int chgd_autobuf (CHGD_ARGS); extern int chgd_buffer (CHGD_ARGS); @@ -20,6 +20,7 @@ extern int chgd_window (CHGD_ARGS); extern int chgd_working (CHGD_ARGS); extern int chgd_xterm (CHGD_ARGS); +extern int chgd_xtermkeys(CHGD_ARGS); #if OPT_COLOR extern int chgd_color (CHGD_ARGS); Index: configure --- vile-9.5b+/configure 2005-09-05 13:51:13.000000000 +0000 +++ vile-9.5c/configure 2005-11-23 12:29:01.000000000 +0000 @@ -3748,7 +3748,7 @@ cf_extensions=no else - EXTRAOBJS="$EXTRAOBJS api.o btree.o history.o isearch.o select.o statevar.o ucrypt.o" + EXTRAOBJS="$EXTRAOBJS api.o btree.o history.o isearch.o select.o statevar.o ucrypt.o xterm.o" cf_extensions=yes fi Index: configure.in Prereq: 1.220 --- vile-9.5b+/configure.in 2005-09-04 20:10:20.000000000 +0000 +++ vile-9.5c/configure.in 2005-11-23 12:27:59.000000000 +0000 @@ -1,12 +1,12 @@ dnl Process this file with autoconf to produce a configure script. -AC_REVISION($Revision: 1.220 $) +AC_REVISION($Revision: 1.221 $) AC_PREREQ(2.13.20030927) rm -f config.cache ### Use "configure -with-screen" to override the default configuration, which is ### termcap-based on unix systems. -dnl $Header: /usr/build/vile/vile/RCS/configure.in,v 1.220 2005/09/04 20:10:20 tom Exp $ +dnl $Header: /usr/build/vile/vile/RCS/configure.in,v 1.221 2005/11/23 12:27:59 tom Exp $ define(MAKELIST, sh $srcdir/filters/makelist.sh $srcdir/filters/genmake.mak) @@ -67,7 +67,7 @@ AC_DEFINE(FEWNAMES) cf_extensions=no else - EXTRAOBJS="$EXTRAOBJS api.o btree.o history.o isearch.o select.o statevar.o ucrypt.o" + EXTRAOBJS="$EXTRAOBJS api.o btree.o history.o isearch.o select.o statevar.o ucrypt.o xterm.o" cf_extensions=yes fi Index: curses.c Prereq: 1.20 --- vile-9.5b+/curses.c 2002-12-22 19:21:27.000000000 +0000 +++ vile-9.5c/curses.c 2005-11-23 19:15:44.000000000 +0000 @@ -1,7 +1,7 @@ /* * A terminal driver using the curses library * - * $Header: /usr/build/vile/vile/RCS/curses.c,v 1.20 2002/12/22 19:21:27 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/curses.c,v 1.25 2005/11/23 19:15:44 tom Exp $ */ #include "estruct.h" @@ -17,6 +17,11 @@ #define is_default(color) (color < 0 || color == 255) +#if USE_TERMCAP +# define TCAPSLEN 1024 +static char tc_parsed[TCAPSLEN]; +#endif + #if OPT_COLOR /* ANSI: black, red, green, yellow, blue, magenta, cyan, white */ static const char ANSI_palette[] = @@ -24,91 +29,27 @@ #endif /* OPT_COLOR */ -static const struct { - char *capname; - int code; -} keyseqs[] = { - /* *INDENT-OFF* */ - /* Arrow keys */ - { CAPNAME("ku", "kcuu1"), KEY_Up }, - { CAPNAME("kd", "kcud1"), KEY_Down }, - { CAPNAME("kr", "kcuf1"), KEY_Right }, - { CAPNAME("kl", "kcub1"), KEY_Left }, - /* other cursor-movement */ - { CAPNAME("kh", "khome"), KEY_Home }, - { CAPNAME("kH", "kll"), KEY_End }, - { CAPNAME("@7", "kend"), KEY_End }, - /* page scroll */ - { CAPNAME("kN", "knp"), KEY_Next }, - { CAPNAME("kP", "kpp"), KEY_Prior }, - /* editing */ - { CAPNAME("kI", "kich1"), KEY_Insert }, - { CAPNAME("kD", "kdch1"), KEY_Delete }, - { CAPNAME("@0", "kfnd"), KEY_Find }, - { CAPNAME("*6", "kslt"), KEY_Select }, - /* command */ - { CAPNAME("%1", "khlp"), KEY_Help }, - /* function keys */ - { CAPNAME("k1", "kf1"), KEY_F1 }, - { CAPNAME("k2", "kf2"), KEY_F2 }, - { CAPNAME("k3", "kf3"), KEY_F3 }, - { CAPNAME("k4", "kf4"), KEY_F4 }, - { CAPNAME("k5", "kf5"), KEY_F5 }, - { CAPNAME("k6", "kf6"), KEY_F6 }, - { CAPNAME("k7", "kf7"), KEY_F7 }, - { CAPNAME("k8", "kf8"), KEY_F8 }, - { CAPNAME("k9", "kf9"), KEY_F9 }, - { CAPNAME("k;", "kf10"), KEY_F10 }, - { CAPNAME("F1", "kf11"), KEY_F11 }, - { CAPNAME("F2", "kf12"), KEY_F12 }, - { CAPNAME("F3", "kf13"), KEY_F13 }, - { CAPNAME("F4", "kf14"), KEY_F14 }, - { CAPNAME("F5", "kf15"), KEY_F15 }, - { CAPNAME("F6", "kf16"), KEY_F16 }, - { CAPNAME("F7", "kf17"), KEY_F17 }, - { CAPNAME("F8", "kf18"), KEY_F18 }, - { CAPNAME("F9", "kf19"), KEY_F19 }, - { CAPNAME("FA", "kf20"), KEY_F20 }, - { CAPNAME("FB", "kf21"), KEY_F21 }, - { CAPNAME("FC", "kf22"), KEY_F22 }, - { CAPNAME("FD", "kf23"), KEY_F23 }, - { CAPNAME("FE", "kf24"), KEY_F24 }, - { CAPNAME("FF", "kf25"), KEY_F25 }, - { CAPNAME("FG", "kf26"), KEY_F26 }, - { CAPNAME("FH", "kf27"), KEY_F27 }, - { CAPNAME("FI", "kf28"), KEY_F28 }, - { CAPNAME("FJ", "kf29"), KEY_F29 }, - { CAPNAME("FK", "kf30"), KEY_F30 }, - { CAPNAME("FL", "kf31"), KEY_F31 }, - { CAPNAME("FM", "kf32"), KEY_F32 }, - { CAPNAME("FN", "kf33"), KEY_F33 }, - { CAPNAME("FO", "kf34"), KEY_F34 }, - { CAPNAME("FP", "kf35"), KEY_F35 } - /* *INDENT-ON* */ - -}; - #if SYS_OS2_EMX #include "os2keys.h" #endif +static int i_am_xterm = 1; static int in_screen = FALSE; static int can_color = FALSE; +#include "xtermkeys.h" + static void initialize(void) { - size_t i; - int j; static int already_open = 0; - static char *fallback_arrows[] = - { - "\033O", /* SS3 */ - "\033[", /* CSI */ - "\217", /* SS3 */ - "\233", /* CSI */ - }; +#if USE_TERMCAP + char tc_rawdata[4096]; + char *p = tc_parsed; +#endif + unsigned i; + int j; if (already_open) return; @@ -120,6 +61,24 @@ nodelay(stdscr, TRUE); idlok(stdscr, TRUE); +#if USE_TERMCAP + if ((tgetent(tc_rawdata, getenv("TERM"))) != 1) { + fprintf(stderr, "Unknown terminal type %s!\n", getenv("TERM")); + ExitProgram(BADEXIT); + } + TRACE(("tc_rawdata used %d of %d\n", strlen(tc_rawdata), sizeof(tc_rawdata))); +#endif + +#if OPT_XTERM + { + char *t = getenv("TERM"); + I_AM_XTERM(t) + if (i_am_xterm) { + xterm_open(&term); + } + } +#endif + term.maxrows = term.rows = LINES; term.maxcols = term.cols = COLS; @@ -144,58 +103,17 @@ #endif /* - * Provide fallback definitions for all ANSI/ISO/DEC cursor keys. + * Read the termcap data now so tcap_init_fkeys() does not depend on the + * state of tgetstr() vs the buffer. */ - for (i = 0; i < TABLESIZE(fallback_arrows); i++) { - for (j = 'A'; j <= 'D'; j++) { - char temp[80]; - lsprintf(temp, "%s%c", fallback_arrows[i], j); - addtosysmap(temp, strlen(temp), SPEC | j); - } - } - -#if SYS_OS2_EMX - for (i = TABLESIZE(VIO_KeyMap); i--;) { - addtosysmap(VIO_KeyMap[i].seq, 2, VIO_KeyMap[i].code); - } + for (i = 0; i < TABLESIZE(keyseqs); ++i) { + keyseqs[i].result = TGETSTR(keyseqs[i].capname, &p); +#if USE_TERMINFO + if (NO_CAP(keyseqs[i].result)) + keyseqs[i].result = 0; #endif - for (i = TABLESIZE(keyseqs); i--;) { - char *seq = TGETSTR(keyseqs[i].capname, &p); - if (!NO_CAP(seq)) { - int len; - TRACE(("TGETSTR(%s) = %s\n", keyseqs[i].capname, str_visible(seq))); -#define DONT_MAP_DEL 1 -#if DONT_MAP_DEL - /* NetBSD, FreeBSD, etc. have the kD (delete) function key - defined as the DEL char. i don't like this hack, but - until we (and we may never) have separate system "map" - and "map!" maps, we can't allow this -- DEL has different - semantics in insert and command mode, whereas KEY_Delete - has the same semantics (whatever they may be) in both. - KEY_Delete is the only non-motion system map, by the - way -- so the rest are benign in insert or command - mode. */ - if (strcmp(seq, "\177") == 0) - continue; -#endif - addtosysmap(seq, len = strlen(seq), keyseqs[i].code); - /* - * Termcap represents nulls as octal 200, which is ambiguous - * (ugh). To avoid losing escape sequences that may contain - * nulls, check here, and add a mapping for the strings with - * explicit nulls. - */ -#define TCAP_NULL '\200' - if (strchr(seq, TCAP_NULL) != 0) { - char temp[BUFSIZ]; - (void) strcpy(temp, seq); - for (j = 0; j < len; j++) - if (char2int(temp[j]) == TCAP_NULL) - temp[j] = '\0'; - addtosysmap(temp, len, keyseqs[i].code); - } - } } + tcap_init_fkeys(); ttopen(); already_open = TRUE; @@ -268,6 +186,8 @@ curs_kopen(void) { static int initialized = FALSE; + + term.mopen(); if (!initialized) { initialized = TRUE; initialize(); @@ -281,6 +201,7 @@ curs_kclose(void) { endwin(); + term.mclose(); in_screen = FALSE; TRACE(("curs_kclose\n")); } @@ -509,6 +430,9 @@ ttwatchfd, ttunwatchfd, curs_cursor, + nullterm_mopen, + nullterm_mclose, + nullterm_mevent, }; #endif /* DISP_CURSES */ Index: display.c Prereq: 1.407 --- vile-9.5b+/display.c 2005-06-17 23:32:03.000000000 +0000 +++ vile-9.5c/display.c 2005-11-16 01:20:27.000000000 +0000 @@ -5,7 +5,7 @@ * functions use hints that are left in the windows by the commands. * * - * $Header: /usr/build/vile/vile/RCS/display.c,v 1.407 2005/06/17 23:32:03 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/display.c,v 1.409 2005/11/16 01:20:27 tom Exp $ * */ @@ -236,7 +236,7 @@ { int c; /* current char in format string */ int the_width; - int the_limit; + int the_limit = 0; int n; int islong; UINT uint_value; @@ -1634,7 +1634,7 @@ if (tbl[num].line != tbl[num].top) (void) gotoline(TRUE, tbl[num].line); (void) gocol(tbl[num].col); - wp->w_flag |= WFMOVE; + wp->w_flag |= WFMOVE | WFSBAR; copy_mvals(NUM_W_VALUES, wp->w_values.wv, tbl[num].w_vals); } curwp = savewp; @@ -3460,7 +3460,7 @@ else if (wp->w_flag & ~(WFMOVE | WFMODE)) update_all(wp); /* update all lines */ #if OPT_SCROLLBARS - if (wp->w_flag & (WFHARD | WFSBAR)) + if (wp->w_flag & (WFHARD | WFMOVE | WFSBAR)) gui_update_scrollbar(wp); #endif /* OPT_SCROLLBARS */ Index: doc/macros.doc Prereq: 1.94 --- vile-9.5b+/doc/macros.doc 2004-12-12 20:29:24.000000000 +0000 +++ vile-9.5c/doc/macros.doc 2005-11-23 16:50:27.000000000 +0000 @@ -140,12 +140,6 @@ show-commands command generates a list of all existing commands). - Note: due to vile's use of the underscore ('_') as a - command terminator, this character should _not_ be - used as a word separator within "unique-name". - Instead, use either a hyphen ('-') or mixed case - alphabetics. - help-string is an optional description of the macro. This string is displayed in the listing created by show-commands. @@ -1480,6 +1474,6 @@ ========================= end vile.rc ======================= ----------------------------------- - $Header: /usr/build/vile/vile/doc/RCS/macros.doc,v 1.94 2004/12/12 20:29:24 tom Exp $ + $Header: /usr/build/vile/vile/doc/RCS/macros.doc,v 1.95 2005/11/23 16:50:27 cmorgan Exp $ ----------------------------------- Index: dumbterm.c Prereq: 1.18 --- vile-9.5b+/dumbterm.c 2004-06-09 01:08:56.000000000 +0000 +++ vile-9.5c/dumbterm.c 2005-11-23 12:19:35.000000000 +0000 @@ -1,6 +1,6 @@ /* Dumb terminal driver, for I/O before we get into screen mode. * - * $Header: /usr/build/vile/vile/RCS/dumbterm.c,v 1.18 2004/06/09 01:08:56 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/dumbterm.c,v 1.19 2005/11/23 12:19:35 tom Exp $ * */ @@ -149,4 +149,7 @@ nullterm_watchfd, nullterm_unwatchfd, nullterm_cursorvis, + nullterm_mopen, + nullterm_mclose, + nullterm_mevent, }; Index: estruct.h Prereq: 1.584 --- vile-9.5b+/estruct.h 2005-07-09 15:49:55.000000000 +0000 +++ vile-9.5c/estruct.h 2005-11-23 13:46:16.000000000 +0000 @@ -12,7 +12,7 @@ */ /* - * $Header: /usr/build/vile/vile/RCS/estruct.h,v 1.584 2005/07/09 15:49:55 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/estruct.h,v 1.589 2005/11/23 13:46:16 tom Exp $ */ #ifndef _estruct_h @@ -532,6 +532,9 @@ ']]' and '[[' be stuttered? they must be stuttered in real vi, I prefer them not to be */ +#define OPT_VILE_ALLOC 1 /* use vile's malloc-macros */ +#define OPT_VILE_CTYPE 1 /* use vile's character-testing macros */ +#define OPT_VILE_REGEX 1 /* use vile's regular expressions */ #define OPT_W32PIPES SYS_WINNT /* Win32 pipes */ #define WINMARK 0 /* experimental */ @@ -576,7 +579,8 @@ #endif #endif -#define OPT_KEY_MODIFY (SYS_WINNT | DISP_X11) /* allow shift/ctrl/alt mods */ +/* allow shift/ctrl/alt mods */ +#define OPT_KEY_MODIFY (SYS_WINNT | DISP_X11 | DISP_TERMCAP | DISP_CURSES) /* the "working..." message -- we must have the alarm() syscall, and system calls must be restartable after an interrupt by default or be @@ -656,7 +660,7 @@ */ #define OPT_PSCREEN (XTOOLKIT) -#if DISP_TERMCAP && !SMALLER +#if (DISP_TERMCAP || DISP_CURSES) && !SMALLER /* the setting "xterm-mouse" is always available, i.e. the modetbl entry * is not conditional. but all of the code that supports xterm-mouse _is_ * ifdefed. this makes it easier for users to be able to put "set @@ -1398,122 +1402,37 @@ ? ((col) + 1) \ : ((col) + (((c) & HIGHBIT) ? 4 : 2)))) -/* these are the bits that go into the vl_chartypes_ array */ -/* the macros below test for them */ -#if OPT_WIDE_CTYPES -#define chrBIT(n) lBIT(n) -#else -#define chrBIT(n) iBIT(n) +#if OPT_VILE_ALLOC +#include #endif -typedef enum { - vl_UPPER = 0 - , vl_LOWER - , vl_DIGIT - , vl_SPACE - , vl_BSPACE - , vl_CNTRL - , vl_PRINT - , vl_PUNCT - , vl_IDENT - , vl_PATHN - , vl_WILD - , vl_LINESPEC - , vl_FENCE - , vl_NONSPACE - , vl_QIDENT -#if OPT_WIDE_CTYPES - , vl_SCRTCH - , vl_SHPIPE - , vl_XDIGIT -#endif - , vl_UNUSED -} VL_CTYPES; - -#define vl_upper chrBIT(vl_UPPER) /* upper case */ -#define vl_lower chrBIT(vl_LOWER) /* lower case */ -#define vl_digit chrBIT(vl_DIGIT) /* digits */ -#define vl_space chrBIT(vl_SPACE) /* whitespace */ -#define vl_bspace chrBIT(vl_BSPACE) /* backspace character (^H, DEL, and user's) */ -#define vl_cntrl chrBIT(vl_CNTRL) /* control characters, including DEL */ -#define vl_print chrBIT(vl_PRINT) /* printable */ -#define vl_punct chrBIT(vl_PUNCT) /* punctuation */ -#define vl_ident chrBIT(vl_IDENT) /* is typically legal in "normal" identifier */ -#define vl_pathn chrBIT(vl_PATHN) /* is typically legal in a file's pathname */ -#define vl_wild chrBIT(vl_WILD) /* is typically a shell wildcard char */ -#define vl_linespec chrBIT(vl_LINESPEC) /* ex-style line range: 1,$ or 13,15 or % etc.*/ -#define vl_fence chrBIT(vl_FENCE) /* a fence, i.e. (, ), [, ], {, } */ -#define vl_nonspace chrBIT(vl_NONSPACE) /* non-whitespace */ -#define vl_qident chrBIT(vl_QIDENT) /* is typically legal in "qualified" identifier */ +#if OPT_VILE_CTYPE +#include +#endif -#if OPT_WIDE_CTYPES -#define vl_scrtch chrBIT(vl_SCRTCH) /* legal in scratch-buffer names */ -#define vl_shpipe chrBIT(vl_SHPIPE) /* legal in shell/pipe-buffer names */ -#define vl_xdigit chrBIT(vl_XDIGIT) /* hex digit */ -#define isXDigit(c) istype(vl_xdigit, c) +#if OPT_VILE_REGEX +#define regcomp vl_regcomp +#define regexec vl_regexec +#include +#endif +#if OPT_WIDE_CTYPES #define SCREEN_STRING (vl_pathn|vl_scrtch|vl_shpipe) -typedef ULONG CHARTYPE; #else #define SCREEN_STRING (vl_pathn) -typedef USHORT CHARTYPE; #endif #define screen_to_bname(buf) screen_string(buf,sizeof(buf),(CHARTYPE)SCREEN_STRING) -/* these parallel the ctypes.h definitions, except that - they force the char to valid range first */ -#define CharOf(c) ((unsigned char)(c)) -#define vlCTYPE(c) vl_chartypes_[CharOf(c)] -#define istype(m,c) ((vlCTYPE(c) & (m)) != 0) - -#define isAlnum(c) istype(vl_lower|vl_upper|vl_digit, c) -#define isAlpha(c) istype(vl_lower|vl_upper, c) -#define isCntrl(c) istype(vl_cntrl, c) -#define isDigit(c) istype(vl_digit, c) -#define isLower(c) istype(vl_lower, c) -#define isPrint(c) istype(vl_print, c) -#define isPunct(c) istype(vl_punct, c) -#define isSpace(c) istype(vl_space, c) -#define isUpper(c) istype(vl_upper, c) - -#define isbackspace(c) (istype(vl_bspace, c) || (c) == backspc) -#define isfence(c) istype(vl_fence, c) -#define isident(c) istype(vl_ident, c) -#define isqident(c) istype(vl_qident, c) -#define islinespecchar(c) istype(vl_linespec, c) -#define ispath(c) istype(vl_pathn, c) -#define iswild(c) istype(vl_wild, c) - #define KEY_Space ' ' #define KEY_Tab '\t' -/* macro for cases where return & newline are equivalent */ -#define isreturn(c) ((c == '\r') || (c == '\n')) - -/* macro for whitespace (non-return) */ -#define isBlank(c) ((c == '\t') || (c == ' ')) - #if OPT_KEY_MODIFY #define isBackTab(c) ((c) == KEY_BackTab || (((c) & mod_SHIFT) != 0 && CharOf(c) == KEY_Tab)) #else #define isBackTab(c) ((c) == KEY_BackTab) #endif -#define isGraph(c) (!isSpecial(c) && !isSpace(c) && isPrint(c)) - -/* DIFCASE represents the difference between upper - and lower case letters, DIFCNTRL the difference between upper case and - control characters. They are xor-able values. */ -#define DIFCASE 0x20 -#define DIFCNTRL 0x40 -#define toUpper(c) vl_uppercase[CharOf(c)] -#define toLower(c) vl_lowercase[CharOf(c)] -#define tocntrl(c) (((unsigned)(c))^DIFCNTRL) -#define toalpha(c) (((unsigned)(c))^DIFCNTRL) - -#define nocase_eq(bc,pc) (CharOf(bc) == CharOf(pc) || (toUpper(bc) == toUpper(pc))) - #define ESC tocntrl('[') #define BEL tocntrl('G') /* ascii bell character */ #define CONTROL_A tocntrl('A') /* for cntl_a attribute sequences */ @@ -1528,41 +1447,6 @@ #define ABORTED(c) ((c) == esc_c || (c) == intrc || interrupted()) /* - * Definitions etc. for regexp(3) routines. - * - * the regexp code is: - * Copyright (c) 1986 by University of Toronto. - * Written by Henry Spencer. Not derived from licensed software. - * - */ -#define NSUBEXP 10 -typedef struct regexp { - char *startp[NSUBEXP]; - char *endp[NSUBEXP]; - size_t mlen; /* convenience: endp[0] - startp[0] */ - int regstart; /* Internal use only. */ - char reganch; /* Internal use only. */ - int regmust; /* Internal use only. */ - unsigned regmlen; /* Internal use only. */ - size_t size; /* vile addition -- how big is this */ - char program[1]; /* Unwarranted chumminess with compiler. */ -} regexp; - -/* - * The first byte of the regexp internal "program" is actually this magic - * number; the start node begins in the second byte. - */ -#define REGEXP_MAGIC 0234 - -#ifndef CHARBITS -#define UCHAR_AT(p) ((int)*(UCHAR *)(p)) -#else -#define UCHAR_AT(p) ((int)*(p)&CHARBITS) -#endif - -/* end of regexp stuff */ - -/* * Data for read/write/etc, hooks */ typedef struct { @@ -2489,6 +2373,10 @@ void (*unwatchfd)(int, long); /* Don't watch file descriptor */ void (*cursorvis)(int flag); /* hide/show cursor */ + /* mouse interface, e.g., for xterm and clones */ + void (*mopen) (void); /* mouse open */ + void (*mclose) (void); /* mouse close */ + void (*mevent) (void); /* mouse event */ } TERM; @@ -2830,20 +2718,6 @@ #define TYPECAST(type,ptr) (type*)(ptr) #endif -/* structure-allocate, for appeasing strict compilers */ -#define castalloc(cast,nbytes) (cast *)malloc(nbytes) -#define castrealloc(cast,ptr,nbytes) (cast *)realloc((ptr),(nbytes)) -#define typecalloc(cast) (cast *)calloc(sizeof(cast),1) -#define typecallocn(cast,ntypes) (cast *)calloc(sizeof(cast),ntypes) -#define typealloc(cast) (cast *)malloc(sizeof(cast)) -#define typeallocn(cast,ntypes) (cast *)malloc((ntypes)*sizeof(cast)) -#define typereallocn(cast,ptr,ntypes) (cast *)realloc((ptr),\ - (ntypes)*sizeof(cast)) -#define typeallocplus(cast,extra) (cast *)calloc((extra)+sizeof(cast),1) - -#define FreeAndNull(p) if ((p) != 0) { free(p); p = 0; } -#define FreeIfNeeded(p) if ((p) != 0) free(p) - #if defined(VILE_ERROR_ABORT) extern void ExitProgram(int code); #endif Index: exec.c Prereq: 1.280 --- vile-9.5b+/exec.c 2005-09-22 22:05:19.000000000 +0000 +++ vile-9.5c/exec.c 2005-11-23 21:20:59.000000000 +0000 @@ -4,7 +4,7 @@ * original by Daniel Lawrence, but * much modified since then. assign no blame to him. -pgf * - * $Header: /usr/build/vile/vile/RCS/exec.c,v 1.280 2005/09/22 22:05:19 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/exec.c,v 1.281 2005/11/23 21:20:59 tom Exp $ * */ @@ -859,14 +859,7 @@ TRACE((T_CALLED "execute(execfunc=%p(%s:%s), f=%d, n=%d)\n", execfunc, - (execfunc->c_flags & CMD_PERL - ? "perl" - : (execfunc->c_flags & CMD_PROC - ? "proc" - : "func")), - (execfunc->c_name - ? execfunc->c_name - : "?"), + TRACE_CMDFUNC(execfunc), f, n)); flags = execfunc->c_flags; Index: file.c Prereq: 1.386 --- vile-9.5b+/file.c 2005-09-22 23:19:30.000000000 +0000 +++ vile-9.5c/file.c 2005-11-15 22:32:22.000000000 +0000 @@ -5,7 +5,7 @@ * reading and writing of the disk are * in "fileio.c". * - * $Header: /usr/build/vile/vile/RCS/file.c,v 1.386 2005/09/22 23:19:30 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/file.c,v 1.388 2005/11/15 22:32:22 tom Exp $ */ #include "estruct.h" @@ -435,6 +435,7 @@ TRACE(("fileuid_get(%s) discarding cache\n", fname)); (void) file_stat(fname, 0); + memset(fuid, 0, sizeof(*fuid)); if (file_stat(fname, &sb) == 0) { fuid->ino = sb.st_ino; fuid->dev = sb.st_dev; @@ -1086,7 +1087,7 @@ { double total = (doslines + unixlines) * b_val(bp, VAL_PERCENT_CRLF); double value = (doslines * 100); - return (value >= total); + return (total != 0) && (value >= total); } /* Index: filters/filters.rc Prereq: 1.202 --- vile-9.5b+/filters/filters.rc 2005-05-10 23:19:13.000000000 +0000 +++ vile-9.5c/filters/filters.rc 2005-11-15 23:06:55.000000000 +0000 @@ -1,4 +1,4 @@ -; $Id: filters.rc,v 1.202 2005/05/10 23:19:13 tom Exp $ +; $Id: filters.rc,v 1.203 2005/11/15 23:06:55 tom Exp $ ; majormodes in this file are ordered alphabetically for convenience - the ; precedence used by vile is strictly alphabetic, counting case. @@ -21,6 +21,12 @@ filtername 'vile-sh-filt -k csh' ~endwith +; using txt filter will highlight quoted strings +define-mode csv +~with define-submode csv + filtername 'vile-txt-filt' +~endwith + define-mode java ~with define-submode java filtername 'vile-c-filt -j -p -k java' Index: filters/rubyfilt.c Prereq: 1.38 --- vile-9.5b+/filters/rubyfilt.c 2005-05-14 12:38:54.000000000 +0000 +++ vile-9.5c/filters/rubyfilt.c 2005-10-08 22:49:03.000000000 +0000 @@ -1,5 +1,5 @@ /* - * $Header: /usr/build/vile/vile/filters/RCS/rubyfilt.c,v 1.38 2005/05/14 12:38:54 tom Exp $ + * $Header: /usr/build/vile/vile/filters/RCS/rubyfilt.c,v 1.39 2005/10/08 22:49:03 tom Exp $ * * Filter to add vile "attribution" sequences to ruby scripts. This is a * translation into C of an earlier version written for LEX/FLEX. @@ -638,7 +638,7 @@ OPS("~"), }; - if (ispunct(*s)) { + if (ispunct(CharOf(*s))) { unsigned n; for (n = 0; n < TABLESIZE(table); ++n) { if (ATLEAST(s, table[n].len) Index: filters/sed-filt.c Prereq: 1.20 --- vile-9.5b+/filters/sed-filt.c 2004-12-10 00:39:11.000000000 +0000 +++ vile-9.5c/filters/sed-filt.c 2005-11-16 20:55:12.000000000 +0000 @@ -1,5 +1,5 @@ /* - * $Header: /usr/build/vile/vile/filters/RCS/sed-filt.c,v 1.20 2004/12/10 00:39:11 tom Exp $ + * $Header: /usr/build/vile/vile/filters/RCS/sed-filt.c,v 1.21 2005/11/16 20:55:12 tom Exp $ * * Filter to add vile "attribution" sequences to sed scripts. */ @@ -261,7 +261,7 @@ static char *line; char *s; - int addresses; + int addresses = 0; int escaped_newline; States state = LeadingBlanks; Index: macros/modes.rc Prereq: 1.28 --- vile-9.5b+/macros/modes.rc 2005-09-05 00:41:00.000000000 +0000 +++ vile-9.5c/macros/modes.rc 2005-11-15 23:05:18.000000000 +0000 @@ -1,4 +1,4 @@ -; $Id: modes.rc,v 1.28 2005/09/05 00:41:00 tom Exp $ +; $Id: modes.rc,v 1.31 2005/11/15 23:05:18 tom Exp $ ; majormodes in this file are ordered alphabetically for convenience - the ; precedence used by vile is strictly alphabetic, counting case. Use the ; before and after qualifiers to override the precedence. @@ -167,6 +167,14 @@ ignorecase ~endwith +; disable wrapping in ".csv" files +define-mode csv +~with define-submode csv + suffixes '\.\(csv\)$' + fillcol=0 + wrapmargin=0 +~endwith + define-mode cweb ~with define-submode cweb suffixes '\.\(w\|web\)$' @@ -602,7 +610,7 @@ define-mode sh ~with define-submode sh mode-filename '^[a-z-]*profile$' - suffixes '\(\.\(sh\|ksh\|shar\|.*rc\)$\|\.bash_[a-z]\+$\)' + suffixes '\(\.\(sh\|ksh\|shar\|.*rc\|bash_[a-z]\+\|ebuild\)$\)' pre '^\(\(#!\s*\/.*sh\>\(\s*[-]\+[\a]*\s*\)\?\)\|:\)\s*$' comment-prefix '^\s*[:#]' comments '^\s*[:#]\s*$' @@ -806,7 +814,7 @@ mode-filename '^\(\.Xdefaults\(-.\+$\)\?\)$' suffixes '\.\(ad\)$' ~if ¬ $filename-ic - mode-pathname '\(app-defaults/[A-Z]\?[A-Z][a-z0-9-]\+\)$' + mode-pathname '\(app-defaults/[A-Z][A-Z0-9]*\([a-z0-9-][A-Z]\?\.\?\)\+\)$' ~endif comment-prefix '^\s*!' comments '^\s*!\s*$' Index: macros/vileinit.rc Prereq: 1.25 --- vile-9.5b+/macros/vileinit.rc 2005-03-11 01:43:31.000000000 +0000 +++ vile-9.5c/macros/vileinit.rc 2005-11-23 21:56:35.000000000 +0000 @@ -1,4 +1,4 @@ -; $Header: /usr/build/vile/vile/macros/RCS/vileinit.rc,v 1.25 2005/03/11 01:43:31 tom Exp $ +; $Header: /usr/build/vile/vile/macros/RCS/vileinit.rc,v 1.32 2005/11/23 21:56:35 tom Exp $ ; This is a sample which may be installed as .vilerc (or vile.rc for non-Unix ; systems), or source'd as-is to provide quick initialization of some useful ; macros and settings. @@ -55,33 +55,67 @@ setv $xshell-flags="" ~elseif &seq $progname winvile ~elseif &or &sin $cfgopts "terminfo" \ - &sin $cfgopts "termcap" + &or &sin $cfgopts "termcap" \ + &sin $cfgopts "curses" set xterm-mouse + set xterm-fkeys ; If your keyboard is setup to transmit META as an escape character, ; these mappings are useful for undo/redo/kill map u u map r r map k k + ; Shifted arrow-keys from XFree86 xterm, mapped to next-row and ; previous-row. They are available when the sunKeyboard resource - ; is false. Old flavor (see modifyCursorKeys in manpage): - map   - map O2A  - map   - map O2B  - map  #C - map O2C #C - map  #D - map O2D #D - ; These are the newer flavor: - map   - map   - map  #C - map  #D - ; You may have a back-tab (map it to previous-window) + ; is false, i.e., the "VT220 Keyboard" menu option is not checked. + ~if &sin &env 'TERM' 'xterm' + ; These are the newer flavor: + ;map   + ;map   + ;map  #C + ;map  #D + ~elseif &or \ + &sin &env 'TERM' 'konsole' \ + &sin &env 'TERM' 'gnome' + ; GNOME or KDE (unclear because the developers do not give + ; credit except in the vaguest possible terms) copied the + ; bindings for xterm-94, and then one copied from the other. + ; However, this is the old, deprecated flavor, before xterm + ; patch #167 (see modifyCursorKeys in the xterm manpage): + map   + map O2A  + map   + map O2B  + map  #C + map O2C #C + map  #D + map O2D #D + ~elseif &sin &env 'TERM' 'rxvt' + map   + map   + map  #C + map  #D + ~endif + ; You may have a back-tab (map it to previous-window). This is fairly + ; standard since it is adapted from the control sequence with the same + ; name. map  O + ; + ; If "xterm-fkeys" is enabled, it alters the input decoding so that + ; function keys can have shift/control/alt modifiers. That means it + ; may override the map commands for the shifted cursor keys: + bind-key previous-row Shift+#A + bind-key next-row Shift+#B + bind-key right-arrow Shift+#C + bind-key left-arrow Shift+#D + ; ...and the alt-keys: + bind-key undo-changes-backward M-u + bind-key redo-changes-forward M-r + bind-key kill-buffer M-k + ; ...and of course back-tab: + bind-key previous-window #b ~endif ; Useful macros for function keys: Index: macros/vilemenu.rc Prereq: 1.2 --- vile-9.5b+/macros/vilemenu.rc 1999-12-17 22:34:05.000000000 +0000 +++ vile-9.5c/macros/vilemenu.rc 2005-11-16 21:03:11.000000000 +0000 @@ -1,4 +1,4 @@ -; $Header: /usr/build/vile/vile/macros/RCS/vilemenu.rc,v 1.2 1999/12/17 22:34:05 tom Exp $ +; $Header: /usr/build/vile/vile/macros/RCS/vilemenu.rc,v 1.3 2005/11/16 21:03:11 tom Exp $ ; A sample .vilemenu file: C:Xvile @@ -42,12 +42,12 @@ B:12x24:setv $font 12x24 ; C:Nice Fonts -B:10pt:setv $font "-*-lucidatypewriter-*-r-normal-sans-10-*-*-*-*-0-iso8859-1" -B:12pt:setv $font "-*-lucidatypewriter-*-r-normal-sans-12-*-*-*-*-0-iso8859-1" -B:14pt:setv $font "-*-lucidatypewriter-*-r-normal-sans-14-*-*-*-*-0-iso8859-1" -B:16pt:setv $font "-*-lucidatypewriter-*-r-normal-sans-16-*-*-*-*-0-iso8859-1" -B:18pt:setv $font "-*-lucidatypewriter-*-r-normal-sans-18-*-*-*-*-0-iso8859-1" -B:20pt:setv $font "-*-lucidatypewriter-*-r-normal-sans-20-*-*-*-*-0-iso8859-1" +B:10pt:setv $font "-*-lucidatypewriter-medium-r-normal-sans-10-*-*-*-*-*-iso8859-1" +B:12pt:setv $font "-*-lucidatypewriter-medium-r-normal-sans-12-*-*-*-*-*-iso8859-1" +B:14pt:setv $font "-*-lucidatypewriter-medium-r-normal-sans-14-*-*-*-*-*-iso8859-1" +B:17pt:setv $font "-*-lucidatypewriter-medium-r-normal-sans-17-*-*-*-*-*-iso8859-1" +B:18pt:setv $font "-*-lucidatypewriter-medium-r-normal-sans-18-*-*-*-*-*-iso8859-1" +B:20pt:setv $font "-*-lucidatypewriter-medium-r-normal-sans-20-*-*-*-*-*-iso8859-1" ; C:Help:help B:About:version Index: main.c Prereq: 1.540 --- vile-9.5b+/main.c 2005-07-11 22:25:32.000000000 +0000 +++ vile-9.5c/main.c 2005-11-23 23:03:36.000000000 +0000 @@ -22,7 +22,7 @@ */ /* - * $Header: /usr/build/vile/vile/RCS/main.c,v 1.540 2005/07/11 22:25:32 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/main.c,v 1.545 2005/11/23 23:03:36 tom Exp $ */ #define realdef /* Make global definitions not external */ @@ -262,6 +262,17 @@ #endif /* + * Do not try to pipe results (vile has no ex-mode, which would be used + * in this case). + */ +#if DISP_TERMCAP || DISP_CURSES || DISP_ANSI + if (!isatty(fileno(stdout))) { + fprintf(stderr, "vile: ex mode is not implemented\n"); + ExitProgram(BADEXIT); + } +#endif + + /* * Allow for I/O to the command-line before we initialize the screen * driver. * @@ -461,7 +472,7 @@ #if !SYS_WINNT #if !DISP_X11 #if SYS_UNIX - char *tty = "/dev/tty"; + char *tty = 0; #else FILE *in; int fd; @@ -478,20 +489,34 @@ ffp = fdopen(dup(fileno(stdin)), "r"); #if !DISP_X11 # if SYS_UNIX -# if defined(HAVE_TTYNAME) && !defined(HAVE_DEV_TTY) - tty = ttyname(fileno(stderr)); +# if defined(HAVE_TTYNAME) + if (isatty(fileno(stdout))) + tty = ttyname(fileno(stdout)); + if (tty == 0 && isatty(fileno(stderr))) + tty = ttyname(fileno(stderr)); +# endif +# if defined(HAVE_DEV_TTY) + if (tty == 0) + tty = "/dev/tty"; # endif + if (tty == 0) { + fprintf(stderr, "cannot open any terminal\n"); + tidy_exit(BADEXIT); + } /* * Note: On Linux, the low-level close/dup operation * doesn't work, since something hangs, apparently * because substituting the file descriptor doesn't communicate * properly up to the stdio routines. */ + TRACE(("call freopen(%s) for stdin\n", tty)); if ((freopen(tty, "r", stdin)) == 0 || !isatty(fileno(stdin))) { + TRACE(("...failed to reopen stdin\n")); fprintf(stderr, "cannot open a terminal (%s)\n", tty); tidy_exit(BADEXIT); } + TRACE(("...successfully reopened stdin\n")); #else # if SYS_WINNT # if DISP_NTCONS @@ -523,8 +548,9 @@ if ((fd >= 0) && (close(0) >= 0) && (fd = dup(fd)) == 0 - && (in = fdopen(fd, "r")) != 0) - *stdin = *in; + && (in = fdopen(fd, "r")) != 0) { + *stdin = *in; /* FIXME: won't work on opaque FILE's */ + } # endif /* SYS_WINNT */ # endif /* SYS_UNIX */ #endif /* DISP_X11 */ @@ -536,9 +562,11 @@ set_b_val(bp, MDCRYPT, TRUE); } #endif - (void) slowreadf(bp, &nline); - set_rdonly(bp, bp->b_fname, MDREADONLY); - (void) ffclose(); + if (ffp != 0) { + (void) slowreadf(bp, &nline); + set_rdonly(bp, bp->b_fname, MDREADONLY); + (void) ffclose(); + } if (is_empty_buf(bp)) { (void) zotbuf(bp); @@ -1156,6 +1184,9 @@ #ifdef GMDWORKING setINT(GMDWORKING, TRUE); /* we put up "working..." */ #endif +#ifdef GMDXTERM_FKEYS + setINT(GMDXTERM_FKEYS, FALSE); /* function-key modifiers */ +#endif #ifdef GMDXTERM_MOUSE setINT(GMDXTERM_MOUSE, FALSE); /* mouse-clicking */ #endif Index: makefile.in Prereq: 1.195 --- vile-9.5b+/makefile.in 2005-03-10 20:01:53.000000000 +0000 +++ vile-9.5c/makefile.in 2005-11-23 12:28:27.000000000 +0000 @@ -20,7 +20,7 @@ # # gnu autoconf support by kevin buettner, 5/94 # -# $Header: /usr/build/vile/vile/RCS/makefile.in,v 1.195 2005/03/10 20:01:53 tom Exp $ +# $Header: /usr/build/vile/vile/RCS/makefile.in,v 1.196 2005/11/23 12:28:27 tom Exp $ SHELL = /bin/sh @@ -234,7 +234,7 @@ modes.c msgs.c npopen.c oneliner.c opers.c path.c random.c \ regexp.c region.c search.c select.c spawn.c statevar.c tags.c \ tbuff.c termio.c ucrypt.c undo.c version.c \ - watch.c window.c word.c wordmov.c + watch.c window.c word.c wordmov.c xterm.c ALLSRC = $(VILESRC) $(SCREENS) $(OTHERSRC) $(HDRS) @@ -274,6 +274,7 @@ # spawn.o # statevar.o # ucrypt.o +# xterm.o OBJ = $(SCREEN)$o \ main$o basic$o bind$o buffer$o csrch$o \ display$o dumbterm$o eval$o exec$o externs$o fences$o file$o \ Index: map.c Prereq: 1.104 --- vile-9.5b+/map.c 2005-02-09 22:42:57.000000000 +0000 +++ vile-9.5c/map.c 2005-11-23 01:33:46.000000000 +0000 @@ -3,7 +3,7 @@ * Original interface by Otto Lind, 6/3/93 * Additional map and map! support by Kevin Buettner, 9/17/94 * - * $Header: /usr/build/vile/vile/RCS/map.c,v 1.104 2005/02/09 22:42:57 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/map.c,v 1.108 2005/11/23 01:33:46 tom Exp $ * */ @@ -269,33 +269,33 @@ } static int -delfrommap(struct maprec **mpp, const char *ks) +delfrommap(struct maprec **mpp, const char *ks, int length) { struct maprec **save_m = mpp; struct maprec ***mstk = 0; - const char *save_k = ks; int depth = 0; int pass; + int n; - if (ks == 0 || *ks == 0) + if (ks == 0 || length == 0) return FALSE; for (pass = 0; pass < 2; pass++) { mpp = save_m; - ks = save_k; depth = 0; - while (*mpp && *ks) { + n = 0; + while (*mpp && n < length) { if (pass) mstk[depth] = mpp; - if ((*mpp)->ch == char2int(*ks)) { + if ((*mpp)->ch == char2int(ks[n])) { mpp = &(*mpp)->dlink; - ks++; + n++; depth++; } else mpp = &(*mpp)->flink; } - if (*ks) + if (n < length) return FALSE; /* not in map */ if (!pass) { mstk = typecallocn(struct maprec **, depth + 1); @@ -477,13 +477,29 @@ return matchedcnt; } +static void +reverse_abbr(struct maprec **mpp, const char *bufname, TBUFF *kbuf) +{ + if ((*mpp && *mpp == abbr_map) || (strcmp(bufname, ABBR_BufName) == 0)) { + /* reverse the lhs */ + int i; + char t; + int len = tb_length(kbuf) - 1; + char *s = tb_values(kbuf); + for (i = 0; i < len / 2; i++) { + t = s[len - i - 1]; + s[len - i - 1] = s[i]; + s[i] = t; + } + } +} + static int map_common(struct maprec **mpp, const char *bufname, UINT remapflag) { int status; static TBUFF *kbuf; static TBUFF *val; - int len; #if OPT_SHOW_MAPS if (end_named_cmd()) { @@ -508,20 +524,9 @@ if (status != TRUE) return status; - len = tb_length(kbuf) - 1; - if ((*mpp && *mpp == abbr_map) || (strcmp(bufname, ABBR_BufName) == 0)) { - /* reverse the lhs */ - int i; - char t; - char *s = tb_values(kbuf); - for (i = 0; i < len / 2; i++) { - t = s[len - i - 1]; - s[len - i - 1] = s[i]; - s[i] = t; - } - } + reverse_abbr(mpp, bufname, kbuf); - status = addtomap(mpp, tb_values(kbuf), len, + status = addtomap(mpp, tb_values(kbuf), tb_length(kbuf) - 1, MAPF_USERTIMER | remapflag, -1, tb_values(val)); relist_mappings(bufname); return status; @@ -544,20 +549,9 @@ if (status != TRUE) return status; - if ((*mpp && *mpp == abbr_map) || (strcmp(bufname, ABBR_BufName) == 0)) { - /* reverse the lhs */ - int i; - char t; - int len = tb_length(kbuf) - 1; - char *s = tb_values(kbuf); - for (i = 0; i < len / 2; i++) { - t = s[len - i - 1]; - s[len - i - 1] = s[i]; - s[i] = t; - } - } + reverse_abbr(mpp, bufname, kbuf); - if (delfrommap(mpp, tb_values(kbuf)) != TRUE) { + if (delfrommap(mpp, tb_values(kbuf), tb_length(kbuf) - 1) != TRUE) { mlforce("[Sequence not mapped]"); return FALSE; } @@ -649,6 +643,14 @@ addtosysmap(const char *seq, int seqlen, int code) { addtomap(&map_syskey, seq, seqlen, MAPF_SYSTIMER, code, (char *) 0); + relist_mappings(SYSMAP_BufName); +} + +void +delfromsysmap(const char *seq, int seqlen) +{ + delfrommap(&map_syskey, seq, seqlen); + relist_mappings(SYSMAP_BufName); } #define INPUT_FROM_TTGET 1 Index: menu.c Prereq: 1.46 --- vile-9.5b+/menu.c 2005-05-20 23:01:32.000000000 +0000 +++ vile-9.5c/menu.c 2005-11-18 01:30:37.000000000 +0000 @@ -8,7 +8,7 @@ /************************************************************************/ /* - * $Header: /usr/build/vile/vile/RCS/menu.c,v 1.46 2005/05/20 23:01:32 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/menu.c,v 1.48 2005/11/18 01:30:37 tom Exp $ */ /* Vile includes */ @@ -103,7 +103,11 @@ _exit(0); /* abandon exec'ing process */ } else if (pid == 0) { newprocessgroup(FALSE, 1); - execl(path, "xvile", "-display", x_get_display_name(), NULL, 0); + execl(path, + "xvile", + "-display", + x_get_display_name(), + (void *) 0); _exit(errno); /* just in case exec-failed */ } } Index: modes.c Prereq: 1.307 --- vile-9.5b+/modes.c 2005-06-03 00:43:27.000000000 +0000 +++ vile-9.5c/modes.c 2005-11-23 13:42:42.000000000 +0000 @@ -7,7 +7,7 @@ * Major extensions for vile by Paul Fox, 1991 * Majormode extensions for vile by T.E.Dickey, 1997 * - * $Header: /usr/build/vile/vile/RCS/modes.c,v 1.307 2005/06/03 00:43:27 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/modes.c,v 1.311 2005/11/23 13:42:42 tom Exp $ * */ @@ -2070,7 +2070,7 @@ int chgd_xterm(BUFFER *bp GCC_UNUSED, VALARGS * args GCC_UNUSED, - int glob_vals, + int glob_vals GCC_UNUSED, int testing GCC_UNUSED) { #if OPT_XTERM @@ -2086,6 +2086,22 @@ return TRUE; } + /* Change the xterm-fkeys mode */ +/*ARGSUSED*/ +int +chgd_xtermkeys(BUFFER *bp GCC_UNUSED, + VALARGS * args GCC_UNUSED, + int glob_vals GCC_UNUSED, + int testing GCC_UNUSED) +{ +#if DISP_TERMCAP || DISP_CURSES + if (glob_vals && !testing) { + tcap_init_fkeys(); + } +#endif + return TRUE; +} + /* Change the mouse mode */ #ifdef GMDMOUSE /*ARGSUSED*/ @@ -3001,6 +3017,7 @@ /* prompt the user and get an answer */ tb_scopy(&cbuf, ""); + *result = 0; while ((status = kbd_reply("submode: ", &cbuf, eol_history, '=', Index: modetbl Prereq: 1.235 --- vile-9.5b+/modetbl 2005-05-30 22:49:48.000000000 +0000 +++ vile-9.5c/modetbl 2005-11-21 00:53:37.000000000 +0000 @@ -11,7 +11,7 @@ # # The modes are table entries in the BUFFER and WINDOW structures. # -# $Header: /usr/build/vile/vile/RCS/modetbl,v 1.235 2005/05/30 22:49:48 tom Exp $ +# $Header: /usr/build/vile/vile/RCS/modetbl,v 1.237 2005/11/21 00:53:37 tom Exp $ # # # Mode-table entries. Capitalized letters are used for abbreviations. @@ -56,6 +56,7 @@ "warn-unread" WARNUNREAD 0 # warn if quitting with unread buffers "warn-reread" WARNREREAD 0 # warn before rereading a buffer "warn-rename" WARNRENAME 0 # warn before renaming a buffer + "xterm-fkeys" XTERM_FKEYS chgd_xtermkeys # mode to control whether we recognize xterm's function-key modifiers "xterm-mouse" XTERM_MOUSE chgd_xterm # mode to control whether we allow mouse-clicking "xterm-title" XTERM_TITLE chgd_swaptitle OPT_TITLE # mode to control whether we allow xterm title updates "SmoothScroll" SMOOTH_SCROLL 0 # should we update even if there is typeahead? Index: npopen.c Prereq: 1.92 --- vile-9.5b+/npopen.c 2005-01-23 00:59:40.000000000 +0000 +++ vile-9.5c/npopen.c 2005-11-18 01:30:37.000000000 +0000 @@ -1,7 +1,7 @@ /* npopen: like popen, but grabs stderr, too * written by John Hutchinson, heavily modified by Paul Fox * - * $Header: /usr/build/vile/vile/RCS/npopen.c,v 1.92 2005/01/23 00:59:40 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/npopen.c,v 1.94 2005/11/18 01:30:37 tom Exp $ * */ @@ -213,9 +213,9 @@ if (cmd[i] == '/') cmd[i] = '\\'; #endif - (void) execlp(sh, shname, SHELL_C, cmd, 0); + (void) execlp(sh, shname, SHELL_C, cmd, (void *) 0); } else { - (void) execlp(sh, shname, 0); + (void) execlp(sh, shname, (void *) 0); } (void) write(2, "exec failed\r\n", 14); exit(-1); Index: ntconio.c Prereq: 1.83 --- vile-9.5b+/ntconio.c 2005-10-02 21:47:00.000000000 +0000 +++ vile-9.5c/ntconio.c 2005-11-23 12:19:35.000000000 +0000 @@ -1,7 +1,7 @@ /* * Uses the Win32 console API. * - * $Header: /usr/build/vile/vile/RCS/ntconio.c,v 1.83 2005/10/02 21:47:00 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/ntconio.c,v 1.84 2005/11/23 12:19:35 tom Exp $ * */ @@ -1516,4 +1516,7 @@ nullterm_watchfd, nullterm_unwatchfd, nullterm_cursorvis, + nullterm_mopen, + nullterm_mclose, + nullterm_mevent, }; Index: ntwinio.c Prereq: 1.149 --- vile-9.5b+/ntwinio.c 2005-10-02 21:47:00.000000000 +0000 +++ vile-9.5c/ntwinio.c 2005-11-23 12:19:35.000000000 +0000 @@ -1,7 +1,7 @@ /* * Uses the Win32 screen API. * - * $Header: /usr/build/vile/vile/RCS/ntwinio.c,v 1.149 2005/10/02 21:47:00 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/ntwinio.c,v 1.150 2005/11/23 12:19:35 tom Exp $ * Written by T.E.Dickey for vile (october 1997). * -- improvements by Clark Morgan (see w32cbrd.c, w32pipe.c). */ @@ -4222,4 +4222,7 @@ nullterm_watchfd, nullterm_unwatchfd, nullterm_cursorvis, + nullterm_mopen, + nullterm_mclose, + nullterm_mevent, }; Index: os2vio.c Prereq: 1.32 --- vile-9.5b+/os2vio.c 2005-10-02 23:13:25.000000000 +0000 +++ vile-9.5c/os2vio.c 2005-11-23 12:19:35.000000000 +0000 @@ -3,7 +3,7 @@ * Modified from a really old version of "borland.c" (before the VIO * stuff went in there.) * - * $Header: /usr/build/vile/vile/RCS/os2vio.c,v 1.32 2005/10/02 23:13:25 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/os2vio.c,v 1.33 2005/11/23 12:19:35 tom Exp $ */ #include "estruct.h" @@ -611,6 +611,9 @@ nullterm_watchfd, nullterm_unwatchfd, nullterm_cursorvis, + nullterm_mopen, + nullterm_mclose, + nullterm_mevent, }; #endif /* DISP_VIO */ Index: patchlev.h --- vile-9.5b+/patchlev.h 2005-09-22 22:09:07.000000000 +0000 +++ vile-9.5c/patchlev.h 2005-11-15 21:41:13.000000000 +0000 @@ -1,3 +1,3 @@ #define VILE_VERSION "9.5" /* set to "" for no patches */ -#define VILE_PATCHLEVEL "b" +#define VILE_PATCHLEVEL "c" Index: proto.h Prereq: 1.553 --- vile-9.5b+/proto.h 2005-09-22 22:05:19.000000000 +0000 +++ vile-9.5c/proto.h 2005-11-23 13:18:25.000000000 +0000 @@ -4,7 +4,7 @@ * * Created: Thu May 14 15:44:40 1992 * - * $Header: /usr/build/vile/vile/RCS/proto.h,v 1.553 2005/09/22 22:05:19 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/proto.h,v 1.559 2005/11/23 13:18:25 tom Exp $ * */ @@ -34,6 +34,7 @@ extern void not_interrupted (void); extern void setup_handler (int sig, void (*disp) (int ACTUAL_SIG_ARGS)); extern void tidy_exit (int code); +extern void tcap_init_fkeys(void); extern void tcap_setup_locale(char *real_locale, char *fake_locale); #ifndef interrupted @@ -67,10 +68,16 @@ #endif /* screen-drivers */ +#if OPT_XTERM +extern void xterm_open (TERM *); +extern void xterm_mopen (void); +extern void xterm_mclose (void); +extern void xterm_settitle (const char *t); #if OPT_XTERM >= 3 extern int xterm_mouse_t (int f, int n); extern int xterm_mouse_T (int f, int n); #endif +#endif #if OPT_PERL /* perl.xs (perl.c) */ @@ -710,6 +717,7 @@ extern int sysmapped_c_avail (void); extern void abbr_check (int *backsp_limit_p); extern void addtosysmap (const char *seq, int seqlen, int code); +extern void delfromsysmap (const char *seq, int seqlen); extern void mapungetc (int c); /* menu.c */ @@ -962,11 +970,7 @@ #endif /* regexp.c */ -#define regcomp vl_regcomp -#define regexec vl_regexec #define lregexec vl_lregexec -extern regexp * regcomp (const char *origexp, size_t exp_len, int magic); -extern int regexec (regexp *prog, char *string, char *stringend, int startoff, int endoff); extern int lregexec (regexp *prog, LINE *lp, int startoff, int endoff); /* region.c */ @@ -1006,7 +1010,6 @@ extern int readpattern (const char *prompt, TBUFF **apat, regexp **srchexpp, int c, int fromscreen); extern int scanner (regexp *exp, int direct, int wrapok, int *wrappedp); extern void attrib_matches (void); -extern void regerror (const char *s); extern void scanboundry (int wrapok, MARK dot, int dir); #if OPT_HILITEMATCH @@ -1129,16 +1132,28 @@ /* termio.c */ extern OUTC_DCL ttputc (OUTC_ARGS); -extern int nullterm_setdescrip (const char *res); -extern int nullterm_watchfd (int fd, WATCHTYPE type, long *idp); extern int open_terminal (TERM *termp); extern int ttgetc (void); extern int tttypahead (void); -extern int ttwatchfd (int fd, WATCHTYPE type, long *idp); +extern int ttwatchfd (int fd, WATCHTYPE type, long *idp); +extern void ttclean (int f); +extern void ttclose (void); +extern void ttflush (void); +extern void ttopen (void); +extern void ttunclean (void); +extern void ttunwatchfd (int fd, long id); +extern void vl_save_tty (void); +extern void vl_restore_tty (void); + +extern int nullterm_setdescrip (const char *res); +extern int nullterm_watchfd (int fd, WATCHTYPE type, long *idp); extern void nullterm_cursorvis (int flag); extern void nullterm_icursor (int c); extern void nullterm_kclose (void); extern void nullterm_kopen (void); +extern void nullterm_mclose (void); +extern void nullterm_mevent (void); +extern void nullterm_mopen (void); extern void nullterm_pflush (void); extern void nullterm_scroll (int f, int t, int n); extern void nullterm_setback (int b); @@ -1147,14 +1162,6 @@ extern void nullterm_setpal (const char *p); extern void nullterm_settitle (const char *t); extern void nullterm_unwatchfd (int fd, long id); -extern void ttclean (int f); -extern void ttclose (void); -extern void ttflush (void); -extern void ttopen (void); -extern void ttunclean (void); -extern void ttunwatchfd (int fd, long id); -extern void vl_save_tty (void); -extern void vl_restore_tty (void); /* ucrypt.c */ #if OPT_ENCRYPT Index: regexp.c Prereq: 1.110 --- vile-9.5b+/regexp.c 2005-01-17 00:54:28.000000000 +0000 +++ vile-9.5c/regexp.c 2005-11-20 20:10:04.000000000 +0000 @@ -1,4 +1,34 @@ /* + * $Header: /usr/build/vile/vile/RCS/regexp.c,v 1.116 2005/11/20 20:10:04 tom Exp $ + * + * Copyright 2005, Thomas E. Dickey and Paul G. Fox + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, distribute with modifications, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name(s) of the above copyright + * holders shall not be used in advertising or otherwise to promote the + * sale, use or other dealings in this Software without prior written + * authorization. + * + * ---------------------------------------------------------------------------- + * * This code has been MODIFIED for use in vile (see the original * copyright information down below) -- in particular: * - regexec no longer needs to scan a null terminated string @@ -23,9 +53,6 @@ * - add test-driver * * ted, 05/03 - * - * $Header: /usr/build/vile/vile/RCS/regexp.c,v 1.110 2005/01/17 00:54:28 tom Exp $ - * */ /* @@ -53,49 +80,64 @@ * regular-expression syntax might require a total rethink. */ -#include "estruct.h" - #ifdef DEBUG_REGEXP -#define realdef /* Make global definitions not external */ +#define UNBUNDLED_VILE_REGEX #endif -#ifdef DEBUG_REGEXP +#ifdef UNBUNDLED_VILE_REGEX -# include +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include + +#define OPT_VILE_CTYPE 0 /* use macros but not data */ + +#include +#include +#include + +#else + +#include + +#endif + +#if OPT_VILE_CTYPE +#include /* use global data from vile */ +#endif + +#if !defined(OPT_WORKING) || defined(DEBUG_REGEXP) # undef beginDisplay # define beginDisplay() /* nothing */ # undef endofDisplay # define endofDisplay() /* nothing */ +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef NO_LEAKS +#define NO_LEAKS 0 +#endif -# undef istype -# undef isAlnum -# undef isAlpha -# undef isCntrl -# undef isDigit -# undef isLower -# undef isPrint -# undef isPunct -# undef isSpace -# undef isUpper -# undef toUpper -# undef toLower -# undef isident -# undef isXDigit - -# define isAlnum(c) isalnum(c) -# define isAlpha(c) isalpha(c) -# define isCntrl(c) iscntrl(c) -# define isDigit(c) isdigit(c) -# define isLower(c) islower(c) -# define isPrint(c) isprint(c) -# define isPunct(c) ispunct(c) -# define isSpace(c) isspace(c) -# define isUpper(c) isupper(c) -# define toUpper(c) toupper(c) -# define toLower(c) tolower(c) -# define isident(c) isalnum(c) -# define isXDigit(c) isxdigit(c) +#ifndef OPT_TRACE +#define OPT_TRACE 0 +#endif + +#ifndef TRACE +#define TRACE(p) /* nothing */ +#endif + +#ifdef DEBUG_REGEXP /* #define OPT_TRACE 1 */ /* #define REGDEBUG 1 */ @@ -107,8 +149,6 @@ # endif #endif -#include "edef.h" - #if OPT_TRACE /* #define REGDEBUG 1 */ #endif @@ -123,6 +163,10 @@ #undef min #undef max +#if !OPT_VILE_CTYPE +int ignorecase = FALSE; +#endif + static char *reg(int paren, int *flagp); static char *regatom(int *flagp, int at_bop); static char *regbranch(int *flagp); @@ -245,9 +289,9 @@ #define is_BLANK(c) (isSpace(c) && !isreturn(c)) #define is_CNTRL(c) isCntrl(c) #define is_DIGIT(c) isDigit(c) -#define is_GRAPH(c) isPrint(c) +#define is_GRAPH(c) isGraph(c) #define is_LOWER(c) isLower(c) -#define is_PRINT(c) (isPrint(c) || isSpace(c)) +#define is_PRINT(c) (isPrint(c) || (isSpace(c) && !isCntrl(c))) #define is_PUNCT(c) isPunct(c) #define is_SPACE(c) isSpace(c) #define is_UPPER(c) isUpper(c) @@ -401,7 +445,11 @@ size_t *out_size, int magic) { - const char *metas = magic ? MAGICMETA : NOMAGICMETA; + const char *metas = ((magic > 0) + ? MAGICMETA + : (magic < 0) + ? "<>" + : NOMAGICMETA); char *nxt = out_text; size_t n; @@ -921,7 +969,7 @@ /* *INDENT-ON* */ unsigned n; - for (n = 0; n < TABLESIZE(char_classes); n++) { + for (n = 0; n < sizeof(char_classes) / sizeof(char_classes[0]); n++) { unsigned len = strlen(char_classes[n].name); if (!strncmp(*src, char_classes[n].name, len)) { *src += len; @@ -1369,7 +1417,7 @@ /* Find last node. */ scan = p; - for_ever { + for (;;) { temp = regnext(scan); if (temp == NULL) break; @@ -2543,6 +2591,7 @@ } #endif +#if defined(llength) && defined(lforw) && defined(lback) /* vile support: * like regexec, but takes LINE * as input instead of char * */ @@ -2578,10 +2627,9 @@ return s; } } +#endif /* VILE LINE */ #ifdef DEBUG_REGEXP -int ignorecase = FALSE; - void mlforce(const char *dummy,...) { @@ -2719,10 +2767,14 @@ /* * Read script containing patterns (p), test-data (q) and results (r). The - * first character of each line is its type. Comments begin with '#'. Use an - * uppercase p/q/r to suppress backslash interpretation of the line, e.g., to - * simplify typing patterns. Lines beginning with '?' are error messages. - * Other lines are converted to comments. + * first character of each line is its type: + * > Comments begin with '#'. + * > Use an uppercase p/q/r to suppress backslash interpretation of the line, + * e.g., to simplify typing patterns. + * > Use M/m to switch magic on/off in the call to regcomp(). + * > Use N to disable regmassage (used for vile), so expressions are POSIX. + * > Lines beginning with '?' are error messages. + * > Other lines are converted to comments. * * The output of the test driver contains the comment lines, p- and q-lines as * well as the computed r-lines. Because special characters are encoded as @@ -2733,6 +2785,7 @@ test_regexp(FILE *fp) { char *s; + int magic = TRUE; int linenum = 0; int literal; int subexp; @@ -2743,6 +2796,18 @@ while ((s = get_string(fp, &length, ++linenum)) != 0) { literal = 0; switch (*s) { + case 'N': + magic = -1; + put_string(s, length, TRUE); + break; + case 'M': + magic = 1; + put_string(s, length, TRUE); + break; + case 'm': + magic = 0; + put_string(s, length, TRUE); + break; case 'P': literal = 1; /* FALLTHRU */ @@ -2752,7 +2817,7 @@ if (pattern != 0) free(pattern); ++s, --length; - pattern = regcomp(s, length, TRUE); + pattern = regcomp(s, length, magic); break; case 'Q': literal = 1; Index: revlist --- vile-9.5b+/revlist 2005-10-03 00:21:01.000000000 +0000 +++ vile-9.5c/revlist 2005-11-24 01:47:20.000000000 +0000 @@ -1,6 +1,6 @@ -revlist for vile, version v9_5b +revlist for vile, version v9_5c -------------------------------------------------------------------------------- -CHANGES 1.867 +CHANGES 1.877 CHANGES.R3 1.1 CHANGES.R4 1.1 CHANGES.R5 1.1 @@ -14,39 +14,39 @@ README.PC 1.32 README.VMS 1.5 aclocal.m4 1.158 -ansi.c 1.45 +ansi.c 1.46 api.c 1.37 api.h 1.13 -basic.c 1.122 -bind.c 1.286 -borland.c 1.32 +basic.c 1.123 +bind.c 1.290 +borland.c 1.33 btree.c 1.21 btree.h 1.4 buffer.c 1.296 buglist 1.402 builtflt.c 1.47 -chgdfunc.h 1.17 +chgdfunc.h 1.18 cmdtbl 1.238 config.emx 1.2 config.guess 1.2 config.sub 1.2 config_h.in 1.2 -configure 1.2 -configure.in 1.220 +configure 1.3 +configure.in 1.221 csrch.c 1.32 -curses.c 1.20 +curses.c 1.25 descrip.mms 1.46 dirstuff.h 1.30 -display.c 1.407 +display.c 1.409 djhandl.c 1.6 -dumbterm.c 1.18 +dumbterm.c 1.19 edef.h 1.320 -estruct.h 1.584 +estruct.h 1.589 eval.c 1.348 -exec.c 1.280 +exec.c 1.281 externs.c 1.10 fences.c 1.83 -file.c 1.386 +file.c 1.388 filec.c 1.121 fileio.c 1.179 finderr.c 1.130 @@ -54,7 +54,6 @@ globals.c 1.48 gppconio.c 1.2 history.c 1.82 -ibmpc.c 1.97 input.c 1.284 insert.c 1.143 install.sh 1.7 @@ -62,66 +61,69 @@ itbuff.c 1.25 lckfiles.c 1.11 line.c 1.170 -main.c 1.540 +main.c 1.545 makefile.blc 1.18 makefile.djg 1.32 makefile.emx 1.5 makefile.icc 1.14 -makefile.in 1.195 +makefile.in 1.196 makefile.tbc 1.24 makefile.wat 1.26 makefile.wnt 1.85 -map.c 1.104 -menu.c 1.46 +map.c 1.108 +menu.c 1.48 mkdirs.sh 1.6 mkprlenv.wnt 1.8 mktbls.c 1.132 -modes.c 1.307 -modetbl 1.235 +modes.c 1.311 +modetbl 1.237 msgs.c 1.26 -npopen.c 1.92 -ntconio.c 1.83 -ntwinio.c 1.149 +npopen.c 1.94 +ntconio.c 1.84 +ntwinio.c 1.150 oneliner.c 1.108 opers.c 1.90 os2keys.h 1.2 os2pipe.c 1.5 -os2vio.c 1.32 -patchlev.h 1.338 +os2vio.c 1.33 +patchlev.h 1.339 path.c 1.150 perl.xs 1.104 plugin.c 1.1 plugin.h 1.1 -proto.h 1.553 +proto.h 1.559 pscreen.h 1.2 ptypemap 1.7 random.c 1.287 -regexp.c 1.110 +regexp.c 1.116 region.c 1.132 -revlist v9_5b +revlist v9_5c search.c 1.137 select.c 1.158 sinstall.sh 1.1 -spawn.c 1.185 +spawn.c 1.187 statevar.c 1.94 tags.c 1.128 tbuff.c 1.63 -tcap.c 1.158 -tcap.h 1.9 -termio.c 1.200 +tcap.c 1.168 +tcap.h 1.10 +termio.c 1.201 trace.c 1.53 -trace.h 1.23 +trace.h 1.24 ucrypt.c 1.15 undo.c 1.88 version.c 1.57 vile-9.5.spec 1.3 vile.1 1.30 -vile.hlp 1.602 +vile.hlp 1.603 vile.wmconfig 1.1 +vl_alloc.h 1.1 +vl_ctype.h 1.2 +vl_regex.h 1.3 vms2unix.c 1.42 vmsbuild.com 1.44 vmspipe.c 1.14 -vmsvt.c 1.57 +vmsvt.c 1.58 w32cbrd.c 1.25 w32cmd.c 1.35 w32misc.c 1.45 @@ -141,15 +143,17 @@ word.c 1.79 wordmov.c 1.22 wvwrap.cpp 1.9 -x11.c 1.280 +x11.c 1.281 x11menu.c 1.8 xshell.sh 1.4 +xterm.c 1.2 +xtermkeys.h 1.6 xvile.wmconfig 1.1 doc/Vileserv.doc 1.1 doc/config.doc 1.14 doc/dir.doc 1.3 doc/filters.doc 1.35 -doc/macros.doc 1.94 +doc/macros.doc 1.95 doc/menus.doc 1.7 doc/modes.doc 1.16 doc/ncu-indent 1.12 @@ -204,7 +208,7 @@ filters/filterio.c 1.28 filters/filters.c 1.99 filters/filters.h 1.94 -filters/filters.rc 1.202 +filters/filters.rc 1.203 filters/flt_defs.h 1.1 filters/fltstack.h 1.9 filters/genmake.c 1.4 @@ -279,10 +283,10 @@ filters/rexxfilt.l 1.8 filters/rpm-filt.l 1.11 filters/rpm.key 1.3 -filters/rubyfilt.c 1.38 +filters/rubyfilt.c 1.39 filters/sccs.key 1.1 filters/sccsfilt.l 1.12 -filters/sed-filt.c 1.20 +filters/sed-filt.c 1.21 filters/sh-filt.l 1.64 filters/sh.key 1.4 filters/sml-filt.l 1.5 @@ -340,15 +344,15 @@ macros/gnugpg.rc 1.3 macros/loaderrs.rc 1.1 macros/manpage.rc 1.21 -macros/modes.rc 1.28 +macros/modes.rc 1.31 macros/palettes.rc 1.7 macros/pictmode.rc 1.4 macros/search.rc 1.3 macros/shifts.rc 1.4 macros/showeach.rc 1.5 macros/vile-pager 1.5 -macros/vileinit.rc 1.25 -macros/vilemenu.rc 1.2 +macros/vileinit.rc 1.32 +macros/vilemenu.rc 1.3 macros/vileperl.rc 1.7 macros/which.rc 1.14 package/winvile.iss 1.5 Index: spawn.c Prereq: 1.185 --- vile-9.5b+/spawn.c 2005-07-17 18:00:44.000000000 +0000 +++ vile-9.5c/spawn.c 2005-11-23 17:15:24.000000000 +0000 @@ -1,7 +1,7 @@ /* Spawn: various DOS access commands * for MicroEMACS * - * $Header: /usr/build/vile/vile/RCS/spawn.c,v 1.185 2005/07/17 18:00:44 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/spawn.c,v 1.187 2005/11/23 17:15:24 tom Exp $ * */ @@ -248,8 +248,10 @@ rtfrmshell(int ACTUAL_SIG_ARGS GCC_UNUSED) { #if USE_UNIX_JOB_CTL + TRACE(("entering rtfrmshell...\n")); endofDisplay(); kbd_openup(); + term.kopen(); ttunclean(); sgarbf = TRUE; setup_handler(SIGCONT, rtfrmshell); /* suspend & restart */ Index: tcap.c Prereq: 1.158 --- vile-9.5b+/tcap.c 2005-07-13 22:13:00.000000000 +0000 +++ vile-9.5c/tcap.c 2005-11-23 19:15:30.000000000 +0000 @@ -1,7 +1,7 @@ /* tcap: Unix V5, V7 and BS4.2 Termcap video driver * for MicroEMACS * - * $Header: /usr/build/vile/vile/RCS/tcap.c,v 1.158 2005/07/13 22:13:00 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/tcap.c,v 1.168 2005/11/23 19:15:30 tom Exp $ * */ @@ -24,8 +24,8 @@ #define WINDOW vile_WINDOW #if USE_TERMCAP -# define TCAPSLEN 768 -static char tcapbuf[TCAPSLEN]; +# define TCAPSLEN 1024 +static char tc_parsed[TCAPSLEN]; #endif static char *tc_CM, *tc_CE, *tc_CL, *tc_ME, *tc_MR, *tc_SO, *tc_SE; @@ -102,69 +102,6 @@ static int shown_fcolor = NO_COLOR; static int shown_bcolor = NO_COLOR; #endif /* OPT_COLOR */ -/* *INDENT-OFF* */ -static const struct { - char * capname; - int code; -} keyseqs[] = { - /* Arrow keys */ - { CAPNAME("ku","kcuu1"), KEY_Up }, /* up */ - { CAPNAME("kd","kcud1"), KEY_Down }, /* down */ - { CAPNAME("kr","kcuf1"), KEY_Right }, /* right */ - { CAPNAME("kl","kcub1"), KEY_Left }, /* left */ - /* other cursor-movement */ - { CAPNAME("kh","khome"), KEY_Home }, /* home */ - { CAPNAME("kH","kll"), KEY_End }, /* end (variant) */ - { CAPNAME("@7","kend"), KEY_End }, /* end */ - { CAPNAME("kB","kcbt"), KEY_BackTab }, /* back-tab */ - /* page scroll */ - { CAPNAME("kN","knp"), KEY_Next }, /* next page */ - { CAPNAME("kP","kpp"), KEY_Prior }, /* previous page */ - /* editing */ - { CAPNAME("kI","kich1"), KEY_Insert }, /* Insert */ - { CAPNAME("kD","kdch1"), KEY_Delete }, /* Delete */ - { CAPNAME("@0","kfnd"), KEY_Find }, /* Find */ - { CAPNAME("*6","kslt"), KEY_Select }, /* Select */ - /* command */ - { CAPNAME("%1","khlp"), KEY_Help }, /* Help */ - /* function keys */ - { CAPNAME("k1","kf1"), KEY_F1 }, /* F1 */ - { CAPNAME("k2","kf2"), KEY_F2 }, - { CAPNAME("k3","kf3"), KEY_F3 }, - { CAPNAME("k4","kf4"), KEY_F4 }, - { CAPNAME("k5","kf5"), KEY_F5 }, - { CAPNAME("k6","kf6"), KEY_F6 }, - { CAPNAME("k7","kf7"), KEY_F7 }, - { CAPNAME("k8","kf8"), KEY_F8 }, - { CAPNAME("k9","kf9"), KEY_F9 }, - { CAPNAME("k;","kf10"), KEY_F10 }, /* F10 */ - { CAPNAME("F1","kf11"), KEY_F11 }, /* F11 */ - { CAPNAME("F2","kf12"), KEY_F12 }, /* F12 */ - { CAPNAME("F3","kf13"), KEY_F13 }, /* F13 */ - { CAPNAME("F4","kf14"), KEY_F14 }, - { CAPNAME("F5","kf15"), KEY_F15 }, - { CAPNAME("F6","kf16"), KEY_F16 }, - { CAPNAME("F7","kf17"), KEY_F17 }, - { CAPNAME("F8","kf18"), KEY_F18 }, - { CAPNAME("F9","kf19"), KEY_F19 }, /* F19 */ - { CAPNAME("FA","kf20"), KEY_F20 }, /* F20 */ - { CAPNAME("FB","kf21"), KEY_F21 }, - { CAPNAME("FC","kf22"), KEY_F22 }, - { CAPNAME("FD","kf23"), KEY_F23 }, - { CAPNAME("FE","kf24"), KEY_F24 }, - { CAPNAME("FF","kf25"), KEY_F25 }, - { CAPNAME("FG","kf26"), KEY_F26 }, - { CAPNAME("FH","kf27"), KEY_F27 }, - { CAPNAME("FI","kf28"), KEY_F28 }, - { CAPNAME("FJ","kf29"), KEY_F29 }, - { CAPNAME("FK","kf30"), KEY_F30 }, - { CAPNAME("FL","kf31"), KEY_F31 }, - { CAPNAME("FM","kf32"), KEY_F32 }, - { CAPNAME("FN","kf33"), KEY_F33 }, - { CAPNAME("FO","kf34"), KEY_F34 }, - { CAPNAME("FP","kf35"), KEY_F35 } -}; -/* *INDENT-ON* */ #if SYS_OS2_EMX #include "os2keys.h" @@ -197,23 +134,9 @@ static void tcap_rev(UINT state); #endif -#define XtermPos() ((unsigned)(keystroke() - 040)) - -#if OPT_XTERM >= 3 -# define XTERM_ENABLE_TRACKING "\033[?1001h" /* mouse hilite tracking */ -# define XTERM_DISABLE_TRACKING "\033[?1001l" -#else -# if OPT_XTERM >= 2 -# define XTERM_ENABLE_TRACKING "\033[?1000h" /* normal tracking mode */ -# define XTERM_DISABLE_TRACKING "\033[?1000l" -# else -# define XTERM_ENABLE_TRACKING "\033[?9h" /* X10 compatibility mode */ -# define XTERM_DISABLE_TRACKING "\033[?9l" -# endif -#endif - static int i_am_xterm; -static int x_origin = 1, y_origin = 1; + +#include "xtermkeys.h" #ifdef HAVE_TPARM /* usually terminfo */ #define CALL_TPARM(cap,code) tparm(cap, code,0,0,0,0,0,0,0,0) @@ -225,9 +148,8 @@ tcap_open(void) { #if USE_TERMCAP - char tcbuf[2048]; - char err_str[72]; - char *p = tcapbuf; + char tc_rawdata[4096]; + char *p = tc_parsed; #endif char *t; char *tv_stype; @@ -279,14 +201,6 @@ ,{ CAPNAME("vi","civis"), &tc_VI } /* make cursor invisible */ /* FIXME: do xmc/ug */ }; - - static char * fallback_arrows[] = { -/* "\033", ** VT52 (type-ahead checks make this not useful) */ - "\033O", /* SS3 */ - "\033[", /* CSI */ - "\217", /* SS3 */ - "\233", /* CSI */ - }; /* *INDENT-ON* */ TRACE((T_CALLED "tcap_open()\n")); @@ -300,11 +214,11 @@ #if USE_TERMINFO setupterm(tv_stype, fileno(stdout), (int *) 0); #else - if ((tgetent(tcbuf, tv_stype)) != 1) { - (void) lsprintf(err_str, "Unknown terminal type %s!", tv_stype); - puts(err_str); + if ((tgetent(tc_rawdata, tv_stype)) != 1) { + fprintf(stderr, "Unknown terminal type %s!\n", tv_stype); ExitProgram(BADEXIT); } + TRACE(("tc_rawdata used %d of %d\n", strlen(tc_rawdata), sizeof(tc_rawdata))); #endif #if OPT_LOCALE @@ -335,40 +249,19 @@ #endif /* are we probably an xterm? */ +#if OPT_XTERM i_am_xterm = FALSE; - if (!strncmp(tv_stype, "xterm", sizeof("xterm") - 1) - || !strncmp(tv_stype, "rxvt", sizeof("rxvt") - 1)) { - i_am_xterm = TRUE; - } else if ((t = TGETSTR(CAPNAME("Km", "kmous"), &p)) != 0 - && (t != (char *) (-1)) - && !strcmp(t, "\033[M")) { - i_am_xterm = TRUE; - } else if (TGETFLAG(CAPNAME("XT", "XT")) > 0) { /* screen */ - i_am_xterm = TRUE; - } -#if USE_TERMCAP - else { - p = tcbuf; - while (*p && *p != ':') { - if (*p == 'x' - && strncmp(p, "xterm", sizeof("xterm") - 1) == 0) { - i_am_xterm = TRUE; - break; - } - p++; - } - } -#endif - if (i_am_xterm) { - x_origin = 0; - y_origin = 0; + I_AM_XTERM(tv_stype) + if (i_am_xterm) { + xterm_open(&term); } +#endif /* OPT_XTERM */ term.maxrows = term.rows; term.maxcols = term.cols; #if USE_TERMCAP - p = tcapbuf; + p = tc_parsed; #endif for (i = 0; i < TABLESIZE(tc_strings); i++) { /* allow aliases */ @@ -463,69 +356,21 @@ #endif /* - * Provide fallback definitions for all ANSI/ISO/DEC cursor keys. + * Read the termcap data now so tcap_init_fkeys() does not depend on the + * state of tgetstr() vs the buffer. */ - for (i = 0; i < TABLESIZE(fallback_arrows); i++) { - for (j = 'A'; j <= 'D'; j++) { - char temp[80]; - lsprintf(temp, "%s%c", fallback_arrows[i], j); - addtosysmap(temp, strlen(temp), SPEC | j); - } - } - -#if SYS_OS2_EMX - for (i = TABLESIZE(VIO_KeyMap); i--;) { - addtosysmap(VIO_KeyMap[i].seq, 2, VIO_KeyMap[i].code); - } + for (i = 0; i < TABLESIZE(keyseqs); ++i) { + keyseqs[i].result = TGETSTR(keyseqs[i].capname, &p); +#if USE_TERMINFO + if (NO_CAP(keyseqs[i].result)) + keyseqs[i].result = 0; #endif - for (i = TABLESIZE(keyseqs); i--;) { - char *seq = TGETSTR(keyseqs[i].capname, &p); - if (!NO_CAP(seq)) { - int len; - TRACE(("TGETSTR(%s) = %s\n", keyseqs[i].capname, str_visible(seq))); -#define DONT_MAP_DEL 1 -#if DONT_MAP_DEL - /* NetBSD, FreeBSD, etc. have the kD (delete) function key - defined as the DEL char. i don't like this hack, but - until we (and we may never) have separate system "map" - and "map!" maps, we can't allow this -- DEL has different - semantics in insert and command mode, whereas KEY_Delete - has the same semantics (whatever they may be) in both. - KEY_Delete is the only non-motion system map, by the - way -- so the rest are benign in insert or command - mode. */ - if (strcmp(seq, "\177") == 0) - continue; -#endif - addtosysmap(seq, len = strlen(seq), keyseqs[i].code); - /* - * Termcap represents nulls as octal 200, which is ambiguous - * (ugh). To avoid losing escape sequences that may contain - * nulls, check here, and add a mapping for the strings with - * explicit nulls. - */ -#define TCAP_NULL '\200' - if (strchr(seq, TCAP_NULL) != 0) { - char temp[BUFSIZ]; - (void) strcpy(temp, seq); - for (j = 0; j < len; j++) - if (char2int(temp[j]) == TCAP_NULL) - temp[j] = '\0'; - addtosysmap(temp, len, keyseqs[i].code); - } - } } -#if OPT_XTERM - addtosysmap("\033[M", 3, KEY_Mouse); -#if OPT_XTERM >= 3 - addtosysmap("\033[t", 3, KEY_text); - addtosysmap("\033[T", 3, KEY_textInvalid); -#endif -#endif + tcap_init_fkeys(); #if USE_TERMCAP - TRACE(("tcapbuf used %d of %d\n", p - tcapbuf, sizeof(tcapbuf))); - if (p >= &tcapbuf[sizeof(tcapbuf)]) { + TRACE(("tc_parsed used %d of %d\n", p - tc_parsed, sizeof(tc_parsed))); + if (p >= &tc_parsed[sizeof(tc_parsed)]) { puts("Terminal description too big!\n"); ExitProgram(BADEXIT); } @@ -571,10 +416,7 @@ tcap_kopen(void) { TRACE((T_CALLED "tcap_kopen()\n")); -#if OPT_XTERM - if (i_am_xterm && global_g_val(GMDXTERM_MOUSE)) - putpad(XTERM_ENABLE_TRACKING); -#endif + term.mopen(); if (!keyboard_open) { keyboard_open = TRUE; if (tc_TI) { @@ -592,10 +434,7 @@ tcap_kclose(void) { TRACE((T_CALLED "tcap_kclose()\n")); -#if OPT_XTERM - if (i_am_xterm && global_g_val(GMDXTERM_MOUSE)) - putpad(XTERM_DISABLE_TRACKING); -#endif + term.mclose(); if (keyboard_open) { keyboard_open = FALSE; if (tc_TE) @@ -1281,226 +1120,6 @@ return ch; } -#if OPT_XTERM -/* Finish decoding a mouse-click in an xterm, after the ESC and '[' chars. - * - * There are 3 mutually-exclusive xterm mouse-modes (selected here by values of - * OPT_XTERM): - * (1) X10-compatibility (not used here) - * Button-press events are received. - * (2) normal-tracking - * Button-press and button-release events are received. - * Button-events have modifiers (e.g., shift, control, meta). - * (3) hilite-tracking - * Button-press and text-location events are received. - * Button-events have modifiers (e.g., shift, control, meta). - * Dragging with the mouse produces highlighting. - * The text-locations are checked by xterm to ensure validity. - * - * NOTE: - * The hilite-tracking code is here for testing and (later) use. Because - * we cannot guarantee that we always are decoding escape-sequences when - * reading from the terminal, there is the potential for the xterm hanging - * when a mouse-dragging operation is begun: it waits for us to specify - * the screen locations that limit the highlighting. - * - * While highlighting, the xterm accepts other characters, but the display - * does not appear to be refreshed until highlighting is ended. So (even - * if we always capture the beginning of highlighting) we cannot simply - * loop here waiting for the end of highlighting. - * - * 1993/aug/6 dickey@software.org - */ - -static int xterm_button(int c); - -/*ARGSUSED*/ -int -mouse_motion(int f GCC_UNUSED, int n GCC_UNUSED) -{ - return xterm_button('M'); -} - -#if OPT_XTERM >= 3 -/*ARGSUSED*/ -int -xterm_mouse_t(int f, int n) -{ - return xterm_button('t'); -} - -/*ARGSUSED*/ -int -xterm_mouse_T(int f, int n) -{ - return xterm_button('T'); -} -#endif /* OPT_XTERM >= 3 */ - -static int -xterm_button(int c) -{ - int event; - int button; - int x; - int y; - int status; -#if OPT_XTERM >= 3 - WINDOW *wp; - int save_row = ttrow; - int save_col = ttcol; - int firstrow, lastrow; - int startx, endx, mousex; - int starty, endy, mousey; - MARK save_dot; - char temp[NSTRING]; - static const char *fmt = "\033[%d;%d;%d;%d;%dT"; -#endif /* OPT_XTERM >= 3 */ - - if ((status = (global_g_val(GMDXTERM_MOUSE))) != 0) { - beginDisplay(); - switch (c) { -#if OPT_XTERM < 3 - /* - * If we get a click on a modeline, clear the current selection, - * if any. Allow implied movement of the mouse (distance between - * pressing and releasing a mouse button) to drag the modeline. - * - * Likewise, if we get a click _not_ on a modeline, make that - * start/extend a selection. - */ - case 'M': /* button-event */ - event = keystroke(); - x = XtermPos() + x_origin - 1; - y = XtermPos() + y_origin - 1; - button = (event & 3) + 1; - - if (button > 3) - button = 0; - TRACE(("MOUSE-button event %d -> btn %d loc %d.%d\n", - event, button, y, x)); - status = on_mouse_click(button, y, x); - break; -#else /* OPT_XTERM >=3, highlighting mode */ - case 'M': /* button-event */ - event = keystroke(); - x = XtermPos() + x_origin; - y = XtermPos() + y_origin; - - button = (event & 3) + 1; - TRACE(("MOUSE-button event:%d x:%d y:%d\n", event, x, y)); - if (button > 3) { - endofDisplay(); - return TRUE; /* button up */ - } - wp = row2window(y - 1); - if (insertmode && wp != curwp) { - kbd_alarm(); - return ABORT; - } - /* Tell the xterm how to highlight the selection. - * It won't do anything else until we do this. - */ - if (wp != 0) { - firstrow = wp->w_toprow + 1; - lastrow = mode_row(wp) + 1; - } else { /* from message-line */ - firstrow = term.rows; - lastrow = term.rows + 1; - } - if (y >= lastrow) /* don't select modeline */ - y = lastrow - 1; - (void) lsprintf(temp, fmt, 1, x, y, firstrow, lastrow); - putpad(temp); - term.flush(); - /* Set the dot-location if button 1 was pressed in a - * window. - */ - if (wp != 0 - && button == 1 - && !reading_msg_line - && setcursor(y - 1, x - 1)) { - (void) update(TRUE); - status = TRUE; - } else if (button <= 3) { - /* abort the selection */ - (void) lsprintf(temp, fmt, 0, x, y, firstrow, lastrow); - putpad(temp); - term.flush(); - status = ABORT; - } else { - status = FALSE; - } - break; - case 't': /* reports valid text-location */ - x = XtermPos(); - y = XtermPos(); - - TRACE(("MOUSE-valid: x:%d y:%d\n", x, y)); - setwmark(y - 1, x - 1); - yankregion(); - - movecursor(save_row, save_col); - (void) update(TRUE); - break; - case 'T': /* reports invalid text-location */ - /* - * The starting-location returned is not the location - * at which the mouse was pressed. Instead, it is the - * top-most location of the selection. In turn, the - * ending-location is the bottom-most location of the - * selection. The mouse-up location is not necessarily - * a pointer to valid text. - * - * This case handles multi-clicking events as well as - * selections whose start or end location was not - * pointing to text. - */ - save_dot = DOT; - startx = XtermPos(); /* starting-location */ - starty = XtermPos(); - endx = XtermPos(); /* ending-location */ - endy = XtermPos(); - mousex = XtermPos(); /* location at mouse-up */ - mousey = XtermPos(); - - TRACE(("MOUSE-invalid: start(%d,%d) end(%d,%d) mouse(%d,%d)\n", - starty, startx, - endy, endx, - mousey, mousex)); - setcursor(starty - 1, startx - 1); - setwmark(endy - 1, endx - 1); - if (MK.o != 0 && !is_at_end_of_line(MK)) - MK.o += 1; - yankregion(); - - DOT = save_dot; - movecursor(save_row, save_col); - (void) update(TRUE); - break; -#endif /* OPT_XTERM < 3 */ - default: - status = FALSE; - } - endofDisplay(); - } - return status; -} - -static void -tcap_settitle(const char *string) -{ - if (i_am_xterm && global_g_val(GMDXTERM_TITLE) && string != 0) { - putpad("\033]0;"); - putpad(string); - putpad("\007"); - term.flush(); - } -} -#else -#define tcap_settitle nullterm_settitle -#endif /* OPT_XTERM */ - TERM term = { 0, /* the first four values are set dynamically */ @@ -1533,10 +1152,13 @@ nullterm_scroll, /* set dynamically at open time */ nullterm_pflush, nullterm_icursor, - tcap_settitle, + nullterm_settitle, /* filled in by xterm_open() */ ttwatchfd, ttunwatchfd, tcap_cursor, + nullterm_mopen, /* filled in by xterm_open() */ + nullterm_mclose, /* filled in by xterm_open() */ + nullterm_mevent, /* filled in by xterm_open() */ }; #endif /* DISP_TERMCAP */ Index: tcap.h Prereq: 1.9 --- vile-9.5b+/tcap.h 2002-12-22 17:19:16.000000000 +0000 +++ vile-9.5c/tcap.h 2005-11-23 15:44:04.000000000 +0000 @@ -1,7 +1,7 @@ /* * Configurable headers used by termcap/terminfo driver for vile. * - * $Header: /usr/build/vile/vile/RCS/tcap.h,v 1.9 2002/12/22 17:19:16 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/tcap.h,v 1.10 2005/11/23 15:44:04 tom Exp $ */ #ifndef VILE_TCAP_H @@ -92,6 +92,20 @@ extern char PC; /* used in 'tputs()' */ #endif +#define I_AM_XTERM(given) \ + if (given != 0 && \ + (strstr(given, "xterm") != 0 || strstr(given, "rxvt") != 0)) { \ + i_am_xterm = TRUE; \ + } else if ((t = TGETSTR(CAPNAME("Km", "kmous"), &p)) != 0 \ + && (t != (char *) (-1)) \ + && !strcmp(t, "\033[M")) { \ + i_am_xterm = TRUE; \ + } else if (TGETFLAG(CAPNAME("XT", "XT")) > 0) { \ + i_am_xterm = TRUE; \ + } else { \ + i_am_xterm = FALSE; \ + } + #ifdef MISSING_EXTERN_TGETENT extern int tgetent (char *buffer, char *termtype); #endif Index: termio.c Prereq: 1.200 --- vile-9.5b+/termio.c 2005-07-11 22:44:41.000000000 +0000 +++ vile-9.5c/termio.c 2005-11-23 12:13:03.000000000 +0000 @@ -3,7 +3,7 @@ * characters, and write characters in a barely buffered fashion on the display. * All operating systems. * - * $Header: /usr/build/vile/vile/RCS/termio.c,v 1.200 2005/07/11 22:44:41 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/termio.c,v 1.201 2005/11/23 12:13:03 tom Exp $ * */ @@ -1512,6 +1512,24 @@ { } +/*ARGSUSED*/ +void +nullterm_mopen(void) +{ +} + +/*ARGSUSED*/ +void +nullterm_mclose(void) +{ +} + +/*ARGSUSED*/ +void +nullterm_mevent(void) +{ +} + TERM null_term = { 1, @@ -1544,6 +1562,9 @@ nullterm_watchfd, nullterm_unwatchfd, nullterm_cursorvis, + nullterm_mopen, + nullterm_mclose, + nullterm_mevent, }; /******************************************************************************/ Index: trace.h Prereq: 1.23 --- vile-9.5b+/trace.h 2005-05-22 16:58:43.000000000 +0000 +++ vile-9.5c/trace.h 2005-11-23 21:18:33.000000000 +0000 @@ -1,7 +1,7 @@ /* * debugging support -- tom dickey. * - * $Header: /usr/build/vile/vile/RCS/trace.h,v 1.23 2005/05/22 16:58:43 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/trace.h,v 1.24 2005/11/23 21:18:33 tom Exp $ * */ #ifndef _trace_h @@ -93,4 +93,21 @@ #define TRACE_NULL(s) ((s) != 0 ? (s) : "") +#define TRACE_CMDFUNC(p) \ + ((p)->c_flags & CMD_PERL \ + ? "perl" \ + : ((p)->c_flags & CMD_PROC \ + ? "proc" \ + : "func")), \ + ((p)->c_name \ + ? (p)->c_name \ + : "?") + +#define TRACE_BINDINGS(p) \ + (p) == &dft_bindings ? "default" : \ + (p) == &sel_bindings ? "select" : \ + (p) == &ins_bindings ? "insert" : \ + (p) == &cmd_bindings ? "command" : \ + "?" + #endif /* _trace_h */ Index: vile.hlp Prereq: 1.602 --- vile-9.5b+/vile.hlp 2005-07-24 20:25:30.000000000 +0000 +++ vile-9.5c/vile.hlp 2005-11-24 01:35:59.000000000 +0000 @@ -1990,6 +1990,10 @@ typed. The target maximum width of lines is changed with the "fillcol" setting. (B) + xterm-fkeys Support xterm's modified function keys by generating + system bindings for the shift-, control-, alt-modifiers + of each function key listed in the terminal description. + xterm-mouse Enables mouse-clicking if you are running within an xterm. That is, it allows vile to receive mouse events. Since this mode overrides xterm's cut & paste, you will @@ -6204,4 +6208,4 @@ Copyright 1995-2005 by Paul Fox, Thomas Dickey, and Kevin Buettner -------------------------------------------------------------------- - $Header: /usr/build/vile/vile/RCS/vile.hlp,v 1.602 2005/07/24 20:25:30 tom Exp $ + $Header: /usr/build/vile/vile/RCS/vile.hlp,v 1.603 2005/11/24 01:35:59 tom Exp $ Index: vl_alloc.h --- /dev/null 2005-11-19 17:15:46.000000000 +0000 +++ vile-9.5c/vl_alloc.h 2005-11-18 01:27:00.000000000 +0000 @@ -0,0 +1,48 @@ +/* + * $Header: /usr/build/vile/vile/RCS/vl_alloc.h,v 1.1 2005/11/18 01:27:00 tom Exp $ + * + * Copyright 2005, Thomas E. Dickey and Paul G. Fox + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, distribute with modifications, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name(s) of the above copyright + * holders shall not be used in advertising or otherwise to promote the + * sale, use or other dealings in this Software without prior written + * authorization. + */ + +#ifndef VL_ALLOC_H_incl +#define VL_ALLOC_H_incl 1 + +/* structure-allocate, for appeasing strict compilers */ +#define castalloc(cast,nbytes) (cast *)malloc(nbytes) +#define castrealloc(cast,ptr,nbytes) (cast *)realloc((ptr),(nbytes)) +#define typecalloc(cast) (cast *)calloc(sizeof(cast),1) +#define typecallocn(cast,ntypes) (cast *)calloc(sizeof(cast),ntypes) +#define typealloc(cast) (cast *)malloc(sizeof(cast)) +#define typeallocn(cast,ntypes) (cast *)malloc((ntypes)*sizeof(cast)) +#define typereallocn(cast,ptr,ntypes) (cast *)realloc((ptr),\ + (ntypes)*sizeof(cast)) +#define typeallocplus(cast,extra) (cast *)calloc((extra)+sizeof(cast),1) + +#define FreeAndNull(p) if ((p) != 0) { free(p); p = 0; } +#define FreeIfNeeded(p) if ((p) != 0) free(p) + +#endif /* VL_ALLOC_H_incl */ Index: vl_ctype.h --- /dev/null 2005-11-19 17:15:46.000000000 +0000 +++ vile-9.5c/vl_ctype.h 2005-11-20 19:57:02.000000000 +0000 @@ -0,0 +1,197 @@ +/* + * $Header: /usr/build/vile/vile/RCS/vl_ctype.h,v 1.2 2005/11/20 19:57:02 tom Exp $ + * + * Character-type tests, like for vile (vi-like-emacs). + * + * Copyright 2005, Thomas E. Dickey + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, distribute with modifications, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name(s) of the above copyright + * holders shall not be used in advertising or otherwise to promote the + * sale, use or other dealings in this Software without prior written + * authorization. + */ + +#ifndef VL_CTYPE_H_incl +#define VL_CTYPE_H_incl 1 + +#ifndef SMALLER +#define SMALLER 0 /* strip some fluff -- not a lot smaller, but some */ +#endif + +#ifndef OPT_VILE_CTYPE +#define OPT_VILE_CTYPE 1 +#endif + +#ifndef OPT_WIDE_CTYPES +#define OPT_WIDE_CTYPES !SMALLER /* extra char-types tests */ +#endif + +#define UCHAR unsigned char + +#define N_chars 256 /* must be a power-of-2 */ + +#define EOS '\0' +#define BQUOTE '`' +#define SQUOTE '\'' +#define DQUOTE '"' +#define BACKSLASH '\\' +#define CH_TILDE '~' + +# undef istype +# undef isAlnum +# undef isAlpha +# undef isCntrl +# undef isDigit +# undef isLower +# undef isPrint +# undef isPunct +# undef isSpace +# undef isUpper +# undef toUpper +# undef toLower +# undef isident +# undef isXDigit + +#define CharOf(c) ((unsigned char)(c)) + +#if OPT_VILE_CTYPE + +/* these are the bits that go into the vl_chartypes_ array */ +/* the macros below test for them */ +#define chrBIT(n) ((CHARTYPE)(1L<<(n))) + +typedef enum { + vl_UPPER = 0 + , vl_LOWER + , vl_DIGIT + , vl_SPACE + , vl_BSPACE + , vl_CNTRL + , vl_PRINT + , vl_PUNCT + , vl_IDENT + , vl_PATHN + , vl_WILD + , vl_LINESPEC + , vl_FENCE + , vl_NONSPACE + , vl_QIDENT +#if OPT_WIDE_CTYPES + , vl_SCRTCH + , vl_SHPIPE + , vl_XDIGIT +#endif + , vl_UNUSED +} VL_CTYPES; + +#define vl_upper chrBIT(vl_UPPER) /* upper case */ +#define vl_lower chrBIT(vl_LOWER) /* lower case */ +#define vl_digit chrBIT(vl_DIGIT) /* digits */ +#define vl_space chrBIT(vl_SPACE) /* whitespace */ +#define vl_bspace chrBIT(vl_BSPACE) /* backspace character (^H, DEL, and user's) */ +#define vl_cntrl chrBIT(vl_CNTRL) /* control characters, including DEL */ +#define vl_print chrBIT(vl_PRINT) /* printable */ +#define vl_punct chrBIT(vl_PUNCT) /* punctuation */ +#define vl_ident chrBIT(vl_IDENT) /* is typically legal in "normal" identifier */ +#define vl_pathn chrBIT(vl_PATHN) /* is typically legal in a file's pathname */ +#define vl_wild chrBIT(vl_WILD) /* is typically a shell wildcard char */ +#define vl_linespec chrBIT(vl_LINESPEC) /* ex-style line range: 1,$ or 13,15 or % etc.*/ +#define vl_fence chrBIT(vl_FENCE) /* a fence, i.e. (, ), [, ], {, } */ +#define vl_nonspace chrBIT(vl_NONSPACE) /* non-whitespace */ +#define vl_qident chrBIT(vl_QIDENT) /* is typically legal in "qualified" identifier */ + +#if OPT_WIDE_CTYPES +#define vl_scrtch chrBIT(vl_SCRTCH) /* legal in scratch-buffer names */ +#define vl_shpipe chrBIT(vl_SHPIPE) /* legal in shell/pipe-buffer names */ +#define vl_xdigit chrBIT(vl_XDIGIT) /* hex digit */ +#define isXDigit(c) istype(vl_xdigit, c) + +typedef unsigned long CHARTYPE; +#else +typedef USHORT CHARTYPE; +#endif + +/* these parallel the ctypes.h definitions, except that + they force the char to valid range first */ +#define vlCTYPE(c) vl_chartypes_[CharOf(c)] +#define istype(m,c) ((vlCTYPE(c) & (m)) != 0) + +#define isAlnum(c) istype(vl_lower|vl_upper|vl_digit, c) +#define isAlpha(c) istype(vl_lower|vl_upper, c) +#define isCntrl(c) istype(vl_cntrl, c) +#define isDigit(c) istype(vl_digit, c) +#define isLower(c) istype(vl_lower, c) +#define isPrint(c) istype(vl_print, c) +#define isPunct(c) istype(vl_punct, c) +#define isSpace(c) istype(vl_space, c) +#define isUpper(c) istype(vl_upper, c) + +#define isbackspace(c) (istype(vl_bspace, c) || (c) == backspc) +#define isfence(c) istype(vl_fence, c) +#define isident(c) istype(vl_ident, c) +#define isqident(c) istype(vl_qident, c) +#define islinespecchar(c) istype(vl_linespec, c) +#define ispath(c) istype(vl_pathn, c) +#define iswild(c) istype(vl_wild, c) + +/* macro for whitespace (non-return) */ +#define isBlank(c) ((c == '\t') || (c == ' ')) + +#define isGraph(c) (!isSpecial(c) && !isSpace(c) && isPrint(c)) + +/* DIFCASE represents the difference between upper + and lower case letters, DIFCNTRL the difference between upper case and + control characters. They are xor-able values. */ +#define DIFCASE 0x20 +#define DIFCNTRL 0x40 +#define toUpper(c) vl_uppercase[CharOf(c)] +#define toLower(c) vl_lowercase[CharOf(c)] +#define tocntrl(c) (((unsigned)(c))^DIFCNTRL) +#define toalpha(c) (((unsigned)(c))^DIFCNTRL) + +#else + +# include + +# define isAlnum(c) isalnum(c) +# define isAlpha(c) isalpha(c) +# define isCntrl(c) iscntrl(c) +# define isDigit(c) isdigit(c) +# define isLower(c) islower(c) +# define isGraph(c) isgraph(c) +# define isPrint(c) isprint(c) +# define isPunct(c) ispunct(c) +# define isSpace(c) isspace(c) +# define isUpper(c) isupper(c) +# define toUpper(c) toupper(c) +# define toLower(c) tolower(c) +# define isident(c) isalnum(c) +# define isXDigit(c) isxdigit(c) + +#endif + +/* macro for cases where return & newline are equivalent */ +#define isreturn(c) ((c == '\r') || (c == '\n')) + +#define nocase_eq(bc,pc) (CharOf(bc) == CharOf(pc) || (toUpper(bc) == toUpper(pc))) + +#endif /* VL_CTYPE_H_incl */ Index: vl_regex.h --- /dev/null 2005-11-19 17:15:46.000000000 +0000 +++ vile-9.5c/vl_regex.h 2005-11-18 19:00:12.000000000 +0000 @@ -0,0 +1,93 @@ +/* + * $Header: /usr/build/vile/vile/RCS/vl_regex.h,v 1.3 2005/11/18 19:00:12 tom Exp $ + * + * Copyright 2005, Thomas E. Dickey and Paul G. Fox + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, distribute with modifications, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name(s) of the above copyright + * holders shall not be used in advertising or otherwise to promote the + * sale, use or other dealings in this Software without prior written + * authorization. + */ + +#ifndef VL_REGEX_H_incl +#define VL_REGEX_H_incl 1 + +#ifndef OPT_VILE_CTYPE +#define OPT_VILE_CTYPE 0 +#endif + +/* + * Definitions etc. for regexp(3) routines. + * + * the regexp code is: + * Copyright (c) 1986 by University of Toronto. + * Written by Henry Spencer. Not derived from licensed software. + * + */ +#define NSUBEXP 10 +typedef struct regexp { + char *startp[NSUBEXP]; + char *endp[NSUBEXP]; + size_t mlen; /* convenience: endp[0] - startp[0] */ + int regstart; /* Internal use only. */ + char reganch; /* Internal use only. */ + int regmust; /* Internal use only. */ + unsigned regmlen; /* Internal use only. */ + size_t size; /* vile addition -- how big is this */ + char program[1]; /* Unwarranted chumminess with compiler. */ +} regexp; + +/* + * The first byte of the regexp internal "program" is actually this magic + * number; the start node begins in the second byte. + */ +#define REGEXP_MAGIC 0234 + +#ifndef CHARBITS +#define UCHAR_AT(p) ((int)*(unsigned char *)(p)) +#else +#define UCHAR_AT(p) ((int)*(p)&CHARBITS) +#endif + +/* end of regexp stuff */ + +#ifndef GCC_PRINTFLIKE +#ifdef GCC_PRINTF +#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) +#else +#define GCC_PRINTFLIKE(fmt,var) /*nothing*/ +#endif +#endif /* GCC_PRINTFLIKE */ + +#ifndef _estruct_h +extern void mlforce (const char *fmt, ...) GCC_PRINTFLIKE(1,2); +#endif /* _estruct_h */ + +extern void regerror (const char *s); +extern regexp * regcomp (const char *origexp, size_t exp_len, int magic); +extern int regexec (regexp *prog, char *string, char *stringend, int startoff, int endoff); + +#if !OPT_VILE_CTYPE +extern int ignorecase; +#endif + +#endif /* VL_REGEX_H_incl */ Index: vmsvt.c Prereq: 1.57 --- vile-9.5b+/vmsvt.c 2004-10-29 21:16:10.000000000 +0000 +++ vile-9.5c/vmsvt.c 2005-11-23 12:19:01.000000000 +0000 @@ -14,7 +14,7 @@ * -- support wide and narrow screen resolutions, * -- support visual bells. * - * $Header: /usr/build/vile/vile/RCS/vmsvt.c,v 1.57 2004/10/29 21:16:10 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/vmsvt.c,v 1.58 2005/11/23 12:19:01 tom Exp $ * */ @@ -721,6 +721,9 @@ nullterm_watchfd, nullterm_unwatchfd, nullterm_cursorvis, + nullterm_mopen, + nullterm_mclose, + nullterm_mevent, }; #endif Index: x11.c Prereq: 1.280 --- vile-9.5b+/x11.c 2005-07-11 21:10:12.000000000 +0000 +++ vile-9.5c/x11.c 2005-11-23 13:30:33.000000000 +0000 @@ -2,7 +2,7 @@ * X11 support, Dave Lemke, 11/91 * X Toolkit support, Kevin Buettner, 2/94 * - * $Header: /usr/build/vile/vile/RCS/x11.c,v 1.280 2005/07/11 21:10:12 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/x11.c,v 1.281 2005/11/23 13:30:33 tom Exp $ * */ @@ -586,6 +586,9 @@ x_watchfd, x_unwatchfd, nullterm_cursorvis, + nullterm_mopen, + nullterm_mclose, + nullterm_mevent, }; #define x_width(tw) ((tw)->cols * (tw)->char_width) Index: xterm.c --- /dev/null 2005-11-19 17:15:46.000000000 +0000 +++ vile-9.5c/xterm.c 2005-11-23 17:13:51.000000000 +0000 @@ -0,0 +1,285 @@ +/* + * $Header: /usr/build/vile/vile/RCS/xterm.c,v 1.2 2005/11/23 17:13:51 tom Exp $ + * + * xterm-specific code for vi-like-emacs. + */ + +#include "estruct.h" +#include "edef.h" + +#if DISP_TERMCAP || DISP_CURSES + +#define putpad(s) fputs(s, stdout) +#define XtermPos() ((unsigned)(keystroke() - 040)) + +#if OPT_XTERM >= 3 +# define XTERM_ENABLE_TRACKING "\033[?1001h" /* mouse hilite tracking */ +# define XTERM_DISABLE_TRACKING "\033[?1001l" +#else +# if OPT_XTERM >= 2 +# define XTERM_ENABLE_TRACKING "\033[?1000h" /* normal tracking mode */ +# define XTERM_DISABLE_TRACKING "\033[?1000l" +# else +# define XTERM_ENABLE_TRACKING "\033[?9h" /* X10 compatibility mode */ +# define XTERM_DISABLE_TRACKING "\033[?9l" +# endif +#endif + +static int x_origin = 1, y_origin = 1; + +void +xterm_open(TERM * tp) +{ + x_origin = 0; + y_origin = 0; + tp->set_title = xterm_settitle; + tp->mopen = xterm_mopen; + tp->mclose = xterm_mclose; + +#if OPT_XTERM + addtosysmap("\033[M", 3, KEY_Mouse); +#if OPT_XTERM >= 3 + addtosysmap("\033[t", 3, KEY_text); + addtosysmap("\033[T", 3, KEY_textInvalid); +#endif +#endif +} + +void +xterm_mopen(void) +{ + TRACE((T_CALLED "xterm_mopen()\n")); + if (global_g_val(GMDXTERM_MOUSE)) { + putpad(XTERM_ENABLE_TRACKING); + fflush(stdout); + } + returnVoid(); +} + +void +xterm_mclose(void) +{ + TRACE((T_CALLED "xterm_mclose()\n")); + if (global_g_val(GMDXTERM_MOUSE)) { + putpad(XTERM_DISABLE_TRACKING); + fflush(stdout); + } + returnVoid(); +} + +/* Finish decoding a mouse-click in an xterm, after the ESC and '[' chars. + * + * There are 3 mutually-exclusive xterm mouse-modes (selected here by values of + * OPT_XTERM): + * (1) X10-compatibility (not used here) + * Button-press events are received. + * (2) normal-tracking + * Button-press and button-release events are received. + * Button-events have modifiers (e.g., shift, control, meta). + * (3) hilite-tracking + * Button-press and text-location events are received. + * Button-events have modifiers (e.g., shift, control, meta). + * Dragging with the mouse produces highlighting. + * The text-locations are checked by xterm to ensure validity. + * + * NOTE: + * The hilite-tracking code is here for testing and (later) use. Because + * we cannot guarantee that we always are decoding escape-sequences when + * reading from the terminal, there is the potential for the xterm hanging + * when a mouse-dragging operation is begun: it waits for us to specify + * the screen locations that limit the highlighting. + * + * While highlighting, the xterm accepts other characters, but the display + * does not appear to be refreshed until highlighting is ended. So (even + * if we always capture the beginning of highlighting) we cannot simply + * loop here waiting for the end of highlighting. + * + * 1993/aug/6 dickey@software.org + */ + +static int xterm_button(int c); + +/*ARGSUSED*/ +int +mouse_motion(int f GCC_UNUSED, int n GCC_UNUSED) +{ + return xterm_button('M'); +} + +#if OPT_XTERM >= 3 +/*ARGSUSED*/ +int +xterm_mouse_t(int f, int n) +{ + return xterm_button('t'); +} + +/*ARGSUSED*/ +int +xterm_mouse_T(int f, int n) +{ + return xterm_button('T'); +} +#endif /* OPT_XTERM >= 3 */ + +static int +xterm_button(int c) +{ + int event; + int button; + int x; + int y; + int status; +#if OPT_XTERM >= 3 + WINDOW *wp; + int save_row = ttrow; + int save_col = ttcol; + int firstrow, lastrow; + int startx, endx, mousex; + int starty, endy, mousey; + MARK save_dot; + char temp[NSTRING]; + static const char *fmt = "\033[%d;%d;%d;%d;%dT"; +#endif /* OPT_XTERM >= 3 */ + + if ((status = (global_g_val(GMDXTERM_MOUSE))) != 0) { + beginDisplay(); + switch (c) { +#if OPT_XTERM < 3 + /* + * If we get a click on a modeline, clear the current selection, + * if any. Allow implied movement of the mouse (distance between + * pressing and releasing a mouse button) to drag the modeline. + * + * Likewise, if we get a click _not_ on a modeline, make that + * start/extend a selection. + */ + case 'M': /* button-event */ + event = keystroke(); + x = XtermPos() + x_origin - 1; + y = XtermPos() + y_origin - 1; + button = (event & 3) + 1; + + if (button > 3) + button = 0; + TRACE(("MOUSE-button event %d -> btn %d loc %d.%d\n", + event, button, y, x)); + status = on_mouse_click(button, y, x); + break; +#else /* OPT_XTERM >=3, highlighting mode */ + case 'M': /* button-event */ + event = keystroke(); + x = XtermPos() + x_origin; + y = XtermPos() + y_origin; + + button = (event & 3) + 1; + TRACE(("MOUSE-button event:%d x:%d y:%d\n", event, x, y)); + if (button > 3) { + endofDisplay(); + return TRUE; /* button up */ + } + wp = row2window(y - 1); + if (insertmode && wp != curwp) { + kbd_alarm(); + return ABORT; + } + /* Tell the xterm how to highlight the selection. + * It won't do anything else until we do this. + */ + if (wp != 0) { + firstrow = wp->w_toprow + 1; + lastrow = mode_row(wp) + 1; + } else { /* from message-line */ + firstrow = term.rows; + lastrow = term.rows + 1; + } + if (y >= lastrow) /* don't select modeline */ + y = lastrow - 1; + (void) lsprintf(temp, fmt, 1, x, y, firstrow, lastrow); + putpad(temp); + term.flush(); + /* Set the dot-location if button 1 was pressed in a + * window. + */ + if (wp != 0 + && button == 1 + && !reading_msg_line + && setcursor(y - 1, x - 1)) { + (void) update(TRUE); + status = TRUE; + } else if (button <= 3) { + /* abort the selection */ + (void) lsprintf(temp, fmt, 0, x, y, firstrow, lastrow); + putpad(temp); + term.flush(); + status = ABORT; + } else { + status = FALSE; + } + break; + case 't': /* reports valid text-location */ + x = XtermPos(); + y = XtermPos(); + + TRACE(("MOUSE-valid: x:%d y:%d\n", x, y)); + setwmark(y - 1, x - 1); + yankregion(); + + movecursor(save_row, save_col); + (void) update(TRUE); + break; + case 'T': /* reports invalid text-location */ + /* + * The starting-location returned is not the location + * at which the mouse was pressed. Instead, it is the + * top-most location of the selection. In turn, the + * ending-location is the bottom-most location of the + * selection. The mouse-up location is not necessarily + * a pointer to valid text. + * + * This case handles multi-clicking events as well as + * selections whose start or end location was not + * pointing to text. + */ + save_dot = DOT; + startx = XtermPos(); /* starting-location */ + starty = XtermPos(); + endx = XtermPos(); /* ending-location */ + endy = XtermPos(); + mousex = XtermPos(); /* location at mouse-up */ + mousey = XtermPos(); + + TRACE(("MOUSE-invalid: start(%d,%d) end(%d,%d) mouse(%d,%d)\n", + starty, startx, + endy, endx, + mousey, mousex)); + setcursor(starty - 1, startx - 1); + setwmark(endy - 1, endx - 1); + if (MK.o != 0 && !is_at_end_of_line(MK)) + MK.o += 1; + yankregion(); + + DOT = save_dot; + movecursor(save_row, save_col); + (void) update(TRUE); + break; +#endif /* OPT_XTERM < 3 */ + default: + status = FALSE; + } + endofDisplay(); + } + return status; +} + +void +xterm_settitle(const char *string) +{ + if (global_g_val(GMDXTERM_TITLE) && string != 0) { + putpad("\033]0;"); + putpad(string); + putpad("\007"); + term.flush(); + } +} +#endif /* DISP_TERMCAP || DISP_CURSES */ Index: xtermkeys.h --- /dev/null 2005-11-19 17:15:46.000000000 +0000 +++ vile-9.5c/xtermkeys.h 2005-11-23 19:17:13.000000000 +0000 @@ -0,0 +1,209 @@ +/* + * $Header: /usr/build/vile/vile/RCS/xtermkeys.h,v 1.6 2005/11/23 19:17:13 tom Exp $ + * + * Function-key definitions and modifiers used for xterm. This is a header + * file to simplify sharing between the termcap/curses drivers. + */ + +#define DATA(tc,ti,code) { CAPNAME(tc,ti), code, 0 } +/* *INDENT-OFF* */ +static struct { + char *capname; + int code; + char * result; +} keyseqs[] = { + /* Arrow keys */ + DATA( "ku","kcuu1", KEY_Up ), + DATA( "kd","kcud1", KEY_Down ), + DATA( "kr","kcuf1", KEY_Right ), + DATA( "kl","kcub1", KEY_Left ), + /* other cursor-movement */ + DATA( "kh","khome", KEY_Home ), + DATA( "kH","kll", KEY_End ), + DATA( "@7","kend", KEY_End ), + DATA( "kB","kcbt", KEY_BackTab ), /* back-tab */ + /* page scroll */ + DATA( "kN","knp", KEY_Next ), + DATA( "kP","kpp", KEY_Prior ), + /* editing */ + DATA( "kI","kich1", KEY_Insert ), + DATA( "kD","kdch1", KEY_Delete ), + DATA( "@0","kfnd", KEY_Find ), + DATA( "*6","kslt", KEY_Select ), + /* command */ + DATA( "%1","khlp", KEY_Help ), + /* function keys */ + DATA( "k1","kf1", KEY_F1 ), + DATA( "k2","kf2", KEY_F2 ), + DATA( "k3","kf3", KEY_F3 ), + DATA( "k4","kf4", KEY_F4 ), + DATA( "k5","kf5", KEY_F5 ), + DATA( "k6","kf6", KEY_F6 ), + DATA( "k7","kf7", KEY_F7 ), + DATA( "k8","kf8", KEY_F8 ), + DATA( "k9","kf9", KEY_F9 ), + DATA( "k;","kf10", KEY_F10 ), + DATA( "F1","kf11", KEY_F11 ), + DATA( "F2","kf12", KEY_F12 ), + DATA( "F3","kf13", KEY_F13 ), + DATA( "F4","kf14", KEY_F14 ), + DATA( "F5","kf15", KEY_F15 ), + DATA( "F6","kf16", KEY_F16 ), + DATA( "F7","kf17", KEY_F17 ), + DATA( "F8","kf18", KEY_F18 ), + DATA( "F9","kf19", KEY_F19 ), + DATA( "FA","kf20", KEY_F20 ), + DATA( "FB","kf21", KEY_F21 ), + DATA( "FC","kf22", KEY_F22 ), + DATA( "FD","kf23", KEY_F23 ), + DATA( "FE","kf24", KEY_F24 ), + DATA( "FF","kf25", KEY_F25 ), + DATA( "FG","kf26", KEY_F26 ), + DATA( "FH","kf27", KEY_F27 ), + DATA( "FI","kf28", KEY_F28 ), + DATA( "FJ","kf29", KEY_F29 ), + DATA( "FK","kf30", KEY_F30 ), + DATA( "FL","kf31", KEY_F31 ), + DATA( "FM","kf32", KEY_F32 ), + DATA( "FN","kf33", KEY_F33 ), + DATA( "FO","kf34", KEY_F34 ), + DATA( "FP","kf35", KEY_F35 ) +}; +#undef DATA +/* *INDENT-ON* */ + +#if OPT_KEY_MODIFY +static void +add_fkey(const char *string, int length, int code, int modify) +{ + char buffer[80]; + /* *INDENT-OFF* */ + static struct { + int code; + int mask; + } table[] = { + { 2, mod_KEY | mod_SHIFT }, + { 3, mod_KEY | mod_ALT }, + { 4, mod_KEY | mod_ALT | mod_SHIFT }, + { 5, mod_KEY | mod_CTRL }, + { 6, mod_KEY | mod_CTRL | mod_SHIFT }, + { 7, mod_KEY | mod_CTRL | mod_ALT }, + { 8, mod_KEY | mod_CTRL | mod_ALT | mod_SHIFT } + }; + /* *INDENT-ON* */ + + if (modify) { + if (length >= 3 + && length < (int) sizeof(buffer) + && length == (int) strlen(string) + && !strncmp(string, "\033[", 2) + && strchr(string, ';') == 0) { + static unsigned n; + for (n = 0; n < TABLESIZE(table); ++n) { + if (isDigit(string[2])) + sprintf(buffer, "%.*s;%d%s", + length - 1, + string, + table[n].code, + string + length - 1); + else + sprintf(buffer, "%.2s1;%d%s", + string, table[n].code, string + 2); + if (modify < 0) + delfromsysmap(buffer, strlen(buffer)); + else + addtosysmap(buffer, strlen(buffer), code | table[n].mask); + } + } + } else { + addtosysmap(string, length, code); + } +} +#else +#define add_fkey(string, length, code, modify) addtosysmap(string, length, code) +#endif + +/* + * (re)initialize the function key definitions from the termcap database. + */ +void +tcap_init_fkeys(void) +{ + /* *INDENT-OFF* */ + static char * fallback_arrows[] = { +/* "\033", ** VT52 (type-ahead checks make this not useful) */ + "\033O", /* SS3 */ + "\033[", /* CSI */ + "\217", /* SS3 */ + "\233", /* CSI */ + }; + /* *INDENT-ON* */ + + unsigned i; + int j; + int pass1, pass2, pass; + + if (i_am_xterm) { + pass1 = global_g_val(GMDXTERM_FKEYS) ? 0 : -1; + pass2 = global_g_val(GMDXTERM_FKEYS) ? 2 : 1; + } else { + pass1 = 0; + pass2 = 1; + } + + for (pass = pass1; pass < pass2; ++pass) { + /* + * Provide fallback definitions for all ANSI/ISO/DEC cursor keys. + */ + for (i = 0; i < TABLESIZE(fallback_arrows); i++) { + for (j = 'A'; j <= 'D'; j++) { + char temp[80]; + lsprintf(temp, "%s%c", fallback_arrows[i], j); + add_fkey(temp, strlen(temp), SPEC | j, pass); + } + } + +#if SYS_OS2_EMX + for (i = TABLESIZE(VIO_KeyMap); i--;) { + add_fkey(VIO_KeyMap[i].seq, 2, VIO_KeyMap[i].code, pass); + } +#endif + for (i = TABLESIZE(keyseqs); i--;) { + char *seq = keyseqs[i].result; + if (!NO_CAP(seq)) { + int len; + TRACE(("TGETSTR(%s) = %s\n", keyseqs[i].capname, str_visible(seq))); +#define DONT_MAP_DEL 1 +#if DONT_MAP_DEL + /* NetBSD, FreeBSD, etc. have the kD (delete) function key + defined as the DEL char. i don't like this hack, but + until we (and we may never) have separate system "map" + and "map!" maps, we can't allow this -- DEL has different + semantics in insert and command mode, whereas KEY_Delete + has the same semantics (whatever they may be) in both. + KEY_Delete is the only non-motion system map, by the + way -- so the rest are benign in insert or command + mode. */ + if (strcmp(seq, "\177") == 0) + continue; +#endif + add_fkey(seq, len = strlen(seq), keyseqs[i].code, pass); + /* + * Termcap represents nulls as octal 200, which is ambiguous + * (ugh). To avoid losing escape sequences that may contain + * nulls, check here, and add a mapping for the strings with + * explicit nulls. + */ +#define TCAP_NULL '\200' + if (strchr(seq, TCAP_NULL) != 0) { + char temp[BUFSIZ]; + (void) strcpy(temp, seq); + for (j = 0; j < len; j++) + if (char2int(temp[j]) == TCAP_NULL) + temp[j] = '\0'; + add_fkey(temp, len, keyseqs[i].code, pass); + } + } + } + } +}