##less command
Added the following support to less command
- emoticon support
- diagonal navigation support
| diff --git 1/less-451/.gitignore 2/less-451/.gitignore | |
| new file mode 100644 | |
| index 0000000..5761abc | |
| --- /dev/null | |
| +++ 2/less-451/.gitignore | |
| @@ -0,0 +1 @@ | |
| +*.o | |
| diff --git 1/../less-451-old/NEWS 2/less-451/NEWS | |
| old mode 100644 | |
| new mode 100755 | |
| diff --git 1/../less-451-old/README 2/less-451/README | |
| old mode 100644 | |
| new mode 100755 | |
| index 521856b..42ba420 | |
| --- 1/../less-451-old/README | |
| +++ 2/less-451/README | |
| @@ -66,7 +66,6 @@ INSTALLATION (Unix systems only): | |
| libraries in the LIBS definition in the Makefile; these may need | |
| to be edited. The terminal libraries will be some subset of | |
| -lncurses -lcurses -ltermcap -ltermlib | |
| - | |
| If you wish, you may edit defines.h to remove some optional features. | |
| If you choose not to include some features in your version, you may | |
| wish to edit the manual page "less.nro" and the help page "less.hlp" | |
| diff --git 1/../less-451-old/cmd.h 2/less-451/cmd.h | |
| index 9a72160..682d645 100755 | |
| --- 1/../less-451-old/cmd.h | |
| +++ 2/less-451/cmd.h | |
| @@ -67,6 +67,11 @@ | |
| #define A_FILTER 55 | |
| #define A_F_UNTIL_HILITE 56 | |
| +#define A_DLSHIFT 57 | |
| +#define A_DRSHIFT 58 | |
| +#define A_ULSHIFT 59 | |
| +#define A_URSHIFT 60 | |
| + | |
| #define A_INVALID 100 | |
| #define A_NOACTION 101 | |
| #define A_UINVALID 102 | |
| diff --git 1/../less-451-old/command.c 2/less-451/command.c | |
| index ed5b323..f6bcde5 100755 | |
| --- 1/../less-451-old/command.c | |
| +++ 2/less-451/command.c | |
| @@ -19,7 +19,7 @@ | |
| #include "position.h" | |
| #include "option.h" | |
| #include "cmd.h" | |
| - | |
| +int vshift; | |
| extern int erase_char, erase2_char, kill_char; | |
| extern int sigs; | |
| extern int quit_if_one_screen; | |
| @@ -1765,6 +1765,102 @@ commands() | |
| screen_trashed = 1; | |
| break; | |
| + case A_DRSHIFT: | |
| + vshift=1; | |
| + /* | |
| + * Right Shift N (default width/2) characters. | |
| + */ | |
| + if (number > 0) { | |
| + shift_count = number; | |
| + vshift = (int) number; | |
| + } | |
| + else { | |
| + number = (shift_count > 0) ? | |
| + shift_count : sc_width / 2; | |
| + } | |
| + hshift += number; | |
| + screen_trashed = 1; | |
| + /* | |
| + * Forward N (default 1) line. | |
| + */ | |
| + cmd_exec(); | |
| + if (show_attn == OPT_ONPLUS && number > 1) | |
| + set_attnpos(bottompos); | |
| + forward((int) vshift, 0, 0); | |
| + break; | |
| + | |
| + case A_DLSHIFT: | |
| + vshift=1; | |
| + /* | |
| + * Left Shift N (default width/2) characters. | |
| + */ | |
| + if (number > 0) { | |
| + shift_count = number; | |
| + vshift = (int) number; | |
| + } else | |
| + number = (shift_count > 0) ? | |
| + shift_count : sc_width / 2; | |
| + if (number > hshift) | |
| + number = hshift; | |
| + hshift -= number; | |
| + screen_trashed = 1; | |
| + /* | |
| + * Forward N (default 1) line. | |
| + */ | |
| + cmd_exec(); | |
| + if (show_attn == OPT_ONPLUS && number > 1) | |
| + set_attnpos(bottompos); | |
| + forward((int) vshift, 0, 0); | |
| + break; | |
| + | |
| + case A_URSHIFT: | |
| + vshift=1; | |
| + /* | |
| + * Right Shift N (default width/2) characters. | |
| + */ | |
| + if (number > 0) { | |
| + shift_count = number; | |
| + vshift = (int) number; | |
| + } | |
| + else { | |
| + number = (shift_count > 0) ? | |
| + shift_count : sc_width / 2; | |
| + } | |
| + hshift += number; | |
| + screen_trashed = 1; | |
| + /* | |
| + * Forward N (default 1) line. | |
| + */ | |
| + cmd_exec(); | |
| + if (show_attn == OPT_ONPLUS && number > 1) | |
| + set_attnpos(bottompos); | |
| + backward((int) vshift, 0, 0); | |
| + break; | |
| + | |
| + case A_ULSHIFT: | |
| + vshift=1; | |
| + /* | |
| + * Left Shift N (default width/2) characters. | |
| + */ | |
| + if (number > 0) { | |
| + shift_count = number; | |
| + vshift = (int) number; | |
| + } else | |
| + number = (shift_count > 0) ? | |
| + shift_count : sc_width / 2; | |
| + if (number > hshift) | |
| + number = hshift; | |
| + hshift -= number; | |
| + screen_trashed = 1; | |
| + /* | |
| + * Forward N (default 1) line. | |
| + */ | |
| + cmd_exec(); | |
| + if (show_attn == OPT_ONPLUS && number > 1) | |
| + set_attnpos(bottompos); | |
| + backward((int) vshift, 0, 0); | |
| + break; | |
| + | |
| case A_PREFIX: | |
| /* | |
| * The command is incomplete (more chars are needed). | |
| diff --git 1/../less-451-old/decode.c 2/less-451/decode.c | |
| index 6d0312d..dc943cb 100755 | |
| --- 1/../less-451-old/decode.c | |
| +++ 2/less-451/decode.c | |
| @@ -94,6 +94,10 @@ static unsigned char cmdtable[] = | |
| ESC,']',0, A_RSHIFT, | |
| ESC,'(',0, A_LSHIFT, | |
| ESC,')',0, A_RSHIFT, | |
| + ESC,'{',0, A_DRSHIFT, | |
| + ESC,'}',0, A_DLSHIFT, | |
| + ESC,CONTROL('{'),0, A_URSHIFT, | |
| + ESC,CONTROL('}'),0, A_ULSHIFT, | |
| SK(SK_RIGHT_ARROW),0, A_RSHIFT, | |
| SK(SK_LEFT_ARROW),0, A_LSHIFT, | |
| '{',0, A_F_BRACKET|A_EXTRA, '{','}',0, | |
| diff --git 1/../less-451-old/defines.h.in 2/less-451/defines.h.in | |
| old mode 100644 | |
| new mode 100755 | |
| diff --git 1/../less-451-old/funcs.h 2/less-451/funcs.h | |
| old mode 100644 | |
| new mode 100755 | |
| diff --git 1/../less-451-old/help.c 2/less-451/help.c | |
| old mode 100644 | |
| new mode 100755 | |
| index 85797f6..0562252 | |
| --- 1/../less-451-old/help.c | |
| +++ 2/less-451/help.c | |
| @@ -25,6 +25,14 @@ constant char helpdata[] = { | |
| ' ',' ','u',' ',' ','^','U',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','B','a','c','k','w','a','r','d',' ','o','n','e',' ','h','a','l','f','-','w','i','n','d','o','w',' ','(','a','n','d',' ','s','e','t',' ','h','a','l','f','-','w','i','n','d','o','w',' ','t','o',' ','_','\b','N',')','.','\n', | |
| ' ',' ','E','S','C','-',')',' ',' ','R','i','g','h','t','A','r','r','o','w',' ','*',' ',' ','L','e','f','t',' ',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n', | |
| ' ',' ','E','S','C','-','(',' ',' ','L','e','f','t','A','r','r','o','w',' ',' ','*',' ',' ','R','i','g','h','t',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n', | |
| +' ',' ','E','S','C','-','}',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','D','i','a','g','o','n','a','l',' ','d','o','w','n',' ','l','e','f','t',':',' ','L','e','f','t',' ',' ','1','/','2',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')',' ','\n', | |
| +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','(','o','r',' ','_','\b','N',')',' ','l','i','n','e','s','.','\n', | |
| +' ',' ','E','S','C','-','{',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','D','i','a','g','o','n','a','l',' ','d','o','w','n',' ','r','i','g','h','t',':',' ','R','i','g','h','t',' ','1','/','2',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')',' ','\n', | |
| +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','(','o','r',' ','_','\b','N',')',' ','l','i','n','e','s','.','\n', | |
| +' ',' ','E','S','C','-','c','t','r','l','-','}',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','D','i','a','g','o','n','a','l',' ','u','p',' ','l','e','f','t',':',' ','L','e','f','t',' ',' ','1','/','2',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')',' ','\n', | |
| +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','B','a','c','k','w','a','r','d',' ',' ','o','n','e',' ','(','o','r',' ','_','\b','N',')',' ','l','i','n','e','s','.','\n', | |
| +' ',' ','E','S','C','-','c','t','r','l','-','{',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','D','i','a','g','o','n','a','l',' ','u','p',' ','r','i','g','h','t',':',' ','R','i','g','h','t',' ','1','/','2',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')',' ','\n', | |
| +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','B','a','c','k','w','a','r','d',' ',' ','o','n','e',' ','(','o','r',' ','_','\b','N',')',' ','l','i','n','e','s','.','\n', | |
| ' ',' ','F',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','f','o','r','e','v','e','r',';',' ','l','i','k','e',' ','"','t','a','i','l',' ','-','f','"','.','\n', | |
| ' ',' ','r',' ',' ','^','R',' ',' ','^','L',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','s','c','r','e','e','n','.','\n', | |
| ' ',' ','R',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','s','c','r','e','e','n',',',' ','d','i','s','c','a','r','d','i','n','g',' ','b','u','f','f','e','r','e','d',' ','i','n','p','u','t','.','\n', | |
| diff --git 1/../less-451-old/less.hlp 2/less-451/less.hlp | |
| index a850561..ff15440 100755 | |
| --- 1/../less-451-old/less.hlp | |
| +++ 2/less-451/less.hlp | |
| @@ -22,6 +22,14 @@ | |
| u ^U * Backward one half-window (and set half-window to _N). | |
| ESC-) RightArrow * Left one half screen width (or _N positions). | |
| ESC-( LeftArrow * Right one half screen width (or _N positions). | |
| + ESC-} * Diagonal down left: Left 1/2 screen width (or _N positions) | |
| + Forward one (or _N) lines. | |
| + ESC-{ * Diagonal down right: Right 1/2 screen width (or _N positions) | |
| + Forward one (or _N) lines. | |
| + ESC-ctrl-} * Diagonal up left: Left 1/2 screen width (or _N positions) | |
| + Backward one (or _N) lines. | |
| + ESC-ctrl-{ * Diagonal up right: Right 1/2 screen width (or _N positions) | |
| + Backward one (or _N) lines. | |
| F Forward forever; like "tail -f". | |
| r ^R ^L Repaint screen. | |
| R Repaint screen, discarding buffered input. | |
| diff --git 1/../less-451-old/less.man 2/less-451/less.man | |
| old mode 100644 | |
| new mode 100755 | |
| diff --git 1/../less-451-old/less.nro 2/less-451/less.nro | |
| old mode 100644 | |
| new mode 100755 | |
| diff --git 1/../less-451-old/lessecho.man 2/less-451/lessecho.man | |
| old mode 100644 | |
| new mode 100755 | |
| diff --git 1/../less-451-old/lessecho.nro 2/less-451/lessecho.nro | |
| old mode 100644 | |
| new mode 100755 | |
| diff --git 1/../less-451-old/lesskey.man 2/less-451/lesskey.man | |
| old mode 100644 | |
| new mode 100755 | |
| diff --git 1/../less-451-old/lesskey.nro 2/less-451/lesskey.nro | |
| old mode 100644 | |
| new mode 100755 | |
| diff --git 1/../less-451-old/main.c 2/less-451/main.c | |
| index da61b6b..9003118 100755 | |
| --- 1/../less-451-old/main.c | |
| +++ 2/less-451/main.c | |
| @@ -118,7 +118,6 @@ main(argc, argv) | |
| init_cmdhist(); | |
| init_option(); | |
| init_search(); | |
| - | |
| /* | |
| * If the name of the executable program is "more", | |
| * act like LESS_IS_MORE is set. | |
| @@ -132,7 +131,6 @@ main(argc, argv) | |
| less_is_more = 1; | |
| init_prompt(); | |
| - | |
| s = lgetenv(less_is_more ? "MORE" : "LESS"); | |
| if (s != NULL) | |
| scan_option(save(s)); | |
| diff --git 1/less-451/mkhelp 2/less-451/mkhelp | |
| new file mode 100755 | |
| index 0000000..8a0e868 | |
| Binary files /dev/null and 2/less-451/mkhelp differ | |
| diff --git 1/less-451/mkhelpy 2/less-451/mkhelpy | |
| new file mode 100755 | |
| index 0000000..2f1f9ae | |
| Binary files /dev/null and 2/less-451/mkhelpy differ | |
| diff --git 1/../less-451-old/output.c 2/less-451/output.c | |
| index bcc8471..b1c31e0 100755 | |
| --- 1/../less-451-old/output.c | |
| +++ 2/less-451/output.c | |
| @@ -46,6 +46,8 @@ extern int bl_fg_color, bl_bg_color; | |
| put_line() | |
| { | |
| register int c; | |
| + register int d; | |
| + register int e; | |
| register int i; | |
| int a; | |
| @@ -64,15 +66,52 @@ put_line() | |
| { | |
| at_switch(a); | |
| final_attr = a; | |
| - if (c == '\b') | |
| - putbs(); | |
| - else | |
| - putchr(c); | |
| + | |
| + // check if the current character is ‘:’ | |
| + // if so, then start an automata to check if the next 2 characters | |
| + // can match according to a smiley. Update it accordingly else, | |
| + // print normally | |
| + if ((c == ':') && ((d = gline(i+1, &a)) != '\0') && (d=='-') && ((e = gline(i+2, &a) ) != '\0')){ | |
| + if (e==')') { | |
| + // Add appropriate unicode for happy smiley | |
| + putchr(0x00); | |
| + putchr(0xe2); | |
| + putchr(0x98); | |
| + putchr(0xba); | |
| + // Increment i by only 2 as at the end of the loop | |
| + // i is incremented by 1 | |
| + i+=2; | |
| + } else if (e=='(') { | |
| + // Add appropriate unicode for sad smiley | |
| + putchr(0x00); | |
| + putchr(0xe2); | |
| + putchr(0x98); | |
| + putchr(0xb9); | |
| + // Increment i by only 2 as at the end of the loop | |
| + // i is incremented by 1 | |
| + i+=2; | |
| + } else { | |
| + // Could not find a smiley, | |
| + at_switch(a); | |
| + final_attr = a; | |
| + if (c == '\b') | |
| + putbs(); | |
| + else { | |
| + putchr(c); | |
| + putchr(d); | |
| + i+=1; | |
| + } | |
| + } | |
| + } else { | |
| + if (c == '\b') | |
| + putbs(); | |
| + else | |
| + putchr(c); | |
| + } | |
| } | |
| at_exit(); | |
| } | |
| - | |
| static char obuf[OUTBUF_SIZE]; | |
| static char *ob = obuf; | |
| diff --git 1/less-451/smiley.txt 2/less-451/smiley.txt | |
| new file mode 100644 | |
| index 0000000..7cfa7d8 | |
| --- /dev/null | |
| +++ 2/less-451/smiley.txt | |
| @@ -0,0 +1,25 @@ | |
| +Unit Tests to check rendering of smileys | |
| + | |
| +Test:1 | |
| +Rendered: ashdsahdashdhd::-):-(:::::::::::-asdf | |
| +Expected: ashdsahdashdhd:☺☹:::::::::::-asdf | |
| + | |
| +Test:2 | |
| +Rendered: : | |
| +Expected: : | |
| + | |
| +Test:3 | |
| +Rendered: :- | |
| +Expected: :- | |
| + | |
| +Test:4 | |
| +Rendered: :-xaskdishd | |
| +Expected: :-xaskdishd | |
| + | |
| +Test:5 | |
| +Rendered: jasdjshdsjdhs:-))) | |
| +Expected: jasdjshdsjdhs☺)) | |
| + | |
| +Test:6 | |
| +Rendered: jasdjshdsjdhs:-) | |
| +Expected: jasdjshdsjdhs☺ |