From: David Lawrence Ramsey Date: Sun, 2 Jan 2005 21:26:53 +0000 (+0000) Subject: implement verbatim input for the statusbar prompt X-Git-Tag: v1.3.6~187 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=11c83d3ed327dbf7c08578ca2a2e23704605f81e;p=nano.git implement verbatim input for the statusbar prompt git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2215 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 22d53577..2c191bc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -83,6 +83,9 @@ CVS code - is disabled when NANO_SMALL is defined. (DLR, based on ideas from a patch for Pico by Eduardo Chappa, suggested by Ryan Dlugosz and Paul Adams) + - Implement verbatim input for the statusbar prompt. Changes to + do_statusbar_input(); new function + do_statusbar_verbatim_input(). (DLR) - cut.c: do_cut_text() - If keep_cutbuffer is FALSE, only blow away the text in the @@ -184,6 +187,9 @@ CVS code - obsolete and it defines a struct termio that we don't use anywhere. (DLR) - Typo fixes. (DLR) +- doc/faq.html: + - Remove now-inaccurate note about verbatim input's not working + at prompts. (DLR) - doc/nanorc.sample: - Add return to the "c-file" regexes. (DLR) diff --git a/TODO b/TODO index d8169416..bb04eb13 100644 --- a/TODO +++ b/TODO @@ -8,8 +8,7 @@ For version 1.4: - Support for filename searches in the file browser. - Undo/Redo key? - Rebindable keys? -- Keystroke to implement "Add next sequence as raw" like vi's ^V. - [DONE for edit window, needs to be done for statusbar prompt] +- Keystroke to implement "Add next sequence as raw" like vi's ^V. [DONE] - Spell check selected text only. [DONE] - Make "To Line" (^W^T) and "Read from Command" (^R^X) reenter their parent menu when their keystroke is entered a second time (^W^T^T and diff --git a/doc/faq.html b/doc/faq.html index 05f84fa4..fa7a55db 100644 --- a/doc/faq.html +++ b/doc/faq.html @@ -166,8 +166,7 @@

You can move between the buffers you have open with the Meta-< and Meta-> keys, or more easily with Meta-, and Meta-. (clear as mud, right? =-). When you have more than one file buffer open, the ^X shortcut will say "Close", instead of the normal "Exit" when only one buffer is open.

3.8. Tell me more about this verbatim input stuff!

To use verbatim input, you must be using nano 1.3.1 or newer. When you want to insert a literal character into the file you're editing, such as a control character that nano usually treats as a command, first press Meta-V. (If you're not at a prompt, you'll get the message "Verbatim input".) Then press the key(s) that generate the character you want.

-

Alternatively, you can press Meta-V and then type a three-digit ASCII code from 000 to 255, and the character with that ASCII code will be inserted instead.

-

NOTE: Verbatim input doesn't work at prompts right now. This will be fixed soon.

+

Alternatively, you can press Meta-V and then type a three-digit ASCII code from 000 to 255, and the character with that ASCII code will be inserted instead.

3.9. How do I make a .nanorc file that nano will read when I start it?

It's not hard at all! But, your version of nano must have been compiled with --enable-nanorc, and again must be version 1.1.12 or newer (use nano -V to check your version and compiled features). Then simply copy the nanorc.sample that came with the nano source or your nano package (most likely in /usr/doc/nano) to .nanorc in your home directory. If you didn't get one, the syntax is simple. Flags are turned on and off by using the word set and the getopt_long flag for the feature, for example "set nowrap" or "set suspend".


@@ -245,6 +244,7 @@

8. ChangeLog

+2005/01/02 - Remove now-inaccurate note about verbatim input's not working at prompts. (DLR) 2004/11/21 - List sh as an example of a Bourne shell. (DLR) 2004/11/05 - Fixed inaccuracy: Pico compatibility mode was made the default in nano 1.1.99pre1, not 1.2.2. Also added question about how to type F13-F16 on terminals lacking keys past F12 (suggested by Chris), question about how to select text for the clipboard in X terminals with nano's mouse support turned on (answer found by Joseph Birthisel), and misc. fixes and link updates. (DLR)
2004/04/07 - Removed NumLock glitch question, as it's no longer needed. (DLR)
diff --git a/src/proto.h b/src/proto.h index 7c632343..c5d7eb60 100644 --- a/src/proto.h +++ b/src/proto.h @@ -582,6 +582,7 @@ void do_statusbar_left(void); void do_statusbar_backspace(void); void do_statusbar_delete(void); void do_statusbar_cut_text(void); +void do_statusbar_verbatim_input(void); void do_statusbar_output(int *kbinput, size_t kbinput_len); size_t xplustabs(void); size_t actual_x(const char *str, size_t xplus); diff --git a/src/winio.c b/src/winio.c index d7d49753..23f5fe3a 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1651,7 +1651,8 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t, input == NANO_HOME_KEY || input == NANO_END_KEY || input == NANO_FORWARD_KEY || input == NANO_BACK_KEY || input == NANO_BACKSPACE_KEY || input == NANO_DELETE_KEY || - input == NANO_CUT_KEY); + input == NANO_CUT_KEY || (*meta_key == TRUE && + input == NANO_VERBATIM_KEY)); /* Set s_or_t to TRUE if we got a shortcut. */ *s_or_t = have_shortcut; @@ -1728,6 +1729,16 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t, currshortcut != writefile_list) do_statusbar_cut_text(); break; + case NANO_VERBATIM_KEY: + if (*meta_key == TRUE) { + /* If we're using restricted mode, the filename + * isn't blank, and we're at the "Write File" + * prompt, disable verbatim input. */ + if (!ISSET(RESTRICTED) || filename[0] == '\0' || + currshortcut != writefile_list) + do_statusbar_verbatim_input(); + break; + } /* Handle the normal statusbar prompt shortcuts, setting * finished to TRUE to indicate that we're done after * running or trying to run their associated @@ -1821,6 +1832,20 @@ void do_statusbar_cut_text(void) statusbar_xend = 0; } +void do_statusbar_verbatim_input(void) +{ + int *kbinput; /* Used to hold verbatim input. */ + size_t kbinput_len; /* Length of verbatim input. */ + + /* Read in all the verbatim characters. */ + kbinput = get_verbatim_kbinput(bottomwin, &kbinput_len); + + /* Display all the verbatim characters at once. */ + do_statusbar_output(kbinput, kbinput_len); + + free(kbinput); +} + void do_statusbar_output(int *kbinput, size_t kbinput_len) { size_t i;