#if ENABLE_LOCALE_SUPPORT
#define Isprint(c) isprint((c))
#else
-#define Isprint(c) ( (c) >= ' ' && (c) != 127 && (c) != ((unsigned char)'\233') )
+/* 0x9b is Meta-ESC */
+#define Isprint(c) ((unsigned char)(c) >= ' ' && (c) != 0x7f && (unsigned char)(c) != 0x9b)
#endif
#define MAX_SCR_COLS BUFSIZ
// Misc. non-Ascii keys that report an escape sequence
-#define VI_K_UP 128 // cursor key Up
-#define VI_K_DOWN 129 // cursor key Down
-#define VI_K_RIGHT 130 // Cursor Key Right
-#define VI_K_LEFT 131 // cursor key Left
-#define VI_K_HOME 132 // Cursor Key Home
-#define VI_K_END 133 // Cursor Key End
-#define VI_K_INSERT 134 // Cursor Key Insert
-#define VI_K_PAGEUP 135 // Cursor Key Page Up
-#define VI_K_PAGEDOWN 136 // Cursor Key Page Down
-#define VI_K_FUN1 137 // Function Key F1
-#define VI_K_FUN2 138 // Function Key F2
-#define VI_K_FUN3 139 // Function Key F3
-#define VI_K_FUN4 140 // Function Key F4
-#define VI_K_FUN5 141 // Function Key F5
-#define VI_K_FUN6 142 // Function Key F6
-#define VI_K_FUN7 143 // Function Key F7
-#define VI_K_FUN8 144 // Function Key F8
-#define VI_K_FUN9 145 // Function Key F9
-#define VI_K_FUN10 146 // Function Key F10
-#define VI_K_FUN11 147 // Function Key F11
-#define VI_K_FUN12 148 // Function Key F12
+#define VI_K_UP (char)128 // cursor key Up
+#define VI_K_DOWN (char)129 // cursor key Down
+#define VI_K_RIGHT (char)130 // Cursor Key Right
+#define VI_K_LEFT (char)131 // cursor key Left
+#define VI_K_HOME (char)132 // Cursor Key Home
+#define VI_K_END (char)133 // Cursor Key End
+#define VI_K_INSERT (char)134 // Cursor Key Insert
+#define VI_K_PAGEUP (char)135 // Cursor Key Page Up
+#define VI_K_PAGEDOWN (char)136 // Cursor Key Page Down
+#define VI_K_FUN1 (char)137 // Function Key F1
+#define VI_K_FUN2 (char)138 // Function Key F2
+#define VI_K_FUN3 (char)139 // Function Key F3
+#define VI_K_FUN4 (char)140 // Function Key F4
+#define VI_K_FUN5 (char)141 // Function Key F5
+#define VI_K_FUN6 (char)142 // Function Key F6
+#define VI_K_FUN7 (char)143 // Function Key F7
+#define VI_K_FUN8 (char)144 // Function Key F8
+#define VI_K_FUN9 (char)145 // Function Key F9
+#define VI_K_FUN10 (char)146 // Function Key F10
+#define VI_K_FUN11 (char)147 // Function Key F11
+#define VI_K_FUN12 (char)148 // Function Key F12
/* vt102 typical ESC sequence */
/* terminal standout start/normal ESC sequence */
static void crash_test();
static int crashme = 0;
#endif
+#if ENABLE_FEATURE_VI_COLON
static char *initial_cmds[] = { NULL, NULL , NULL }; // currently 2 entries, NULL terminated
+#endif
static void write1(const char *out)
// 1- process $HOME/.exrc file (not inplemented yet)
// 2- process EXINIT variable from environment
// 3- process command line args
+#if ENABLE_FEATURE_VI_COLON
{
char *p = getenv("EXINIT");
if (p && *p)
initial_cmds[0] = xstrdup(p);
}
- while ((c = getopt(argc, argv, "hCRc:")) != -1) {
+#endif
+ while ((c = getopt(argc, argv, "hCR" USE_FEATURE_VI_COLON("c:"))) != -1) {
switch (c) {
#if ENABLE_FEATURE_VI_CRASHME
case 'C':
//case 'r': // recover flag- ignore- we don't use tmp file
//case 'x': // encryption flag- ignore
//case 'c': // execute command first
+#if ENABLE_FEATURE_VI_COLON
case 'c': // cmd line vi command
if (*optarg)
initial_cmds[initial_cmds[0] != 0] = xstrdup(optarg);
break;
//case 'h': // help -- just use default
+#endif
default:
show_help();
return 1;
redraw(FALSE); // dont force every col re-draw
show_status_line();
+#if ENABLE_FEATURE_VI_COLON
{
char *p, *q;
int n = 0;
n++;
}
}
+#endif
//------This is the main Vi cmd handling loop -----------------------
while (editing > 0) {
#if ENABLE_FEATURE_VI_CRASHME
int c_is_no_print;
c = *q;
- c_is_no_print = c > 127 && !Isprint(c);
+ c_is_no_print = (c & 0x80) && !Isprint(c);
if (c_is_no_print) {
c = '.';
standout_start();
}
#if ENABLE_FEATURE_VI_SET
} else if (strncasecmp(cmd, "set", i) == 0) { // set or clear features
+#if ENABLE_FEATURE_VI_SETOPTS
char *argp;
+#endif
i = 0; // offset into args
// only blank is regarded as args delmiter. What about tab '\t' ?
if (!args[0] || strcasecmp(args, "all") == 0) {
}
#if ENABLE_FEATURE_VI_SETOPTS
argp = args;
- while (*argp) {
+ while (*argp) {
if (strncasecmp(argp, "no", 2) == 0)
i = 2; // ":set noautoindent"
setops(argp, "autoindent ", i, "ai", VI_AUTOINDENT);
int c_is_no_print;
c = *s;
- c_is_no_print = c > 127 && !Isprint(c);
+ c_is_no_print = (c & 0x80) && !Isprint(c);
if (c_is_no_print) {
strcat(buf, SOn);
c = '.';
char c;
for (co = 0; co < MAX_SCR_COLS; co++) {
- c= ' '; // assume blank
+ c = ' '; // assume blank
if (li > 0 && co == 0) {
c = '~'; // not first line, assume Tilde
}
}
if (c == '\n')
break;
- if (c > 127 && !Isprint(c)) {
+ if ((c & 0x80) && !Isprint(c)) {
c = '.';
}
- if (c < ' ' || c == 127) {
+ if ((unsigned char)(c) < ' ' || c == 0x7f) {
if (c == '\t') {
c = ' ';
// co % 8 != 7
}
} else {
dest[co++] = '^';
- if (c == 127)
+ if (c == 0x7f)
c = '?';
else
c += '@'; // make it visible
if (cmd_mode == 2) {
// flip-flop Insert/Replace mode
- if (c == VI_K_INSERT) goto dc_i;
+ if (c == VI_K_INSERT)
+ goto dc_i;
// we are 'R'eplacing the current *dot with new char
if (*dot == '\n') {
// don't Replace past E-o-l
case 'h': // h- move left
case VI_K_LEFT: // cursor key Left
case 8: // ctrl-H- move left (This may be ERASE char)
- case 127: // DEL- move left (This may be ERASE char)
+ case 0x7f: // DEL- move left (This may be ERASE char)
if (cmdcnt-- > 1) {
do_cmd(c);
} // repeat cnt
editing = 0;
}
}
- } else if (strncasecmp(p, "file", cnt) == 0 ) {
+ } else if (strncasecmp(p, "file", cnt) == 0) {
last_status_cksum = 0; // force status update
} else if (sscanf(p, "%d", &j) > 0) {
dot = find_line(j); // go to line # j