From e011690ab1d0e28b4dd7f45897bfd2a50798ad4d Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Sun, 18 Sep 2016 17:54:18 +0530 Subject: [PATCH] rcfile: reject several ASCII symbols from 64 to 127 Since Ctrl combinations of several ASCII symbols from 64 to 127 cannot be rebound, complain user accordingly and stop colouring them in green in ~/.nanorc, along with other symbols below ASCII 64, as these too can't be rebound. Also, colour M-`, M-~ and M-@ in green since they are functioning properly. --- doc/syntax/nanorc.nanorc | 4 ++-- src/rcfile.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/syntax/nanorc.nanorc b/doc/syntax/nanorc.nanorc index 9f3278d..3972302 100644 --- a/doc/syntax/nanorc.nanorc +++ b/doc/syntax/nanorc.nanorc @@ -10,8 +10,8 @@ icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|comment|ma icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cut|fill|historylog|justifytrim|locking|morespace|mouse|multibuffer|noconvert|nohelp|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|unix|view|wordbounds)\>" icolor yellow "^[[:space:]]*set[[:space:]]+(functioncolor|keycolor|statuscolor|titlecolor)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>" icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|functioncolor|keycolor|matchbrackets|operatingdir|punct|quotestr|speller|statuscolor|titlecolor|whitespace|wordchars)[[:space:]]+" -icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9^_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+(all|main|search|replace(2|with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)" -icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9^_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+(all|main|search|replace(2|with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)" +icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^([[:alpha:]]|space|[]]|[0-9^_\])|M-([[:alpha:]]|space|[]]|address@hidden|\]))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+(all|main|search|replace(2|with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)" +icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([[:alpha:]]|space|[]]|[0-9^_\])|M-([[:alpha:]]|space|[]]|address@hidden|\]))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+(all|main|search|replace(2|with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)" icolor brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|linter|formatter)[[:space:]]+.*$" icolor green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|formatter|extendsyntax)\>" diff --git a/src/rcfile.c b/src/rcfile.c index 2a12d38..6247a1b 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -400,7 +400,8 @@ void parse_binding(char *ptr, bool dobind) rcfile_error(N_("Key name must begin with \"^\", \"M\", or \"F\"")); goto free_copy; } else if ((keycopy[0] == 'M' && keycopy[1] != '-') || - (keycopy[0] == '^' && ((keycopy[1] < 64 || keycopy[1] > 127) || + (keycopy[0] == '^' && ((keycopy[1] < 65 || keycopy[1] > 122) || + keycopy[1] == 91 || keycopy[1] == 96 || (strlen(keycopy) > 2 && strcmp(keycopy, "^Space") != 0))) || (strlen(keycopy) > 3 && strcmp(keycopy, "^Space") != 0 && strcmp(keycopy, "M-Space") != 0)) { -- 2.7.4