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,9 +38,19 @@ /* 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. */ +int controlleft = CONTROL_LEFT; +int controlright = CONTROL_RIGHT; +int shiftcontrolleft = 0x402; +int shiftcontrolright = 0x403; + +int shifthome = 0x404; +int shiftend = 0x405; + #ifndef DISABLE_WRAPJUSTIFY ssize_t fill = 0; /* The column where we will wrap lines. */ 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,8 +33,18 @@ extern bool meta_key; extern bool func_key; +extern bool shift_held; + extern bool focusing; +extern int controlleft; +extern int controlright; +extern int shiftcontrolleft; +extern int shiftcontrolright; + +extern int shifthome; +extern int shiftend; + #ifndef DISABLE_WRAPJUSTIFY extern ssize_t fill; extern ssize_t wrap_at; Index: src/winio.c =================================================================== --- src/winio.c (revision 5426) +++ src/winio.c (working copy) @@ -137,7 +137,7 @@ } else #endif errcount++; - +beep(); /* If we've failed to get a character MAX_BUF_SIZE times in a * row, assume that the input source we were using is gone and * die gracefully. We could check if errno is set to EIO @@ -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. */ @@ -571,14 +579,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 @@ -634,23 +647,27 @@ retval = ERR; break; #endif - case CONTROL_LEFT: #ifndef NANO_TINY - retval = sc_seq_or(do_prev_word_void, 0); -#endif - break; - case CONTROL_RIGHT: -#ifndef NANO_TINY - retval = sc_seq_or(do_next_word_void, 0); -#endif - break; -#ifndef NANO_TINY case KEY_WINCH: retval = KEY_WINCH; break; #endif } +#ifndef NANO_TINY + if (retval == controlleft) + 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); + } +#endif + /* If our result is an extended keypad value (i.e. a value * outside of byte range), set func_key to TRUE. */ if (retval != ERR) @@ -696,6 +713,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 +978,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; } @@ -981,6 +1000,18 @@ } } break; + 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; } } break; @@ -1161,6 +1192,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) @@ -2707,6 +2724,35 @@ interface_color_pair[FUNCTION_TAG].bright = FALSE; #endif +#ifndef USE_SLANG +if ((int)tigetstr("kLFT6") > 0) + shiftcontrolleft = key_defined(tigetstr("kLFT6")); +else + define_key("kLFT6", shiftcontrolleft); + +if ((int)tigetstr("kRIT6") > 0) + shiftcontrolright = key_defined(tigetstr("kRIT6")); +else + define_key("kRIT6", shiftcontrolright); + +if ((int)tigetstr("kHOM") > 0) + shifthome = key_defined(tigetstr("kHOM")); +else + define_key("kHOM", shifthome); + +if ((int)tigetstr("kEND") > 0) + shiftend = key_defined(tigetstr("kEND")); +else + define_key("kEND", shiftend); +#endif + +#ifndef USE_SLANG +if ((int)tigetstr("kLFT5") > 0) + controlleft = key_defined(tigetstr("kLFT5")); +if ((int)tigetstr("kRIT5") > 0) + controlright = key_defined(tigetstr("kRIT5")); +#endif + #ifdef DEBUG fprintf(stderr, "Main: open file\n"); #endif