Index: src/nano.h =================================================================== --- src/nano.h (revision 5426) +++ src/nano.h (working copy) @@ -177,6 +177,10 @@ } append_type; typedef enum { + NOMARK, 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; Index: src/global.c =================================================================== --- src/global.c (revision 5426) +++ src/global.c (working copy) @@ -38,6 +38,8 @@ /* 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. */ Index: src/files.c =================================================================== --- src/files.c (revision 5426) +++ 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 = NOMARK; openfile->fmt = NIX_FILE; Index: src/proto.h =================================================================== --- src/proto.h (revision 5426) +++ src/proto.h (working copy) @@ -33,6 +33,8 @@ extern bool meta_key; extern bool func_key; +extern bool shift_held; + extern bool focusing; #ifndef DISABLE_WRAPJUSTIFY Index: src/winio.c =================================================================== --- src/winio.c (revision 5426) +++ 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,42 @@ 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: + shift_held = TRUE; #endif + 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: + shift_held = TRUE; #endif + 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. */ @@ -571,14 +577,19 @@ * 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: + shift_held = TRUE; + retval = sc_seq_or(do_end, *kbinput); #endif - retval = sc_seq_or(do_end, *kbinput); - break; #ifdef KEY_BEG /* Slang doesn't support KEY_BEG. */ case KEY_BEG: /* Center (5) on numeric keypad with @@ -696,6 +707,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. */ @@ -960,6 +972,7 @@ 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; } @@ -1161,6 +1174,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 5426) +++ src/nano.c (working copy) @@ -1713,8 +1713,25 @@ } else #endif { + /* 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; + } + /* Execute the function of the shortcut. */ s->scfunc(); + + /* 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; + openfile->kind_of_mark = NOMARK; + edit_refresh_needed = TRUE; + } #ifndef DISABLE_COLOR if (f && !f->viewok && openfile->syntax != NULL && openfile->syntax->nmultis > 0)