nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G)


From: Benno Schulenberg
Subject: Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G)
Date: Tue, 15 Nov 2016 15:08:00 +0100

With your patch applied, run 'src/nano NEWS' and then
type: ^G ^W and resize the window. See how the titlebar
now says something like "File: /tmp/nano.RYxXxw".

Now make the window narrower and narrower.  See how the
help text does not get rewrapped.  It should -- it does
without your patch.


On Mon, Nov 14, 2016, at 13:04, Rishabh Dave wrote:
> I also renamed it to saved_answer (just
> like margin_copy was renamed to saved_margin).

Good.  You are beginning to get it.  :)
Do the same for prompt_save.

> I have added 2 comments in src/help.c. I think rest are either too
> short, self-explanatory or both.

Hmm.  I will add some more later.

More details:

     add_to_funcs(total_refresh, MHELP, refresh_tag, "x", 0, VIEW);
 
+    add_to_funcs(do_search, MHELP,
+       whereis_tag, IFSCHELP(nano_whereis_msg), TOGETHER, VIEW);
+    add_to_funcs(do_research, MHELP,
+       whereis_next_tag, IFSCHELP(nano_whereis_next_msg), TOGETHER, VIEW);
+
     add_to_funcs(do_up_void, MHELP, prev_line_tag, "x", 0, VIEW);
     add_to_funcs(do_down_void, MHELP, next_line_tag, "x" , 0, VIEW);

Look at the surrounding items.  The help menu itself does not
have any help, that's why "x" and 0 are used for those funcs.

+    add_to_sclist(MFINDINHELP, "^I", 0, do_tab, 0);
+    add_to_sclist(MFINDINHELP, "Tab", TAB_CODE, do_tab, 0);
+    add_to_sclist(MFINDINHELP, "^M", 0, do_enter, 0);
+    add_to_sclist(MFINDINHELP, "Enter", KEY_ENTER, do_enter, 0);
+    add_to_sclist(MFINDINHELP, "^H", 0, do_backspace, 0);
+    add_to_sclist(MFINDINHELP, "Bsp", KEY_BACKSPACE, do_backspace, 0);
+    add_to_sclist(MFINDINHELP, "^D", 0, do_delete, 0);
+    add_to_sclist(MFINDINHELP, "Del", 0, do_delete, 0);

Merge these into the MMOST lines that follow below after it.

+    /* Extract title from help_text and display it. */

The fragment of code does not actually display the title;
it just extracts it.

+    ptr += line_size;
+    while (*ptr == '\n')
+       ++ptr

This then skips the title.  Separate block, add a comment.

+       while (*ptr == '\n') {
+           fwrite("\n", sizeof(char), 1, fp);
+           ++ptr;
+       }

Shorter:

        while (*ptr == '\n')
            fwrite(ptr++, sizeof(char), 1, fp);


+           do_last_line();
        } else if (func == do_exit) {
            /* Exit from the help viewer. */
+           close_buffer();

Keep the exit part close to the end of the routine;
put the search and re-search before it.

+           do_research();
+           bottombars(MHELP);
+           wnoutrefresh(bottomwin);

Why does the bottombar need to be refreshed after a
re-search?  I think restoring currmenu = MHELP should
be enough.

Benno

-- 
http://www.fastmail.com - Accessible with your email software
                          or over the web




reply via email to

[Prev in Thread] Current Thread [Next in Thread]