Commit Graph

41 Commits (0363703073afe35579476e5dc8d3e3df5d7735de)

Author SHA1 Message Date
Benno Schulenberg 0363703073 new feature: option --zero for an interface without bars
With --zero or 'set zero', nano will hide the title bar or the minibar
(whichever is active) and will use all rows of the terminal for showing
the text of the buffer.  Only when there is an important message will
it be shown on the bottom row -- until the next keystroke.

This feature can be toggled with M-Z.

The feedback at startup ("Read nnn lines") is suppressed with --zero,
because it disrupts the fullscreen experience (and is hardly useful).
The "Reading..." message then needs to be suppressed too, otherwise
it creates an annoying little flash.

There are still some issues that need to be addressed:

* In the browser, when the highlighted item is on the bottom row, it
  will get obscured by the prompt bar or the "Search Wrapped" message.

* In the edit window, when the search occurrence is on the bottom row,
  it can get obscured by the "This is the only occurrence" message.

* When tabbing at a prompt shows possible completions, they are shown
  a row too low.
2021-11-09 11:50:40 +01:00
Benno Schulenberg f9468fa987 history: process file faster by not filtering out hypothetical duplicates
When the history file has been created by nano, it will not contain
any duplicate search or replace strings, nor duplicate commands, so
checking for such a duplicate for each read item was a waste of time.

And if the user edited the history file and created duplicates, who
are we to filter them out?  They will not cause the history mechanism
to malfunction; they just take a little extra memory.
2021-10-14 09:58:07 +02:00
Benno Schulenberg 61b3aa6626 tweaks: use five symbolic names, to make eight function calls clearer 2021-09-29 15:35:18 +02:00
Benno Schulenberg 189960c467 cutting: copy anchors into the cutbuffer, so that undo can restore them
When a segment of text is extracted, copy any anchors that it has
into the cutbuffer, so that they get saved in the undo item, so that
an undo will put these anchors back on the lines where they were,
instead of leaving an inherited anchor at the top of the segment.

And when text is pasted, clear any anchors in it, so that they will
not travel nor multiply.

This fixes https://savannah.gnu.org/bugs/?61162.

Bug existed since version 5.0, since anchors were introduced.
2021-09-19 11:29:39 +02:00
Benno Schulenberg 650dc14e0f tweaks: rename a defined type, to fit within the general pattern
So that it can be colorized as a type by a general syntax rule.

(The name is now uglier than it was, but... alas.)
2021-09-11 18:05:03 +02:00
Benno Schulenberg 47c8e627f4 build: help Haiku find the header files that define mkstemps()
The documentation (https://www.haiku-os.org/docs/api/libroot.html)
says that BSD extensions are enabled by default, but somehow this
does not seem to be the case on my system.  With _DEFAULT_SOURCE
defined, though, src/files.c now compiles fine.
2021-08-22 11:42:34 +02:00
Benno Schulenberg e2e8bf0a3e options: accept 'set minicolor' for setting the color of the minibar
When it is not specified, it defaults to the value for 'titlecolor'.

When not using --minibar, I want the title bar to be blue (as that is
how I've always had it), but with --minibar, I want this mini bar to
be grey, as otherwise it reminds me too much of the prompt bar.

Also, colorize 'set minicolor' as valid in a nanorc file.
2021-06-08 09:25:02 +02:00
Benno Schulenberg c96e62e33a startup: save the compiled file-matching regexes, to avoid recompiling
This reduces startup time by seven percent (when using the standard set
of syntaxes) when opening just one file that doesn't match any syntax,
and more than ten percent when opening multiple files.  It takes some
extra memory, but... not wasting CPU cycles is more important.

This addresses https://savannah.gnu.org/bugs/?56433.
2021-04-24 10:54:04 +02:00
Benno Schulenberg 49d8b99e4f softwrap: avoid time-consuming computations, to burden large files less
Whenever softwrap was toggled on or line numbers were toggled on/off or
the window was resized, the extra rows per line needed to be recomputed
for ALL the lines.  For large files with many long lines this was too
costly.

(This change causes the indicator to have an incorrect size when there
are many softwrapped chunks onscreen, but that will be addressed later.)

This fixes https://savannah.gnu.org/bugs/?60429.

Problem existed since version 5.0, since the indicator was introduced.
2021-04-21 16:40:20 +02:00
Benno Schulenberg 5efb6836a8 options: retire the obsolete 'smooth', 'morespace', and 'nopauses' 2021-04-15 11:43:39 +02:00
Benno Schulenberg debb288115 tweaks: reduce the maximum character length from six bytes to four
In UTF-8 valid multibyte characters are at most four bytes long,
and now that we no longer make use of mblen() and mbtowc() from
the underlying system, we won't get five- or six-byte sequences
mistakenly reported as valid (by glibc).  So it is always enough
to reserve space for just four bytes per character.
2021-04-07 17:21:25 +02:00
Benno Schulenberg 77da54c6c6 startup: do not store an error message in the record of another buffer
Set the 'format' of a file only when it has been fully read in,
so that this field can be used to indicate that any later error
message cannot be meant for this buffer.

This fixes https://savannah.gnu.org/bugs/?60269.

Bug existed since commit 6bf52dcc from yesterday.
2021-03-23 16:19:07 +01:00
Benno Schulenberg ede64d7ea0 feedback: upon first switch to a buffer, show its error message (if any)
When opening multiple files and some of them had an error, only the
first message was shown and the others were lost -- indicated only
by three dots.  Improve upon this by storing the first error message
for each buffer and showing this message when the buffer is first
switched to.

Requested-by: Mike Frysinger <vapier@gentoo.org>
2021-03-21 16:52:29 +01:00
Benno Schulenberg a9ccd99b90 tweaks: rename a symbol, to better match the corresponding option 2021-03-03 09:39:49 +01:00
Benno Schulenberg 87fe73ddaa color: give highlighted text its own color, to not look like marked text
Now that a search match gets highlighted, the unsuspecting user might
think that the text is selected, because it is colorized the same way
as selected text.  Avoid this by colorizing a highlighted search match
with its own specific color, black on yellow by default.
2021-02-14 12:51:09 +01:00
Benno Schulenberg 7bf253702e options: remove --markmatch and 'set markmatch', as the behavior is gone 2021-02-07 09:18:15 +01:00
Benno Schulenberg 3ea2694d9c tweaks: rename six symbols, to be more straightforward 2021-01-28 16:11:57 +01:00
Benno Schulenberg 6360e4170a copyright: update the years for the FSF 2021-01-11 14:22:51 +01:00
Benno Schulenberg d0bceb1449 options: add --markmatch and -^ for activating the select-match behavior
And add, of course, the 'set markmatch' nanorc option.
2020-12-24 11:49:22 +01:00
Benno Schulenberg b86f7868d1 feedback: differentiate between remarks, mistakes, and information
Remarks are about unsurprising things but it's good to give feedback
on them; "mistakes" are unexpected things, and get colored like an
error; and information is something that the user requested and thus
needs to stay on the status bar until the next keystroke.
2020-12-23 12:17:06 +01:00
Benno Schulenberg d31cc373de display: add code for showing minimal state-information bar at the bottom
When activated, it suppresses the title bar, and suppresses feedback
on the status bar for toggles whose effect is obvious or whose state
is already shown in the minibar.

This addresses https://savannah.gnu.org/bugs/?58152,
and addresses https://savannah.gnu.org/bugs/?58789.
2020-12-23 12:17:05 +01:00
Benno Schulenberg 96e4fec31c tweaks: use a boolean instead of an enumeration of two values 2020-12-19 16:40:21 +01:00
Benno Schulenberg 89e84e76c3 build: fix compilation when configured with --enable-tiny
The BACK and DEL symbols are used as parameters for do_deletion().
2020-12-09 16:27:34 +01:00
Benno Schulenberg b87d7f69fc options: accept 'set promptcolor' for setting the color of the prompt bar
When it is not specified, it defaults to the value for 'titlecolor'.
2020-12-06 16:34:42 +01:00
Benno Schulenberg c6501beba7 tweaks: reshuffle some more lines, to have most #defines together 2020-12-06 12:30:52 +01:00
Benno Schulenberg dbf522b750 tweaks: reshuffle some lines, to have most #includes near the beginning 2020-12-06 11:49:37 +01:00
Benno Schulenberg 651e97ceef tweaks: reshuffle some lines, to group things better 2020-12-06 11:40:25 +01:00
Benno Schulenberg 7ebf5f52b8 tweaks: clean up after the previous change 2020-12-05 12:12:11 +01:00
Benno Schulenberg 4f7593b704 general: remove support for Slang
Slang has too many bugs to be useful.

This addresses https://savannah.gnu.org/bugs/?59210.
2020-12-05 11:57:08 +01:00
Benno Schulenberg b7539ea985 weeding: remove a workaround for versions of ncurses before 5.9
(Yes, the test is for 6.0, but the bug was actually fixed in 5.9,
as far as I remember -- I just wasn't sure and didn't want to bother
building different versions of ncurses myself.)
2020-11-15 10:27:22 +01:00
Benno Schulenberg e1601d2eb5 tweaks: use the standard symbols for the three standard file descriptors
Also, take into account (as elsewhere) that dup2() could fail,
and harmonize their error checks.
2020-10-10 12:32:02 +02:00
Benno Schulenberg cbf6fd021a tweaks: remove an usused element from 'funcstruct', saving 8 more bytes 2020-09-28 11:57:03 +02:00
Hussam al-Homsi b093d19262 tweaks: reorder a member of 'funcstruct', to save 8 bytes of padding
Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2020-09-28 11:57:03 +02:00
Benno Schulenberg 58a3293efc options: require --magic or 'set magic' to enable the use of libmagic
Trying to determine which syntax to apply with the help of libmagic
can be a somewhat time-consuming and yet often still fruitless affair.
Therefore using libmagic should not be the default; it should require
an option to tell nano to try using libmagic when it can't determine
the applicable syntax from the file's name or first line.

This is better than having a --nomagic option (and using libmagic by
default), because when the user has 'set nomagic' in their nanorc or
--nomagic in their alias, then switching the use of libmagic back on
is troublesome.  But with --magic (and not using libmagic by default),
when nano fails to recognize a file, it is a simple ^X, add -! to the
command line, and restart.

The short form of the option is -! because we have run out of letters.

This addresses https://savannah.gnu.org/bugs/?59028.
2020-09-25 16:34:01 +02:00
Benno Schulenberg d679bbc802 new feature: option --stateflags to show some states in top-right corner
With --stateflags (short form: -%) or 'set stateflags', nano reserves
the righthand end of the title bar not for showing "Modified" but for
showing the state of auto-indentation (I), the mark (M), the breaking
of long lines (L), macro recording (R), and softwrapping (S).

When the buffer is modified, this is indicated with a star (*) after
the file name (shown in the center of the title bar).

This fulfills https://savannah.gnu.org/bugs/?57953.
Requested-by: Sébastien Desreux <seb@h-k.fr>
2020-09-23 19:48:03 +02:00
Benno Schulenberg 9709dfd563 tweaks: rename two elements of history struct, away from abbreviations 2020-09-22 10:12:43 +02:00
Benno Schulenberg cf4901da2d suspension: do not enter an invalid byte upon resume (when using Slang)
Instead of stuffing 0x91 into the input stream, use 0xFF when built
with Slang -- the same code that Slang itself produces when resuming
from an externally induced suspension.  This byte is ignored.

In a UTF-8 locale, it should be safe to ignore the byte 0xFF coming
from the keyboard, as no valid UTF-8 sequence can contain 0xFF.

In an ISO8859 locale, this change prevents ÿ from being typed on the
keyboard -- it can still be entered with <Esc> <Esc> 255, though.
My apologies to the people of Pierre Louÿs and L'Haÿ-les-Roses.
2020-09-07 17:09:57 +02:00
Benno Schulenberg 46e769a113 rcfile: add 'set scrollercolor', for changing the color of the indicator
This fulfills https://savannah.gnu.org/bugs/?59041.
2020-09-02 19:55:24 +02:00
Hussam al-Homsi c87bc1d55f tweaks: stop casting the return of malloc() and friends
Those casts are redundant, and sometimes ugly.  And as the types of
variables are extremely unlikely to change any more at this point,
the protection they offer against miscompilations is moot.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2020-08-31 12:17:27 +02:00
Benno Schulenberg 712f68c697 options: add -O/--bookstyle to make leading whitespace mean new paragraph
Before version 2.9.8, nano would consider any line that started with
leading whitespace as the beginning of a new paragraph, and would thus
be unable to justify an indented piece of text (unless autoindent was
switched on).  I thought that this was too limiting and changed the
way nano detects and parses paragraphs.  It works fine in texts where
paragraphs occupy multiple lines, but breaks down for paragraphs of
a single line: nano merges those with adjoining lines.

Now, when -O or --bookstyle or 'set bookstyle' is used, nano will again
consider a line that begins with whitespace as the start of a paragraph
-- when 'autoindent' is OFF.

This addresses https://savannah.gnu.org/bugs/?57402.
Indirectly-reported-by: Sébastien Desreux <seb@h-k.fr>
Also-reported-by: Bill Kendrick <nbs@sonic.net>
2020-06-27 11:12:21 +02:00
Benno Schulenberg 90f6342fd1 tweaks: rename two header files, to be distinct and not an abbreviation 2020-06-20 12:09:31 +02:00