Index: src/nano.h =================================================================== --- src/nano.h (revision 5456) +++ src/nano.h (working copy) @@ -173,6 +173,10 @@ } append_type; typedef enum { + SOFTMARK, HARDMARK +} mark_type; + +typedef enum { UPWARD, DOWNWARD } scroll_dir; @@ -391,6 +395,8 @@ /* The file's line where the mark is, if any. */ size_t mark_begin_x; /* The file's mark's x-coordinate position, if any. */ + mark_type kind_of_mark; + /* Whether this is a soft or a hard mark. */ file_format fmt; /* The file's format. */ struct stat *current_stat; @@ -551,6 +557,12 @@ /* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */ #define CONTROL_LEFT 0x401 #define CONTROL_RIGHT 0x402 +#define SHIFT_PAGEUP 0x403 +#define SHIFT_PAGEDOWN 0x404 +#define SHIFT_CONTROL_LEFT 0x405 +#define SHIFT_CONTROL_RIGHT 0x406 +#define SHIFT_ALT_LEFT 0x407 +#define SHIFT_ALT_RIGHT 0x408 #ifndef NANO_TINY /* An imaginary key for when we get a SIGWINCH (window resize). */ Index: src/global.c =================================================================== --- src/global.c (revision 5451) +++ src/global.c (working copy) @@ -38,12 +38,18 @@ /* Whether the current keystroke is a Meta key. */ bool func_key; /* Whether the current keystroke is an extended keypad value. */ +bool shift_held; + /* Whether Shift was being held together with a movement key. */ bool focusing = FALSE; /* Whether an update of the edit window should center the cursor. */ #ifndef NANO_TINY int controlleft = CONTROL_LEFT; int controlright = CONTROL_RIGHT; +int shiftcontrolleft = SHIFT_CONTROL_LEFT; +int shiftcontrolright = SHIFT_CONTROL_RIGHT; +int shiftaltleft = SHIFT_ALT_LEFT; +int shiftaltright = SHIFT_ALT_RIGHT; #endif #ifndef DISABLE_WRAPJUSTIFY Index: src/files.c =================================================================== --- src/files.c (revision 5457) +++ src/files.c (working copy) @@ -65,6 +65,7 @@ openfile->mark_set = FALSE; openfile->mark_begin = NULL; openfile->mark_begin_x = 0; + openfile->kind_of_mark = SOFTMARK; openfile->fmt = NIX_FILE; Index: src/proto.h =================================================================== --- src/proto.h (revision 5451) +++ src/proto.h (working copy) @@ -33,11 +33,17 @@ extern bool meta_key; extern bool func_key; +extern bool shift_held; + extern bool focusing; #ifndef NANO_TINY extern int controlleft; extern int controlright; +extern int shiftcontrolleft; +extern int shiftcontrolright; +extern int shiftaltleft; +extern int shiftaltright; #endif #ifndef DISABLE_WRAPJUSTIFY Index: src/text.c =================================================================== --- src/text.c (revision 5456) +++ src/text.c (working copy) @@ -50,10 +50,12 @@ void do_mark(void) { openfile->mark_set = !openfile->mark_set; + if (openfile->mark_set) { statusbar(_("Mark Set")); openfile->mark_begin = openfile->current; openfile->mark_begin_x = openfile->current_x; + openfile->kind_of_mark = HARDMARK; } else { statusbar(_("Mark Unset")); openfile->mark_begin = NULL; Index: src/winio.c =================================================================== --- src/winio.c (revision 5454) +++ src/winio.c (working copy) @@ -333,6 +333,7 @@ meta_key = FALSE; func_key = FALSE; + shift_held = FALSE; /* Read in a character. */ if (nodelay_mode) { @@ -502,37 +503,44 @@ retval = ISSET(REBIND_DELETE) ? sc_seq_or(do_delete, 0) : sc_seq_or(do_backspace, 0); break; - case KEY_DOWN: #ifdef KEY_SDOWN /* ncurses and Slang don't support KEY_SDOWN. */ case KEY_SDOWN: #endif + case KEY_SF: /* Scroll forward, on Xfce4-terminal. */ + shift_held = TRUE; + case KEY_DOWN: retval = sc_seq_or(do_down_void, *kbinput); break; - case KEY_UP: #ifdef KEY_SUP /* ncurses and Slang don't support KEY_SUP. */ case KEY_SUP: #endif + case KEY_SR: /* Scroll backward, on Xfce4-terminal. */ + shift_held = TRUE; + case KEY_UP: retval = sc_seq_or(do_up_void, *kbinput); break; - case KEY_LEFT: #ifdef KEY_SLEFT /* Slang doesn't support KEY_SLEFT. */ case KEY_SLEFT: + shift_held = TRUE; #endif + case KEY_LEFT: retval = sc_seq_or(do_left, *kbinput); break; - case KEY_RIGHT: #ifdef KEY_SRIGHT /* Slang doesn't support KEY_SRIGHT. */ case KEY_SRIGHT: + shift_held = TRUE; #endif + case KEY_RIGHT: retval = sc_seq_or(do_right, *kbinput); break; #ifdef KEY_SHOME /* HP-UX 10-11 and Slang don't support KEY_SHOME. */ case KEY_SHOME: + shift_held = TRUE; #endif case KEY_A1: /* Home (7) on numeric keypad with * NumLock off. */ @@ -556,10 +564,18 @@ retval = sc_seq_or(do_insertfile_void, *kbinput); break; #endif +#ifndef NANO_TINY + case SHIFT_PAGEDOWN: /* Fake key, from Shift+Alt+Down. */ + shift_held = TRUE; +#endif case KEY_C3: /* PageDown (4) on numeric keypad with * NumLock off. */ retval = sc_seq_or(do_page_down, *kbinput); break; +#ifndef NANO_TINY + case SHIFT_PAGEUP: /* Fake key, from Shift+Alt+Up. */ + shift_held = TRUE; +#endif case KEY_A3: /* PageUp (9) on numeric keypad with * NumLock off. */ retval = sc_seq_or(do_page_up, *kbinput); @@ -571,14 +587,20 @@ * NumLock off. */ retval = ERR; break; +#ifdef KEY_END + case KEY_END: +#endif case KEY_C1: /* End (1) on numeric keypad with * NumLock off. */ + retval = sc_seq_or(do_end, *kbinput); + break; #ifdef KEY_SEND /* HP-UX 10-11 and Slang don't support KEY_SEND. */ case KEY_SEND: -#endif + shift_held = TRUE; retval = sc_seq_or(do_end, *kbinput); break; +#endif #ifdef KEY_BEG /* Slang doesn't support KEY_BEG. */ case KEY_BEG: /* Center (5) on numeric keypad with @@ -646,6 +668,26 @@ retval = sc_seq_or(do_prev_word_void, 0); else if (retval == controlright) retval = sc_seq_or(do_next_word_void, 0); + else if (retval == shiftcontrolleft) { + shift_held = TRUE; + retval = sc_seq_or(do_prev_word_void, 0); + } else if (retval == shiftcontrolright) { + shift_held = TRUE; + retval = sc_seq_or(do_next_word_void, 0); + } else if (retval == shiftaltleft) { + shift_held = TRUE; + retval = sc_seq_or(do_home, 0); + } else if (retval == shiftaltright) { + shift_held = TRUE; + retval = sc_seq_or(do_end, 0); + /* Guess at the key codes for Shift+Alt+Up and Shift+Alt+Down. */ + } else if (retval == shiftaltright + 6) { + shift_held = TRUE; + retval = sc_seq_or(do_page_up, 0); + } else if (retval == shiftaltleft - 20) { + shift_held = TRUE; + retval = sc_seq_or(do_page_down, 0); + } #endif /* If our result is an extended keypad value (i.e. a value @@ -693,6 +735,7 @@ * Terminal. */ case 'D': /* Esc O 1 ; 2 D == Shift-Left on * Terminal. */ + shift_held = TRUE; retval = get_escape_seq_abcd(seq[4]); break; case 'P': /* Esc O 1 ; 2 P == F13 on Terminal. */ @@ -957,11 +1000,34 @@ case 'B': /* Esc [ 1 ; 2 B == Shift-Down on xterm. */ case 'C': /* Esc [ 1 ; 2 C == Shift-Right on xterm. */ case 'D': /* Esc [ 1 ; 2 D == Shift-Left on xterm. */ + shift_held = TRUE; retval = get_escape_seq_abcd(seq[4]); break; } } break; +#ifndef NANO_TINY + case '4': + if (seq_len >= 5) { + /* When the arrow keys are held together with Shift+Meta, + * act as if they are Home/End/PgUp/PgDn with Shift. */ + switch (seq[4]) { + case 'A': /* Esc [ 1 ; 4 A == Shift-Alt-Up on xterm. */ + retval = SHIFT_PAGEUP; + break; + case 'B': /* Esc [ 1 ; 4 B == Shift-Alt-Down on xterm. */ + retval = SHIFT_PAGEDOWN; + break; + case 'C': /* Esc [ 1 ; 4 C == Shift-Alt-Right on xterm. */ + retval = KEY_SEND; + break; + case 'D': /* Esc [ 1 ; 4 D == Shift-Alt-Left on xterm. */ + retval = KEY_SHOME; + break; + } + } + break; +#endif case '5': if (seq_len >= 5) { switch (seq[4]) { @@ -978,6 +1044,20 @@ } } break; +#ifndef NANO_TINY + case '6': + if (seq_len >= 5) { + switch (seq[4]) { + case 'C': /* Esc O 1 ; 6 C == Shift-Ctrl-Right on xterm. */ + retval = shiftcontrolright; + break; + case 'D': /* Esc O 1 ; 6 D == Shift-Ctrl-Left on xterm. */ + retval = shiftcontrolleft; + break; + } + } + break; +#endif } } break; @@ -1158,6 +1238,7 @@ case 'b': /* Esc [ b == Shift-Down on rxvt/Eterm. */ case 'c': /* Esc [ c == Shift-Right on rxvt/Eterm. */ case 'd': /* Esc [ d == Shift-Left on rxvt/Eterm. */ + shift_held = TRUE; retval = get_escape_seq_abcd(seq[1]); break; case '[': Index: src/nano.c =================================================================== --- src/nano.c (revision 5451) +++ src/nano.c (working copy) @@ -1714,8 +1714,26 @@ } else #endif { +#ifndef NANO_TINY + /* If Shifted movement occurs, set the mark. */ + if (shift_held && !openfile->mark_set) { + openfile->mark_set = TRUE; + openfile->mark_begin = openfile->current; + openfile->mark_begin_x = openfile->current_x; + openfile->kind_of_mark = SOFTMARK; + } +#endif /* Execute the function of the shortcut. */ s->scfunc(); +#ifndef NANO_TINY + /* If Shiftless movement occurs, discard a soft mark. */ + if (openfile->mark_set && !shift_held && + openfile->kind_of_mark == SOFTMARK) { + openfile->mark_set = FALSE; + openfile->mark_begin = NULL; + edit_refresh_needed = TRUE; + } +#endif #ifndef DISABLE_COLOR if (f && !f->viewok && openfile->syntax != NULL && openfile->syntax->nmultis > 0) @@ -2718,6 +2736,16 @@ controlleft = key_defined(tigetstr("kLFT5")); if ((int)tigetstr("kRIT5") > 0) controlright = key_defined(tigetstr("kRIT5")); + /* Ask for the codes for Shift+Control+Left and Shift+Control+Right. */ + if ((int)tigetstr("kLFT6") > 0) + shiftcontrolleft = key_defined(tigetstr("kLFT6")); + if ((int)tigetstr("kRIT6") > 0) + shiftcontrolright = key_defined(tigetstr("kRIT6")); + /* Ask for the codes for Shift+Alt+Left and Shift+Alt+Right. */ + if ((int)tigetstr("kLFT4") > 0) + shiftaltleft = key_defined(tigetstr("kLFT4")); + if ((int)tigetstr("kRIT4") > 0) + shiftaltright = key_defined(tigetstr("kRIT4")); #endif #ifdef DEBUG