9997 Commits

Author SHA1 Message Date
Benno Schulenberg
fdd946c02c files: do not change to a higher directory when the working one is gone
When the working directory has been deleted from under nano's feet,
get_full_path() would move up in the directory tree until getcwd()
would succeed.  This meant that a filename that was specified on the
command line without any path (or with a relative path) would refer
to a different file than what the user intended.  Not good.

So, stop changing directories in get_full_path().  Use the realpath()
function with NULL as second parameter instead -- it has been part of
the POSIX standard since 2008, time enough for operating systems to
have caught up.

In the bargain, this saves seventy lines of complicated logic.

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

Bug existed since version 2.0.0, commit 85e35e67.
2022-04-04 12:52:35 +02:00
Benno Schulenberg
81e5b57d74 syntax: xml: colorize user-defined entities differently
Also improve two comments.
2022-04-04 12:08:23 +02:00
Benno Schulenberg
b568705eec syntax: xml: colorize /> properly, and colorize prolog tags differently
Use lightgrey for the prolog tags, as they normally are unimportant
boiler-plate stuff.  Comments are likely to be more relevant.

Any /> is part of the tag itself, not of the attributes.
2022-04-04 10:01:49 +02:00
Benno Schulenberg
fe42eb7a1a painting: stop coloring an extremely long line after 2000 bytes
Especially when softwrapping and when multiline regexes are involved,
colorizing takes roughly exponential time relative to the line length.
To avoid bogging down, stop colorizing a line beyond a certain point.

This mitigates https://savannah.gnu.org/bugs/?61799.
Reported-by: Devin Hussey <husseydevin@gmail.com>
2022-04-03 12:28:22 +02:00
Benno Schulenberg
df7b0a6d97 execute: clear an anchor only when the whole buffer gets filtered
Although an anchor at the top line is rather pointless, it shouldn't
get cleared when the user pipes just a part of the buffer through an
external command.
2022-03-28 11:38:22 +02:00
Benno Schulenberg
fcf598e797 execute: stay on the same line number when filtering the whole buffer
When the filter command makes just small, per-line changes, keeping the
cursor at the same line number allows the user to observe the effect of
the changes -- which is not possible when the cursor gets moved to the
end of the buffer.

This partially fulfills https://savannah.gnu.org/bugs/?57248.
2022-03-28 11:15:04 +02:00
Benno Schulenberg
d9cb12f6e3 tweaks: move the saving and restoring of flags to where it is needed 2022-03-27 18:44:48 +02:00
Benno Schulenberg
0f23729253 tweaks: prevent the adding of an unwanted newline in a different way
The prevention is needed only for temporary files, not for normal files.
2022-03-27 18:20:17 +02:00
Benno Schulenberg
3def429290 tweaks: don't leave an orphaned temporary file behind when writing fails 2022-03-27 12:37:01 +02:00
Benno Schulenberg
803ea0d7a0 justify: stay at the same line number when doing a full justification
The same line number may not be the same position in the text, but
it will be approximately -- and it is certainly better than leaving
the cursor at the end of the buffer.

This fulfills https://savannah.gnu.org/bugs/?61175.
2022-03-24 17:05:55 +01:00
Benno Schulenberg
9b014876cd tweaks: trim a few comments, rename a function, and reshuffle some code 2022-03-20 13:20:31 +01:00
Benno Schulenberg
9ccf85eaa8 tweaks: avoid a function call when two plain assignments will do 2022-03-18 11:40:03 +01:00
Benno Schulenberg
93fa53c3e8 tweaks: elide an unneeded call of strlen() 2022-03-18 11:36:10 +01:00
Benno Schulenberg
eea3e1f0b2 tweaks: make the triggering of the recalculation of multidata less eager
Also, trigger recalculation when an undo or redo causes a large enough
forward jump.
2022-03-18 11:29:18 +01:00
Benno Schulenberg
e6e22ea976 tweaks: normalize the indentation after the previous change 2022-03-17 14:09:09 +01:00
Benno Schulenberg
80c2000f87 tweaks: simplify a bit of code, eliding two labels and three gotos 2022-03-17 14:09:09 +01:00
Benno Schulenberg
15a0a129c8 painting: recalculate the multidata when making large strides or changes
When making a forward movement larger than a screenful, we cannot rely
on the multidata of the line before the new screen start to have been
set correctly by a previous screen drawing, so we need to recompute all
of the multidata, for the whole buffer, so that afterward we can freely
move around and draw the screen without having to do any backtracking.

Also when a piece of text larger than a screenful is pasted or inserted,
all the multidata needs to be recomputed.

This fixes https://savannah.gnu.org/bugs/?60041,
and fixes https://savannah.gnu.org/bugs/?62056.

First bug existed in this form since version 2.4.2, commit d49c267f
(but editing Python was incomparably slower in those days).

Second bug existed since version 5.6, commit 43d94692.
2022-03-17 14:07:42 +01:00
Benno Schulenberg
51bd04b541 painting: colorize text also after an unterminated start match
This does not waste time looking for an end match, which is especially
wasteful when there is none.  Also, it makes the coloring behavior more
consistent: any start match will cause coloring of the subsequent text,
no matter whether the user is in the middle of the file or near the end.
2022-03-14 09:12:55 +01:00
Benno Schulenberg
18ba7f60c1 painting: tighten the check for a lacking end match on a colored line
As it's possible for the start regex to match what is actually the end
match of a multiline thing (see the Python triple quotes, for example),
make sure that such a detected start match is *not* an end match, just
to avoid a needless full-screen refresh.
2022-03-08 09:47:36 +01:00
Benno Schulenberg
5c3e00d70a build: remove an obsolete check -- the dependent code was deleted
The code fragment that was conditionalized on REDEFINING_MACROS_OK
was deleted five weeks ago in commit 3f494e35.
2022-03-07 18:09:51 +01:00
Benno Schulenberg
6c4c77971e build: add the --disable-maintainer-mode option to ./configure
By passing --disable-maintainer-mode to ./configure the user can disable
autoconf build rules that would cause configure to be rebuilt and rerun.

Kind-of-requested-by: Mike Frysinger <vapier@gentoo.org>
2022-03-07 17:26:30 +01:00
Benno Schulenberg
67adef8f6c display: suppress spotlight yellow and error red when NO_COLOR is set
This makes nano conform to the https://no-color.org/ idea: suppressing
any color in the output (in the default setup) when NO_COLOR is set in
the environment.

Specifying a color for any interface element will, however, re-enable
also yellow for the spotlight and red for error messages.
2022-03-06 17:03:42 +01:00
Benno Schulenberg
ed60e16974 tweaks: exclude the extra truncation warning from the tiny version 2022-03-04 12:12:48 +01:00
Benno Schulenberg
47c11ae83d feedback: show extra warning when writing failed due to "No space left"
This mitigates https://savannah.gnu.org/bugs/?36864.
Reported-by: Clarence Risher <sparr0@gmail.com>

Problem has existed since the beginning, as nano empties the existing
file before writing the current buffer contents into it.
2022-03-03 11:12:41 +01:00
Mike Frysinger
8173b1bfbe general: fix building for Windows
Fix building with x86_64-w64-mingw32 to cross-compile native Windows
programs.  Need to:

  * add checks for missing functions
  * don't use signals that are unavailable on the platform
  * avoid useless non-Linux sys/ioctl.h include
  * use putenv instead of setenv as the latter is unavailable
2022-03-01 11:05:07 +01:00
Benno Schulenberg
93400ec8a1 execute: don't crash when an empty buffer is piped through a command
That is, take into account that the cutbuffer could be NULL
(when updating the undo item).

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

Bug existed since version 4.9, commit b15c5a7e.
2022-02-24 16:50:18 +01:00
Benno Schulenberg
0d85a798e5 painting: look for another start match only after the actual end match
The 'endmatch.rm_eo' value is relative to the end of the start match,
so to find the end of the end match, one has to add 'startmatch.rm_eo'
plus 'endmatch.rm_eo' to the starting point of the line.

This addresses https://savannah.gnu.org/bugs/?62091.

Problem existed since version 5.6, commit 0596b875.
2022-02-21 10:46:28 +01:00
Benno Schulenberg
d4d534925f po: update translations and regenerate POT file and PO files v6.2 2022-02-18 10:58:47 +01:00
Benno Schulenberg
a1ba7ee786 bump version numbers and add a news item for the 6.2 release 2022-02-18 10:44:22 +01:00
Benno Schulenberg
756cd4a4b8 tweaks: store a result, to avoid calling a function twice 2022-02-18 10:27:47 +01:00
Benno Schulenberg
1b186fcff3 tweaks: rename two more variables, and drop unneeded initializations
Also, make sure that there is a space in the complaint so that the
later strstr() call cannot fail.  And reshuffle a line.
2022-02-17 14:20:45 +01:00
Benno Schulenberg
165da9b447 tweaks: rename a variable, reshuffle five lines, and snip two comments 2022-02-17 14:00:55 +01:00
Benno Schulenberg
aea10ed383 tweaks: rename two variables (to get rid of a prefix), and elide a third 2022-02-17 13:57:22 +01:00
Benno Schulenberg
8fccb31436 linter: adjust the parsing to accommodate for a modern 'pyflakes'
In version 2.2.0, pyflakes changed its output format,
from 'filename:line: text' to 'filename:line:column text'.

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

Problem existed since version 2.9.0, commit 5dcf375f.

(That commit tried to compensate for an introductory message from gcc
that no longer seems to exist.)
2022-02-16 15:39:01 +01:00
Benno Schulenberg
89bb88e4f5 syntaxes: fold a couple of regexes together, and improve a few comments 2022-02-16 13:07:11 +01:00
Benno Schulenberg
a58efa70bc tweaks: consistently backslash-escape the dash in M-letter keystrokes 2022-02-16 12:19:31 +01:00
Benno Schulenberg
fe1fecc5da tweaks: rename a variable, to be more correct, and adjust two comments
The new name 'gauge' more clearly indicates that it is a distance
between two "columns", two "pillars", two "piles".  Using 'longest'
was poor, because in fact it was set to 'widest + 10'.

(Also, change the type of 'piles' to an integer -- it will always
be smaller than COLS, and COLS is an integer.)
2022-02-13 13:07:52 +01:00
Benno Schulenberg
87612582ff tweaks: use an intermediate variable, to avoid using one for two purposes 2022-02-13 12:43:55 +01:00
Benno Schulenberg
c3a53cffbc tweaks: rename a variable, to be more fitting
It is about width (cells/columns), not about length (bytes).
2022-02-13 12:19:16 +01:00
Benno Schulenberg
aeea83703b tweaks: rename a misnamed variable 2022-02-13 12:04:57 +01:00
Benno Schulenberg
27c8f13fc9 tweaks: change the type of a variable, to avoid a compiler warning
A newer compiler (gcc-10.3) said: browser.c:174:34: warning:
  field width specifier '*' expects argument of type 'int'

It's fine for 'longest' to be an integer, as a filename in Unix is
at most 255 bytes long, which can occupy at most 510 columns (when
the name consists entirely of control codes), and that fits easily
within an 'int', which has at least fifteen bits, unsigned.

Well... in theory 'tabsize' could be set to an insanely high number,
and if a filename contains several tabs, this could cause 'longest'
to overflow.  (Why doesn't the compiler warn about that?)  If that
were to occur, and the filename with the tabs were the last in the
list, then 'longest' would get set to the minimum width: 15.  That
would not be correct, but... nothing bad would happen.

This addresses https://savannah.gnu.org/bugs/?62014.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2022-02-13 11:54:14 +01:00
Benno Schulenberg
c6ddae70f7 display: suppress the bottom-bar wiping only when the user is editing
This wipe suppression is meant to prevent the last row of the edit window
getting cleared when edit window and bottom window overlap, and this is
relevant only when the user is actually editing -- the file browser and
help viewer take care not to use this bottom row for content.

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

Bug existed since version 6.0, commit be61aad9.
2022-02-11 16:46:05 +01:00
Benno Schulenberg
e4ecd03e3f po: update translations and regenerate POT file and PO files v6.1 2022-02-09 11:53:47 +01:00
Benno Schulenberg
a6dc5c963c bump version numbers and add a news item for the 6.1 release 2022-02-09 11:31:03 +01:00
Benno Schulenberg
989e6a9a7e tweaks: rename two variables, and elide a near-enough duplicate
(The 'in_edit' variable was a duplicate because also when the pointer is
on the line numbers, we want to scroll when the mouse wheel is rolled.)
2022-02-04 15:51:40 +01:00
Benno Schulenberg
c28048d20f tweaks: rename another variable, to better fit in with its sisters 2022-02-04 12:17:37 +01:00
Benno Schulenberg
a24e72f972 tweaks: rename a variable, to make it clearer it refers to a window 2022-02-04 12:11:05 +01:00
Benno Schulenberg
a29aa31e93 tweaks: when discarding keycodes, don't bother parsing them 2022-02-04 11:18:52 +01:00
Benno Schulenberg
8546139997 build: fix compilation when configured with --enable-tiny
Problem existed since commit 3b657a26 from five days ago.

In addition, exclude pasting-at-the-prompt from the tiny version, as
it's hardly useful when one cannot copy a selected piece of text.
2022-02-03 13:06:21 +01:00
Benno Schulenberg
a61586947e gnulib: update to its current upstream state 2022-02-03 11:20:08 +01:00