Compare commits
151 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce94cb1dc6 | ||
|
|
031f255ffd | ||
|
|
e8a5665d2c | ||
|
|
65e4784eec | ||
|
|
e2051a61e0 | ||
|
|
a8fa0a82c4 | ||
|
|
d19169c263 | ||
|
|
4e7b92ed4c | ||
|
|
eaeafe29ca | ||
|
|
fe3a72ce3e | ||
|
|
6cd53e7f44 | ||
|
|
b84d7bf7a5 | ||
|
|
6840205e84 | ||
|
|
3c5e5d4b6f | ||
|
|
09ab2e3d0e | ||
|
|
5b1229599e | ||
|
|
8efdd08a86 | ||
|
|
27d2db2d1f | ||
|
|
571676eb85 | ||
|
|
9e71de12cd | ||
|
|
c7affe17c0 | ||
|
|
e21ce0db1f | ||
|
|
e6429e782a | ||
|
|
3270aac7db | ||
|
|
13615d0953 | ||
|
|
921f8ae4c9 | ||
|
|
24487d48ff | ||
|
|
388cd0b514 | ||
|
|
33c4bb22d5 | ||
|
|
6e80772311 | ||
|
|
5f00b02f7c | ||
|
|
c6bdc46bb0 | ||
|
|
bf5949395d | ||
|
|
a18b48f0f7 | ||
|
|
25e9877607 | ||
|
|
c524fbe6d0 | ||
|
|
93c8e316a8 | ||
|
|
80bea3eb9b | ||
|
|
b5ede4ff65 | ||
|
|
63b15275bd | ||
|
|
772c324f25 | ||
|
|
f1e5872e6a | ||
|
|
bc42ae42a9 | ||
|
|
6d62682ddb | ||
|
|
8d6b205e4c | ||
|
|
03f9761c35 | ||
|
|
ec339d3b08 | ||
|
|
3218d8358a | ||
|
|
a3a10dfafe | ||
|
|
850e538ff7 | ||
|
|
18419b5e3f | ||
|
|
07447f3278 | ||
|
|
fd65f74428 | ||
|
|
e40e6bbf10 | ||
|
|
2147e161bf | ||
|
|
dc079bdf31 | ||
|
|
8560a0a225 | ||
|
|
52d851a1aa | ||
|
|
2d434f63e2 | ||
|
|
5c179aae7d | ||
|
|
975b491235 | ||
|
|
94b4f07281 | ||
|
|
61b4eeda66 | ||
|
|
667fcea65e | ||
|
|
c39c9c241b | ||
|
|
115f089d5f | ||
|
|
7f6460b804 | ||
|
|
bc6787826a | ||
|
|
b5f15cb574 | ||
|
|
4c66a6259c | ||
|
|
db1893ef2d | ||
|
|
ad79a4fcfb | ||
|
|
418bd3be34 | ||
|
|
4170454837 | ||
|
|
e90b7cf4aa | ||
|
|
bb90de0eb4 | ||
|
|
157c7b1bc4 | ||
|
|
ac102a7516 | ||
|
|
d249233ea7 | ||
|
|
33fb54c75f | ||
|
|
c231b774d7 | ||
|
|
0c263bda7d | ||
|
|
60ee4408be | ||
|
|
72a590d60a | ||
|
|
9a47a9c4c0 | ||
|
|
9c8e40b442 | ||
|
|
54a4123d4c | ||
|
|
7a31507167 | ||
|
|
7f2031006a | ||
|
|
7e18b91ead | ||
|
|
f82eefa303 | ||
|
|
8e1ce7034d | ||
|
|
c4d09cc24b | ||
|
|
d04c8f88f1 | ||
|
|
a67f6c6031 | ||
|
|
8d8f5788ce | ||
|
|
4a268678a5 | ||
|
|
7c9a4793dd | ||
|
|
05592a84ec | ||
|
|
c46696d40c | ||
|
|
bfe65af6f3 | ||
|
|
46f5d51fb5 | ||
|
|
b99ec28a60 | ||
|
|
b2acffe5be | ||
|
|
2fef7f647d | ||
|
|
6d3b16b761 | ||
|
|
89c0e7493f | ||
|
|
14b9a42f5b | ||
|
|
3227ba46d9 | ||
|
|
d994af0334 | ||
|
|
75c7c35cfd | ||
|
|
eb84205426 | ||
|
|
c2593c1c5a | ||
|
|
d92142c66a | ||
|
|
f598a4f12d | ||
|
|
063a8b0870 | ||
|
|
ecc9211afc | ||
|
|
ab0897072a | ||
|
|
b2ff574678 | ||
|
|
3bac3c4c78 | ||
|
|
acadf71b13 | ||
|
|
4c02329205 | ||
|
|
a31896011a | ||
|
|
769504c495 | ||
|
|
18f13c3a75 | ||
|
|
aea54276b6 | ||
|
|
0c455155ad | ||
|
|
e6c6a72ee8 | ||
|
|
4a853cf451 | ||
|
|
078265456c | ||
|
|
3ac821ee0c | ||
|
|
ce0ecf67a6 | ||
|
|
b6f7ff5c6f | ||
|
|
035b91cb15 | ||
|
|
f456794045 | ||
|
|
20971e8392 | ||
|
|
fa454abb1c | ||
|
|
f2adefb158 | ||
|
|
7ae8f3bca4 | ||
|
|
9a7ba5db79 | ||
|
|
cc2b19c8fd | ||
|
|
430d3bad7a | ||
|
|
4e667bd048 | ||
|
|
ba2e6f43c2 | ||
|
|
6c555828c9 | ||
|
|
0ff068380c | ||
|
|
fb372ed0a8 | ||
|
|
ed433f6af0 | ||
|
|
44814055b5 | ||
|
|
71f859377d | ||
|
|
33d81fa1e6 |
172
ChangeLog
172
ChangeLog
@@ -1,3 +1,175 @@
|
||||
Changes between v3.0 and v3.1:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (13):
|
||||
bindings: bind ASCII DEL during startup instead of repeatedly at runtime
|
||||
bindings: make ^H rebindable also on NetBSD, FreeBSD and macOS
|
||||
bindings: when Ctrl+Shift+Delete has no keycode, don't use KEY_BSP
|
||||
bump version numbers and add a news item for the 3.1 release
|
||||
input: keep the cursor in edit window after message, also on NetBSD
|
||||
input: recognize the sequences for Ctrl+Shift+Delete on xterm and urxvt
|
||||
main: allow toggling all editor features when in view mode
|
||||
suspension: don't try to show the cursor position when going to sleep
|
||||
syntax: sh: let the header regex match also busybox shell scripts
|
||||
tweaks: condense a bit of code
|
||||
tweaks: remove a superfluous comment and a redundant assignment
|
||||
tweaks: rename a variable to be special and distinct
|
||||
tweaks: sharpen an optimization, to allow DEL to be a shortcut
|
||||
|
||||
Liu Hao (1):
|
||||
search: disallow switching to the Replace prompt when in view mode
|
||||
|
||||
Changes between v2.9.8 and v3.0:
|
||||
--------------------------------
|
||||
|
||||
Benno Schulenberg (113):
|
||||
bindings: bind M-Q to 'findprevious' by default, and M-W to 'findnext'
|
||||
bindings: hard-bind <Ctrl+Shift+Delete> to 'cutwordleft'
|
||||
bindings: make ^Q and M-Q available also in the help viewer
|
||||
bindings: move the noconvert toggle from the main to the insert menu
|
||||
bindings: reassign the M-| keystroke to 'cutwordleft' by default
|
||||
bindings: remove backup and new-buffer toggles (M-B, M-F) from main menu
|
||||
bindings: remove the More-Space toggle entirely
|
||||
bindings: remove the 'searchagain' function entirely
|
||||
bindings: rename two bindable functions: copytext to copy, uncut to paste
|
||||
bindings: unassign the M-? keystroke, to free it up for future use
|
||||
build: add the release script to the repository
|
||||
build: fix compilation again when configured with --enable-tiny
|
||||
build: fix compilation when configured with --enable-tiny
|
||||
build: verify that 'msgfmt' is available when building from git
|
||||
bump version numbers and add a news item for the 3.0 release
|
||||
chars: make the UTF-8 case ever so slightly faster by eliding an 'if'
|
||||
chars: speed up the counting of string length for the plain ASCII case
|
||||
chars: speed up the parsing of a character for the plain ASCII case
|
||||
completion: when the cursor is not after a word fragment, say so
|
||||
cut: concentrate the logic for clearing the cutbuffer mostly in one place
|
||||
cutting: when deleting whole words, don't join lines unexpectedly
|
||||
debug: add some code to time the performance of get_totsize()
|
||||
docs: improve a comment about rebinding <Backspace>
|
||||
docs: mention that also Ctrl increases the stride when selecting text
|
||||
docs: mention that "normal" can be used to give things the default color
|
||||
docs: mention that the 'formatter' command has been superseded
|
||||
docs: reshuffle a bindable function to a slightly better position
|
||||
docs: say that 'cutwordright' is now bound to <Ctrl+Delete> by default
|
||||
docs: slightly reword the description of four bindable functions
|
||||
docs: the 'noconvert' bindable function was renamed to 'flipconvert'
|
||||
dropping a feature: remove the ability to use the 'formatter' command
|
||||
easter: show the crawl only when there is room enough for the lines
|
||||
files: add the file format on the status bar when switching buffers
|
||||
filtering: wait for the data-sending process to terminate too
|
||||
gnulib: update to its current upstream state
|
||||
help: for ^R^X, mention that the buffer can be piped to the command
|
||||
help: move "Search Again" away from "Find Next" and "Find Previous"
|
||||
input: consume the whole escape sequence for modified PgUp and PgDn keys
|
||||
input: fully consume modified PgUp and PgDn keys also in the tiny version
|
||||
input: ignore any <Escape>s before a valid command keystroke
|
||||
input: stop <Alt+Insert> from entering "3~" into the buffer
|
||||
input: stop a modified Delete key from entering stuff into the buffer
|
||||
mouse: put the row/column arguments in the proper order [coverity scan]
|
||||
prompt: concentrate manipulations of 'statusbar_x' into a single file
|
||||
prompt: remove redundant redrawings of the prompt bar
|
||||
rcfile: allow to rebind the Cancel function in the yesno menu
|
||||
rcfile, docs: no longer recognize nor mention 'set backwards'
|
||||
rcfile: do not accept rebinding F0 nor function keys above F16
|
||||
rcfile: ensure that in the yesno menu Cancel is bound to some keystroke
|
||||
rcfile: explicitly check for disallowed keywords in included files
|
||||
rcfile: reject things like "M-Del" and "^{" as invalid key names
|
||||
rcfile: when a vital function is not mapped, mention in which menu
|
||||
search: include 'findprevious' and 'findnext' in the tiny version
|
||||
signals: don't call a print routine in a signal handler
|
||||
speller: do not replace the text when the temporary file did not change
|
||||
startup: don't overwrite rcfile error messages on a Linux console
|
||||
startup: show the correct number of lines when opening multiple files
|
||||
syntax: awk: recognize any {g,m,n,}awk script also by its shebang line
|
||||
syntax: default: colorize also two-digit and capitalized nano versions
|
||||
syntaxes: remove all traces of the 'formatter' command
|
||||
syntax: nanorc: recognize 'yesno' as a valid menu to bind/unbind keys in
|
||||
syntax: nanorc: show ^@ as validly rebindable, but not any ^digit
|
||||
syntax: python: avoid coloring the three special values inside strings
|
||||
text: add auto-whitespace to the file size after creating the undo item
|
||||
tweaks: adjust indentation after the previous change
|
||||
tweaks: adjust one more translator hint, for removed toggles
|
||||
tweaks: adjust some translator hints for past changes, and add two more
|
||||
tweaks: adjust two comments, to be more accurate and general
|
||||
tweaks: avoid dereferencing a pointer when it is NULL [coverity scan]
|
||||
tweaks: close a temp file only when descriptor is valid [coverity scan]
|
||||
tweaks: correct a comment, rewrap a line, and drop some debugging stuff
|
||||
tweaks: delete some old debugging code that no longer seems useful
|
||||
tweaks: don't bother having debug code that deallocates all memory
|
||||
tweaks: don't call va_start() without calling va_end() [coverity scan]
|
||||
tweaks: drop a condition that has been made redundant two commits ago
|
||||
tweaks: drop some old debugging code
|
||||
tweaks: elide a bunch of unneeded constant strings
|
||||
tweaks: elide a function that is used just once
|
||||
tweaks: elide another function that is used just once
|
||||
tweaks: elide an unneeded/duplicate variable
|
||||
tweaks: elide a one-line function -- no, a half-line function
|
||||
tweaks: elide a subfunction that is used just once
|
||||
tweaks: exclude a global flagging variable when it is not needed
|
||||
tweaks: exclude the file-prepending code from the tiny version
|
||||
tweaks: fix a pasting error from a month ago
|
||||
tweaks: implement the name-to-menu function in another manner
|
||||
tweaks: improve a couple of comments in the sample nanorc
|
||||
tweaks: improve a translator hint and some other comments
|
||||
tweaks: move a call to where it will be executed [coverity scan]
|
||||
tweaks: normalize the indentation after the previous change
|
||||
tweaks: properly escape "\" in a man page and "@" in a texi document
|
||||
tweaks: recognize escape sequences of modified Ins/Del more precisely
|
||||
tweaks: reduce the counting of characters to just the needed function
|
||||
tweaks: remove a redundant "struct" word, and replace it in comments
|
||||
tweaks: remove a superfluous condition and a redundant refresh
|
||||
tweaks: remove redundant braces and conditions after the previous change
|
||||
tweaks: remove some braces that are now superfluous
|
||||
tweaks: remove some ineffectual parts from header-line regexes
|
||||
tweaks: remove the superfluous calls that reset the mbtowc() state
|
||||
tweaks: remove two needless words, and split up a changed text further
|
||||
tweaks: remove two superfluous assignments
|
||||
tweaks: rename a constant, to match what it actually means
|
||||
tweaks: rename a function and place its call better
|
||||
tweaks: rename a function to better match its counterpart
|
||||
tweaks: rename a function, to better state what it does
|
||||
tweaks: rename a variable and a function, for more clarity
|
||||
tweaks: rename a variable, to better match its task
|
||||
tweaks: reshuffle some lines, in order to elide one
|
||||
tweaks: reshuffle the order of the bindings, for help-line esthetics
|
||||
tweaks: show "Space" and "Bsp" in the help text of the browser
|
||||
tweaks: slightly improve error message when vital function is unmapped
|
||||
tweaks: use a shorter message, because when the screen is small...
|
||||
undo: differentiate between general filtering and spell checking
|
||||
|
||||
Brand Huntsman (4):
|
||||
input: give feedback for all unbound keys also in the help viewer
|
||||
statusbar: elevate three messages to an ALERT, to make them more visible
|
||||
tweaks: correct four spaces of indentation to a tab, in two places
|
||||
tweaks: remove the 'bright' field from the colortype struct
|
||||
|
||||
David Lawrence Ramsey (13):
|
||||
bindings: make "n" work again in file browser and help viewer
|
||||
bindings: make ^Q start a backward search also in the file browser
|
||||
docs: mention that "Ins" and "Del" are valid rebindable keys
|
||||
justify: verify being in a paragraph before trying to find its beginning
|
||||
speller: hook up a full alternative spellcheck to the undo system
|
||||
speller: hook up a marked-text alternative spellcheck to the undo system
|
||||
speller: make replace_buffer() use the cutting functions directly
|
||||
speller: make replace_marked_buffer() use the cutting functions directly
|
||||
undo: actually enable undoing/redoing an alternative spellcheck
|
||||
undo: always initialize the 'newsize' element in the undo struct
|
||||
undo: position the cursor properly when undoing/redoing magicline cuts
|
||||
undo: restore the cursor position when a cut and paste are paired
|
||||
undo: store the correct cursor position after a paired cut+insert
|
||||
|
||||
Devin Hussey (2):
|
||||
files: speed up reading by using getc_unlocked() instead of getc()
|
||||
syntax: sh: recognize more file extensions and header lines
|
||||
|
||||
Marco Diego Aurélio Mesquita (1):
|
||||
input: erase the next word when Ctrl is held while pressing Delete
|
||||
|
||||
Mark-Weston (2):
|
||||
build: fix compilation when CC=tcc
|
||||
syntax: lua: do not color strings inside comments, and add a linter
|
||||
|
||||
|
||||
Changes between v2.9.7 and v2.9.8:
|
||||
----------------------------------
|
||||
|
||||
|
||||
@@ -3555,10 +3555,10 @@ GNU nano 2.1.4 - 2008.08.09
|
||||
* text.c (add_undo): Fix check for multi-line cut check skips adding other new legit events.
|
||||
|
||||
2008-07-23 Chris Allegretta <chrisa@asty.org>
|
||||
* text.c: Reset openfile-> to OTHER after an undo or redo so we don't
|
||||
mistakenly think this is an update when it's really an add. Also
|
||||
fix an extra ; after an if statement which makes nano try to free
|
||||
a struct which may be NULL.
|
||||
* text.c: Reset openfile->last_action to OTHER after an undo or redo
|
||||
so we don't mistakenly think this is an update when it's really an
|
||||
add. Also fix a mistaken ; after an if statement which made nano
|
||||
try to free a struct which might be NULL.
|
||||
|
||||
GNU nano 2.1.3 - 2008.08.04
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
Improvements in GNU nano
|
||||
========================
|
||||
|
||||
Since 3.0:
|
||||
- <Ctrl+Delete> wipes next word and <Shift+Ctrl+Delete> preceding word.
|
||||
- An external spell check can be undone.
|
||||
|
||||
Since 2.9.0:
|
||||
- The ability to filter text through an external command.
|
||||
- Better detection of paragraphs, allowing a less indented beginning.
|
||||
|
||||
29
NEWS
29
NEWS
@@ -1,3 +1,32 @@
|
||||
2018.09.18 - GNU nano 3.1 "Je faisais des bonds comme ça!" fixes a
|
||||
misbinding of ^H on some terminals and some systems,
|
||||
does not leave stray stuff after the prompt upon exit
|
||||
when having suspended nano while using --constantshow,
|
||||
and does not allow to toggle to Replace in view mode.
|
||||
|
||||
2018.09.09 - GNU nano 3.0 "Water Flowing Underground" speeds up the
|
||||
reading of a file by seventy percent, roughly doubles the
|
||||
speed of handling ASCII text, changes the way words at line
|
||||
boundaries are deleted, makes <Ctrl+Delete> wipe the next
|
||||
word and <Ctrl+Shift+Delete> the preceding word, binds M-Q
|
||||
to 'findprevious' by default (the Tabs-to-Spaces toggle is
|
||||
placed on M-O, and the More-Space toggle is fully removed),
|
||||
makes an external spell check undoable, shows the correct
|
||||
number of lines on the status bar when opening multiple
|
||||
files, removes the 'formatter' command, removes the
|
||||
'searchagain' bindable function (M-W is now bound to
|
||||
'findnext' by default), moves the No-Convert toggle to the
|
||||
Insert menu, removes the Backup and New-Buffer toggles from
|
||||
the main menu (they remain in the Write-Out and Insert
|
||||
menus, respectively), is more precise in what it accepts as
|
||||
a rebindable key name, ignores any presses of <Esc> before
|
||||
a valid command keystroke, recognizes some more escape
|
||||
sequences for modified editing-pad keys, does not hide
|
||||
rcfile error messages on a Linux console, renames the
|
||||
bindable functions 'copytext' to 'copy' and 'uncut' to
|
||||
'paste', and avoids a possible hang during a Full-Justify.
|
||||
|
||||
|
||||
2018.06.02 - GNU nano 2.9.8 "Espresso" brings the ability to filter the
|
||||
buffer (or the marked region) through an external command
|
||||
(^R^X and prefix the command with the pipe symbol, "|"), is
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Generate configure & friends for GIT users.
|
||||
|
||||
gnulib_url="git://git.sv.gnu.org/gnulib.git"
|
||||
gnulib_hash="90f289f249a266b1afb9c63e182f5d979d17df5f"
|
||||
gnulib_hash="14df8ea0658c8902d1ea60bf57ce696cb51814f5"
|
||||
|
||||
modules="
|
||||
futimens
|
||||
|
||||
10
configure.ac
10
configure.ac
@@ -16,7 +16,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
AC_INIT([GNU nano], [2.9.8], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [3.1], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AC_CANONICAL_HOST
|
||||
AM_INIT_AUTOMAKE([1.14])
|
||||
@@ -762,6 +762,14 @@ else
|
||||
fi
|
||||
AM_CONDITIONAL(BUILDING_FROM_GIT, test x$from_git = xyes)
|
||||
|
||||
if test x$from_git = xyes; then
|
||||
if test "$ac_cv_path_MSGFMT" = ":"; then
|
||||
AC_MSG_ERROR([
|
||||
*** The msgfmt program is missing. ***
|
||||
*** The gettext package needs to be installed when building from git. ***])
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
doc/Makefile
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
<h3><a name="1.3"></a>1.3. Why the name change from TIP?</h3>
|
||||
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program "establishes a full duplex terminal connection to a remote host", and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
|
||||
<h3><a name="1.4"></a>1.4. What is the current version of nano?</h3>
|
||||
<blockquote><p>The current version of nano <i>should</i> be <b>2.9.8</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
|
||||
<blockquote><p>The current version of nano <i>should</i> be <b>3.1</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
|
||||
<h3><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h3>
|
||||
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/latest/nano.1.html">here</a>.</p></blockquote>
|
||||
<hr width="100%">
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANO 1 "version 2.9.8" "June 2018"
|
||||
.TH NANO 1 "version 3.1" "September 2018"
|
||||
|
||||
.SH NAME
|
||||
nano \- Nano's ANOther editor, an enhanced free Pico clone
|
||||
@@ -55,7 +55,8 @@ cutbuffer. One can also save the marked text to a file with \fB^O\fR, or
|
||||
spell check it with \fB^T\fR.
|
||||
.PP
|
||||
On some terminals, text can be selected also by holding down Shift while
|
||||
using the arrow keys. Holding down the Alt key too will increase the stride.
|
||||
using the arrow keys. Holding down the Ctrl or Alt key too will increase
|
||||
the stride.
|
||||
Any cursor movement without Shift being held will cancel such a selection.
|
||||
.PP
|
||||
The two lines at the bottom of the screen show some important commands;
|
||||
|
||||
132
doc/nano.texi
132
doc/nano.texi
@@ -8,8 +8,8 @@
|
||||
|
||||
@smallbook
|
||||
@set EDITION 0.5
|
||||
@set VERSION 2.9.8
|
||||
@set UPDATED June 2018
|
||||
@set VERSION 3.1
|
||||
@set UPDATED September 2018
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
@@ -23,7 +23,7 @@
|
||||
@titlepage
|
||||
@title GNU @command{nano}
|
||||
@subtitle a small and friendly text editor
|
||||
@subtitle version 2.9.8
|
||||
@subtitle version 3.1
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
@@ -63,7 +63,7 @@ e-mail: @email{chrisa@@asty.org}@*
|
||||
@node Top
|
||||
@top
|
||||
|
||||
This manual documents the GNU @command{nano} editor, version 2.9.8.
|
||||
This manual documents the GNU @command{nano} editor, version 3.1.
|
||||
|
||||
@menu
|
||||
* Introduction::
|
||||
@@ -506,8 +506,9 @@ This selection can now be cut or copied in its entirety with a single
|
||||
@kbd{^K} or @kbd{M-6}. Or the selection can be used to limit the scope of
|
||||
a search-and-replace (@kbd{^\}) or spell-checking session (@kbd{^T}).
|
||||
|
||||
On some terminals, it is also possible to select text by holding down
|
||||
@kbd{Shift} together with the cursor keys. Such a selection is cancelled
|
||||
On some terminals, text can be selected also by holding down @kbd{Shift}
|
||||
while using the cursor keys. Holding down the @kbd{Ctrl} or @kbd{Alt}
|
||||
key too will increase the stride. Such a selection is cancelled
|
||||
upon any cursor movement where @kbd{Shift} isn't held.
|
||||
|
||||
Cutting or copying selected text will toggle the mark off automatically.
|
||||
@@ -595,15 +596,9 @@ The following global toggles are available:
|
||||
|
||||
@table @code
|
||||
|
||||
@item Backup Files
|
||||
@kbd{Meta-B} toggles the @option{-B} (@option{--backup}) command-line option.
|
||||
|
||||
@item Constant Cursor Position Display
|
||||
@kbd{Meta-C} toggles the @option{-c} (@option{--constantshow}) command-line option.
|
||||
|
||||
@item Multiple File Buffers
|
||||
@kbd{Meta-F} toggles the @option{-F} (@option{--multibuffer}) command-line option.
|
||||
|
||||
@item Smart Home Key
|
||||
@kbd{Meta-H} toggles the @option{-A} (@option{--smarthome}) command-line option.
|
||||
|
||||
@@ -619,18 +614,12 @@ The following global toggles are available:
|
||||
@item Mouse Support
|
||||
@kbd{Meta-M} toggles the @option{-m} (@option{--mouse}) command-line option.
|
||||
|
||||
@item No Conversion From DOS/Mac Format
|
||||
@kbd{Meta-N} toggles the @option{-N} (@option{--noconvert}) command-line option.
|
||||
|
||||
@item More Space For Editing
|
||||
@kbd{Meta-O} toggles the @option{-O} (@option{--morespace}) command-line option.
|
||||
@item Tabs To Spaces
|
||||
@kbd{Meta-O} toggles the @option{-E} (@option{--tabstospaces}) command-line option.
|
||||
|
||||
@item Whitespace Display
|
||||
@kbd{Meta-P} toggles the displaying of whitespace (@pxref{Whitespace}).
|
||||
|
||||
@item Tabs To Spaces
|
||||
@kbd{Meta-Q} toggles the @option{-E} (@option{--tabstospaces}) command-line option.
|
||||
|
||||
@item Smooth Scrolling
|
||||
@kbd{Meta-S} toggles the @option{-S} (@option{--smooth}) command-line option.
|
||||
|
||||
@@ -720,10 +709,6 @@ numbered one every time a file is saved --- when backups are enabled
|
||||
with @code{set backup} or @option{--backup} or @option{-B}.
|
||||
The uniquely numbered files are stored in the specified directory.
|
||||
|
||||
@item set backwards
|
||||
Obsolete option. Recognized but ignored. @code{^Q} is available to
|
||||
start a backward search.
|
||||
|
||||
@item set boldtext
|
||||
Use bold instead of reverse video for the title bar, status bar, key combos,
|
||||
function tags, line numbers, and selected text. This can be overridden by
|
||||
@@ -992,11 +977,6 @@ on the system and will be silently ignored otherwise.)
|
||||
Use the given @var{program} to do a syntax check on the current buffer.
|
||||
(This overrides the speller function.)
|
||||
|
||||
@item formatter @var{program} [@var{arg} @dots{}]
|
||||
Use the given @var{program} to automatically reformat the text in
|
||||
the current buffer --- useful for a programming language like Go.
|
||||
(This overrides the speller and linter functions.)
|
||||
|
||||
@item comment "@var{string}"
|
||||
Use the given string for commenting and uncommenting lines.
|
||||
If the string contains a vertical bar or pipe character (@t{|}),
|
||||
@@ -1012,8 +992,11 @@ The default value is @t{"#"}.
|
||||
Display all pieces of text that match the
|
||||
extended regular expression "regex" with foreground color "fgcolor" and
|
||||
background color "bgcolor", at least one of which must be specified.
|
||||
Valid colors for foreground and background are: white, black, red,
|
||||
blue, green, yellow, magenta, and cyan. You may use the prefix "bright"
|
||||
Valid names for foreground and background color are:
|
||||
@code{white}, @code{black}, @code{blue}, @code{green},
|
||||
@code{red}, @code{cyan}, @code{yellow}, @code{magenta}, and @code{normal}
|
||||
--- where @code{normal} means the default foreground or background color.
|
||||
You may use the prefix @code{bright}
|
||||
to get a stronger color highlight for the foreground. If your
|
||||
terminal supports transparency, not specifying a "bgcolor" tells @command{nano}
|
||||
to attempt to use a transparent background.
|
||||
@@ -1040,13 +1023,28 @@ to @code{icolor}.
|
||||
@item extendsyntax @var{name} @var{command} [@var{arg} @dots{}]
|
||||
Extend the syntax previously defined as "@var{name}" with another @var{command}.
|
||||
This allows you to add a new @code{color}, @code{icolor}, @code{header},
|
||||
@code{magic}, @code{comment}, @code{linter}, or @code{formatter} command
|
||||
to an already
|
||||
@code{magic}, @code{comment}, or @code{linter} command to an already
|
||||
defined syntax --- useful when you want to slightly improve a syntax defined
|
||||
in one of the system-installed files (which normally are not writable).
|
||||
|
||||
@end table
|
||||
|
||||
Note: the @code{formatter} command has been removed. It was superseded by
|
||||
a more general mechanism: the filtering of buffer or marked text through
|
||||
an external command. Such filtering is done by typing @code{^R^X} and then
|
||||
preceding your formatter command with the pipe symbol (@code{|}). It has
|
||||
the added advantage that the operation can be undone.
|
||||
|
||||
If you use such a formatting command regularly, you could assign the relevant
|
||||
series of keystrokes to a single key in your nanorc:
|
||||
|
||||
@example
|
||||
bind M-F "^R^X|yourformatcommand^M" main
|
||||
@end example
|
||||
|
||||
(Note that the @key{^R}, @key{^X}, and @key{^M} are each a single, literal
|
||||
control character. You can enter them by preceding each with @key{M-V}.)
|
||||
|
||||
@node Rebinding Keys
|
||||
@section Rebinding Keys
|
||||
|
||||
@@ -1077,16 +1075,20 @@ The format of @code{key} should be one of:
|
||||
|
||||
@itemize @w{}
|
||||
@item
|
||||
@code{^}@ followed by an ASCII character or the word "Space".
|
||||
@code{^}@ followed by a Latin letter, by one of several ASCII characters
|
||||
(@@, ], \, ^, or _), or by the word "Space".
|
||||
Example: @code{^C}.
|
||||
|
||||
@item
|
||||
@code{M-}@ followed by a ASCII character or the word "Space".
|
||||
@code{M-}@ followed by any ASCII character except [, or by the word "Space".
|
||||
Example: @code{M-C}.
|
||||
|
||||
@item
|
||||
@code{F}@ followed by a numeric value from 1 to 16.
|
||||
Example: @code{F10}.
|
||||
|
||||
@item
|
||||
the word "Ins" or the word "Del".
|
||||
@end itemize
|
||||
|
||||
@sp 1
|
||||
@@ -1118,16 +1120,14 @@ Starts a forward search for text in the current buffer --- or for filenames
|
||||
matching a string in the current list in the file browser.
|
||||
|
||||
@item wherewas
|
||||
Starts a backward search for text in the current buffer.
|
||||
|
||||
@item searchagain
|
||||
Repeats the last search command without prompting.
|
||||
Starts a backward search for text in the current buffer --- or for filenames
|
||||
matching a string in the current list in the file browser.
|
||||
|
||||
@item findprevious
|
||||
As @code{searchagain}, but always in the backward direction.
|
||||
Searches the next occurrence in the backward direction.
|
||||
|
||||
@item findnext
|
||||
As @code{searchagain}, but always in the forward direction.
|
||||
Searches the next occurrence in the forward direction.
|
||||
|
||||
@item replace
|
||||
Interactively replaces text within the current buffer.
|
||||
@@ -1135,25 +1135,32 @@ Interactively replaces text within the current buffer.
|
||||
@item cut
|
||||
Cuts and stores the current line (or the marked region).
|
||||
|
||||
@item copytext
|
||||
@item copy
|
||||
Copies the current line (or the marked region) without deleting it.
|
||||
(The old form 'copytext' is deprecated.)
|
||||
|
||||
@item uncut
|
||||
Copies the currently stored text into the current buffer at the
|
||||
@item paste
|
||||
Pastes the currently stored text into the current buffer at the
|
||||
current cursor position.
|
||||
|
||||
@item mark
|
||||
Sets the mark at the current position, to start selecting text.
|
||||
(The old form 'uncut' is deprecated.)
|
||||
|
||||
@item cutwordleft
|
||||
Cuts from the cursor position to the beginning of the preceding word.
|
||||
(This function is not bound by default. If your terminal produces
|
||||
@code{^H} for <Ctrl+Backspace>, you can make <Ctrl+Backspace> delete
|
||||
the word to the left of the cursor by rebinding ^H to this function.)
|
||||
|
||||
@item cutwordright
|
||||
Cuts from the cursor position to the beginning of the next word.
|
||||
(This function is bound by default to <Ctrl+Delete>.)
|
||||
|
||||
@item cutrestoffile
|
||||
Cuts all text from the cursor position till the end of the buffer.
|
||||
|
||||
@item mark
|
||||
Sets the mark at the current position, to start selecting text.
|
||||
Or, when it is set, unsets the mark.
|
||||
|
||||
@item curpos
|
||||
Shows the current cursor position: the line, column, and character positions.
|
||||
|
||||
@@ -1161,7 +1168,7 @@ Shows the current cursor position: the line, column, and character positions.
|
||||
Counts the number of words, lines and characters in the current buffer.
|
||||
|
||||
@item speller
|
||||
Invokes a spell-checking program (or linting program, or formatter program,
|
||||
Invokes a spell-checking program (or linting program,
|
||||
if the active syntax defines such a thing).
|
||||
|
||||
@item justify
|
||||
@@ -1294,19 +1301,20 @@ Suspends the editor (if the suspending function is enabled, see the
|
||||
"suspendenable" entry below).
|
||||
|
||||
@item casesens
|
||||
Toggles case sensitivity in searching (search/replace menus only).
|
||||
Toggles whether searching/replacing ignores or respects the case of
|
||||
the given characters.
|
||||
|
||||
@item regexp
|
||||
Toggles whether searching/replacing is based on literal strings or regular expressions.
|
||||
Toggles whether searching/replacing uses literal strings or regular expressions.
|
||||
|
||||
@item backwards
|
||||
Toggles whether searching/replacing goes forward or backward.
|
||||
|
||||
@item prevhistory
|
||||
Shows the previous history entry in the prompt menus (e.g.@: search).
|
||||
Retrieves the previous (older) entry at a prompt.
|
||||
|
||||
@item nexthistory
|
||||
Shows the next history entry in the prompt menus (e.g.@: search).
|
||||
Retrieves the next (newer) entry at a prompt.
|
||||
|
||||
@item flipreplace
|
||||
Toggles between searching for something and replacing something.
|
||||
@@ -1326,6 +1334,10 @@ region) is piped to the command.
|
||||
Toggles between inserting into the current buffer and into a new
|
||||
empty buffer.
|
||||
|
||||
@item flipconvert
|
||||
When reading in a file, toggles between converting and not converting
|
||||
it from DOS/Mac format. Converting is the default.
|
||||
|
||||
@item dosformat
|
||||
When writing a file, switches to writing a DOS format (CR/LF).
|
||||
|
||||
@@ -1366,9 +1378,6 @@ Toggles the presence of the two-line list of key bindings at the bottom of the s
|
||||
Toggles the constant display of the current line, column, and character positions.
|
||||
(The form @code{constupdate} is deprecated.)
|
||||
|
||||
@item morespace
|
||||
Toggles the presence of the blank line that 'separates' the title bar from the file text.
|
||||
|
||||
@item smoothscroll
|
||||
Toggles smooth scrolling (when moving around with the arrow keys).
|
||||
|
||||
@@ -1403,19 +1412,9 @@ Toggles whether long lines will be hard-wrapped to the next line.
|
||||
@item tabstospaces
|
||||
Toggles whether typed tabs will be converted to spaces.
|
||||
|
||||
@item backupfile
|
||||
Toggles whether a backup will be made of the file to be edited.
|
||||
|
||||
@item multibuffer
|
||||
Toggles whether a file is inserted into the current buffer
|
||||
or read into a new buffer.
|
||||
|
||||
@item mouse
|
||||
Toggles mouse support.
|
||||
|
||||
@item noconvert
|
||||
Toggles automatic conversion of files from DOS/Mac format.
|
||||
|
||||
@item suspendenable
|
||||
Toggles whether the suspend shortcut (normally @kbd{^Z}) will suspend the editor.
|
||||
|
||||
@@ -1438,6 +1437,9 @@ The 'search to replace' menu.
|
||||
@item replacewith
|
||||
The 'replace with' menu, which comes up after 'search to replace'.
|
||||
|
||||
@item yesno
|
||||
The 'yesno' menu, where the Yes/No/All/Cancel question is asked.
|
||||
|
||||
@item gotoline
|
||||
The 'goto line (and column)' menu.
|
||||
|
||||
|
||||
111
doc/nanorc.5
111
doc/nanorc.5
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANORC 5 "version 2.9.8" "June 2018"
|
||||
.TH NANORC 5 "version 3.1" "September 2018"
|
||||
|
||||
.SH NAME
|
||||
nanorc \- GNU nano's configuration file
|
||||
@@ -80,10 +80,6 @@ numbered one every time a file is saved -- when backups are enabled
|
||||
with \fBset backup\fR or \fB\-\-backup\fR or \fB\-B\fR.
|
||||
The uniquely numbered files are stored in the specified \fIdirectory\fR.
|
||||
.TP
|
||||
.B set backwards
|
||||
Obsolete option. Recognized but ignored. \fB^Q\fR is available to
|
||||
start a backward search.
|
||||
.TP
|
||||
.B set boldtext
|
||||
Use bold instead of reverse video for the title bar, status bar, key combos,
|
||||
function tags, line numbers, and selected text. This can be overridden by
|
||||
@@ -345,11 +341,6 @@ system and will be silently ignored otherwise.)
|
||||
Use the given \fIprogram\fR to run a syntax check on the current buffer.
|
||||
(This overrides the speller function.)
|
||||
.TP
|
||||
.BI formatter " program " \fR[ "arg " \fR...]
|
||||
Use the given \fIprogram\fR to automatically reformat the text in
|
||||
the current buffer -- useful in a programming language like Go.
|
||||
(This overrides the speller and linter functions.)
|
||||
.TP
|
||||
.BI "comment """ string """
|
||||
Use the given \fIstring\fR for commenting and uncommenting lines.
|
||||
If the string contains a vertical bar or pipe character (\fB|\fR),
|
||||
@@ -365,9 +356,11 @@ The default value is "\fB#\fP".
|
||||
Display all pieces of text that match
|
||||
the extended regular expression \fIregex\fP with foreground color
|
||||
\fIfgcolor\fP and background color \fIbgcolor\fP, at least one of which
|
||||
must be specified. Valid colors for foreground and background
|
||||
are: white, black, red, blue, green, yellow, magenta, and cyan. You may
|
||||
use the prefix "bright" to get a stronger color highlight for the
|
||||
must be specified. Valid names for foreground and background colors are:
|
||||
.BR white ", " black ", " blue ", " green ", " red ", "
|
||||
.BR cyan ", " yellow ", " magenta ", and " normal
|
||||
-- where \fBnormal\fR means the default foreground or background color.
|
||||
You may use the prefix \fBbright\fR to get a stronger color highlight for the
|
||||
foreground. If your terminal supports transparency, not specifying a
|
||||
\fIbgcolor\fP tells \fBnano\fP to attempt to use a transparent
|
||||
background.
|
||||
@@ -395,11 +388,28 @@ to \fBicolor\fP.
|
||||
.BI extendsyntax " name command " \fR[ "arg " \fR...]
|
||||
Extend the syntax previously defined as \fIname\fR with another
|
||||
\fIcommand\fR. This allows adding a new \fBcolor\fP, \fBicolor\fP,
|
||||
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, \fBlinter\fP, or \fBformatter\fP
|
||||
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, or \fBlinter\fP
|
||||
command to an already defined syntax -- useful when you want to
|
||||
slightly improve a syntax defined in one of the system-installed
|
||||
files (which normally are not writable).
|
||||
|
||||
.P
|
||||
Note: the \fBformatter\fR command has been removed. It was superseded by
|
||||
a more general mechanism: the filtering of buffer or marked text through
|
||||
an external command. Such filtering is done by typing \fB^R^X\fR and then
|
||||
preceding your formatter command with the pipe symbol (\fB|\fR). It has
|
||||
the added advantage that the operation can be undone.
|
||||
.PP
|
||||
If you use such a formatting command regularly, you could assign the relevant
|
||||
series of keystrokes to a single key in your nanorc:
|
||||
.PP
|
||||
.RS
|
||||
.B "bind M\-F \(dq^R^X|yourformatcommand^M\(dq main"
|
||||
.RE
|
||||
.PP
|
||||
(Note that the \fB^R\fR, \fB^X\fR, and \fB^M\fR are each a single, literal
|
||||
control character. You can enter them by preceding each with \fBM-V\fR.)
|
||||
|
||||
.SH REBINDING KEYS
|
||||
Key bindings can be changed via the following three commands:
|
||||
.RS 3
|
||||
@@ -427,16 +437,19 @@ The format of \fIkey\fP should be one of:
|
||||
.RS 3
|
||||
.TP 3
|
||||
.B ^
|
||||
followed by an alpha character or the word "Space".
|
||||
Example: ^C
|
||||
followed by a Latin letter, by one of several ASCII characters
|
||||
(@, ], \\, ^, or _), or by the word "Space".
|
||||
Example: ^C.
|
||||
.TP
|
||||
.B M-
|
||||
followed by a printable character or the word "Space".
|
||||
Example: M-C
|
||||
followed by any ASCII character except [, or by the word "Space".
|
||||
Example: M-C.
|
||||
.TP
|
||||
.B F
|
||||
followed by a numeric value from 1 to 16.
|
||||
Example: F10
|
||||
Example: F10.
|
||||
.TP
|
||||
the word "Ins" or the word "Del".
|
||||
.RE
|
||||
|
||||
.TP
|
||||
@@ -467,16 +480,14 @@ Starts a forward search for text in the current buffer -- or for filenames
|
||||
matching a string in the current list in the file browser.
|
||||
.TP
|
||||
.B wherewas
|
||||
Starts a backward search for text in the current buffer.
|
||||
.TP
|
||||
.B searchagain
|
||||
Repeats the last search command without prompting.
|
||||
Starts a backward search for text in the current buffer -- or for filenames
|
||||
matching a string in the current list in the file browser.
|
||||
.TP
|
||||
.B findprevious
|
||||
As \fBsearchagain\fR, but always in the backward direction.
|
||||
Searches the next occurrence in the backward direction.
|
||||
.TP
|
||||
.B findnext
|
||||
As \fBsearchagain\fR, but always in the forward direction.
|
||||
Searches the next occurrence in the forward direction.
|
||||
.TP
|
||||
.B replace
|
||||
Interactively replaces text within the current buffer.
|
||||
@@ -484,25 +495,32 @@ Interactively replaces text within the current buffer.
|
||||
.B cut
|
||||
Cuts and stores the current line (or the marked region).
|
||||
.TP
|
||||
.B copytext
|
||||
.B copy
|
||||
Copies the current line (or the marked region) without deleting it.
|
||||
(The old form 'copytext' is deprecated.)
|
||||
.TP
|
||||
.B uncut
|
||||
Copies the currently stored text into the current buffer at the
|
||||
.B paste
|
||||
Pastes the currently stored text into the current buffer at the
|
||||
current cursor position.
|
||||
.TP
|
||||
.B mark
|
||||
Sets the mark at the current position, to start selecting text.
|
||||
(The old form 'uncut' is deprecated.)
|
||||
.TP
|
||||
.B cutwordleft
|
||||
Cuts from the cursor position to the beginning of the preceding word.
|
||||
(This function is not bound by default. If your terminal produces
|
||||
\fB^H\fR for <Ctrl+Backspace>, you can make <Ctrl+Backspace> delete
|
||||
the word to the left of the cursor by rebinding ^H to this function.)
|
||||
.TP
|
||||
.B cutwordright
|
||||
Cuts from the cursor position to the beginning of the next word.
|
||||
(This function is bound by default to <Ctrl+Delete>.)
|
||||
.TP
|
||||
.B cutrestoffile
|
||||
Cuts all text from the cursor position till the end of the buffer.
|
||||
.TP
|
||||
.B mark
|
||||
Sets the mark at the current position, to start selecting text.
|
||||
Or, when it is set, unsets the mark.
|
||||
.TP
|
||||
.B curpos
|
||||
Shows the current cursor position: the line, column, and character positions.
|
||||
.TP
|
||||
@@ -510,7 +528,7 @@ Shows the current cursor position: the line, column, and character positions.
|
||||
Counts the number of words, lines and characters in the current buffer.
|
||||
.TP
|
||||
.B speller
|
||||
Invokes a spell-checking program (or linting program, or formatter program,
|
||||
Invokes a spell-checking program (or linting program,
|
||||
if the active syntax defines such a thing).
|
||||
.TP
|
||||
.B linter
|
||||
@@ -646,19 +664,20 @@ Suspends the editor (if the suspending function is enabled, see the
|
||||
"suspendenable" entry below).
|
||||
.TP
|
||||
.B casesens
|
||||
Toggles case sensitivity in searching (search/replace menus only).
|
||||
Toggles whether searching/replacing ignores or respects the case of
|
||||
the given characters.
|
||||
.TP
|
||||
.B regexp
|
||||
Toggles whether searching/replacing is based on literal strings or regular expressions.
|
||||
Toggles whether searching/replacing uses literal strings or regular expressions.
|
||||
.TP
|
||||
.B backwards
|
||||
Toggles whether searching/replacing goes forward or backward.
|
||||
.TP
|
||||
.B prevhistory
|
||||
Shows the previous history entry in the prompt menus (e.g. search).
|
||||
Retrieves the previous (older) entry at a prompt.
|
||||
.TP
|
||||
.B nexthistory
|
||||
Shows the next history entry in the prompt menus (e.g. search).
|
||||
Retrieves the next (newer) entry at a prompt.
|
||||
.TP
|
||||
.B flipreplace
|
||||
Toggles between searching for something and replacing something.
|
||||
@@ -678,6 +697,10 @@ region) is piped to the command.
|
||||
Toggles between inserting into the current buffer and into a new
|
||||
empty buffer.
|
||||
.TP
|
||||
.B flipconvert
|
||||
When reading in a file, toggles between converting and not converting
|
||||
it from DOS/Mac format. Converting is the default.
|
||||
.TP
|
||||
.B dosformat
|
||||
When writing a file, switches to writing a DOS format (CR/LF).
|
||||
.TP
|
||||
@@ -718,9 +741,6 @@ Toggles the presence of the two-line list of key bindings at the bottom of the s
|
||||
Toggles the constant display of the current line, column, and character positions.
|
||||
(The form 'constupdate' is deprecated.)
|
||||
.TP
|
||||
.B morespace
|
||||
Toggles the presence of the blank line that 'separates' the title bar from the file text.
|
||||
.TP
|
||||
.B smoothscroll
|
||||
Toggles smooth scrolling (when moving around with the arrow keys).
|
||||
.TP
|
||||
@@ -755,19 +775,9 @@ Toggles whether long lines will be hard-wrapped to the next line.
|
||||
.B tabstospaces
|
||||
Toggles whether typed tabs will be converted to spaces.
|
||||
.TP
|
||||
.B backupfile
|
||||
Toggles whether a backup will be made of the file being edited.
|
||||
.TP
|
||||
.B multibuffer
|
||||
Toggles whether a file is inserted into the current buffer
|
||||
or read into a new buffer.
|
||||
.TP
|
||||
.B mouse
|
||||
Toggles mouse support.
|
||||
.TP
|
||||
.B noconvert
|
||||
Toggles automatic conversion of files from DOS/Mac format.
|
||||
.TP
|
||||
.B suspendenable
|
||||
Toggles whether the suspend sequence (normally ^Z) will suspend the editor window.
|
||||
.RE
|
||||
@@ -788,6 +798,9 @@ The 'search to replace' menu.
|
||||
.B replacewith
|
||||
The 'replace with' menu, which comes up after 'search to replace'.
|
||||
.TP
|
||||
.B yesno
|
||||
The 'yesno' menu, where the Yes/No/All/Cancel question is asked.
|
||||
.TP
|
||||
.B gotoline
|
||||
The 'goto line (and column)' menu.
|
||||
.TP
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH RNANO 1 "version 2.9.8" "June 2018"
|
||||
.TH RNANO 1 "version 3.1" "September 2018"
|
||||
|
||||
.SH NAME
|
||||
rnano \- a restricted nano
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
## Sample initialization file for GNU nano.
|
||||
##
|
||||
## Please note that you must have configured nano with --enable-nanorc
|
||||
## for this file to be read! Also note that this file should not be in
|
||||
## DOS or Mac format, and that characters specially interpreted by the
|
||||
## shell should not be escaped here.
|
||||
## This file should not be in DOS or Mac format, and characters
|
||||
## specially interpreted by the shell should not be escaped here.
|
||||
##
|
||||
## To make sure an option is disabled, use "unset <option>".
|
||||
##
|
||||
@@ -53,9 +51,9 @@
|
||||
# set cutfromcursor
|
||||
## (The old form, 'cut', is deprecated.)
|
||||
|
||||
## Set the line length for wrapping text and justifying paragraphs.
|
||||
## If the value is 0 or less, the wrapping point will be the screen
|
||||
## width less this number.
|
||||
## Enable hard-wrapping and set the target width, both for automatic
|
||||
## line wrapping and for justifying paragraphs. If the value is 0 or
|
||||
## less, the wrapping point will be the screen width minus this number.
|
||||
# set fill -8
|
||||
|
||||
## Remember the used search/replace strings for the next session.
|
||||
@@ -100,7 +98,7 @@
|
||||
## last one will be readable (when there are multiple ones).
|
||||
# set nopauses
|
||||
|
||||
## Don't wrap text at all.
|
||||
## Do not automatically hard-wrap text.
|
||||
# set nowrap
|
||||
|
||||
## Set operating directory. nano will not read or write files outside
|
||||
@@ -149,7 +147,7 @@
|
||||
## beginning of the line.
|
||||
# set smarthome
|
||||
|
||||
## Use smooth scrolling as the default.
|
||||
## Use line-by-line scrolling instead of chunk-by-chunk.
|
||||
# set smooth
|
||||
|
||||
## Enable soft line wrapping (AKA full-line display).
|
||||
@@ -233,9 +231,9 @@
|
||||
## "color" will do case-sensitive matches, while "icolor" will do
|
||||
## case-insensitive matches.
|
||||
##
|
||||
## Valid colors: white, black, red, blue, green, yellow, magenta, cyan.
|
||||
## For foreground colors, you may use the prefix "bright" to get a
|
||||
## stronger highlight.
|
||||
## Valid color names ares: white, black, normal, red, blue, green,
|
||||
## yellow, magenta, cyan. For foreground colors, you may use the
|
||||
## prefix "bright" to get a stronger highlight.
|
||||
##
|
||||
## To use multi-line regexes, use the start="regex" end="regex"
|
||||
## [start="regex" end="regex"...] format.
|
||||
@@ -255,18 +253,23 @@
|
||||
## ".nanorc" extension) should be the same as the "short description"
|
||||
## name inside that file. These names are kept fairly short to make
|
||||
## them easier to remember and faster to type using nano's -Y option.
|
||||
##
|
||||
|
||||
## To include all existing syntax definitions, you can do:
|
||||
# include "@PKGDATADIR@/*.nanorc"
|
||||
|
||||
|
||||
## Key bindings.
|
||||
## See nanorc(5) (section REBINDING KEYS) for more details on this.
|
||||
##
|
||||
## The following two functions are not bound to any key by default.
|
||||
## You may wish to choose other keys than the ones suggested here.
|
||||
# bind M-B cutwordleft main
|
||||
# bind M-N cutwordright main
|
||||
|
||||
## Set this if your Backspace key sends Del most of the time.
|
||||
## If your Backspace key behaves as Delete (when ssh'ing in from another
|
||||
## machine, for example), set this to make it behave as Backspace again:
|
||||
# bind Del backspace all
|
||||
|
||||
## The <Ctrl+Delete> keystroke deletes the word to the right of the cursor.
|
||||
## On some terminals the <Ctrl+Backspace> keystroke produces ^H, which is
|
||||
## the ASCII character for backspace, so it is bound by default to the
|
||||
## backspace function. The <Backspace> key itself produces a different
|
||||
## keycode, which is hard-bound to the backspace function. So, if you
|
||||
## normally use <Backspace> for backspacing and not ^H, you can make
|
||||
## <Ctrl+Backspace> delete the word to the left of the cursor with:
|
||||
# bind ^H cutwordleft main
|
||||
|
||||
1088
po/nano.pot
1088
po/nano.pot
File diff suppressed because it is too large
Load Diff
1154
po/pt_BR.po
1154
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
1165
po/zh_CN.po
1165
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
1198
po/zh_TW.po
1198
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
26
roll-a-release.sh
Executable file
26
roll-a-release.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION="3.1"
|
||||
|
||||
echo "Running autogen..." && ./autogen.sh &&
|
||||
rm -v -f m4/*.m4~ *.asc *.sig *.gz *.xz &&
|
||||
|
||||
echo "Rebuilding..." && make &&
|
||||
po/update_linguas.sh &&
|
||||
|
||||
make distcheck && make dist-xz &&
|
||||
|
||||
git commit -a -m "$(git log -1 --grep 'po: up' | grep o: | sed 's/^ //')" &&
|
||||
|
||||
gpg -a -b nano-$VERSION.tar.gz &&
|
||||
gpg -a -b nano-$VERSION.tar.xz &&
|
||||
gpg --verify nano-$VERSION.tar.gz.asc &&
|
||||
gpg --verify nano-$VERSION.tar.xz.asc &&
|
||||
|
||||
git tag -u A0ACE884 -a v$VERSION -m "the nano $VERSION release" &&
|
||||
|
||||
for file in nano-$VERSION.tar.*z*; do scp $file bens@wh0rd.org:$file; done &&
|
||||
|
||||
gnupload --to ftp.gnu.org:nano nano-$VERSION.tar.*z &&
|
||||
|
||||
echo "Tarballs have been rolled and uploaded."
|
||||
@@ -166,15 +166,13 @@ char *do_browser(char *path)
|
||||
say_there_is_no_help();
|
||||
#endif
|
||||
} else if (func == do_search_forward) {
|
||||
do_filesearch();
|
||||
} else if (func == do_research) {
|
||||
do_fileresearch(FORWARD);
|
||||
#ifndef NANO_TINY
|
||||
do_filesearch(FORWARD);
|
||||
} else if (func == do_search_backward) {
|
||||
do_filesearch(BACKWARD);
|
||||
} else if (func == do_findprevious) {
|
||||
do_fileresearch(BACKWARD);
|
||||
} else if (func == do_findnext) {
|
||||
do_fileresearch(FORWARD);
|
||||
#endif
|
||||
} else if (func == do_left) {
|
||||
if (selected > 0)
|
||||
selected--;
|
||||
@@ -488,11 +486,9 @@ functionptrtype parse_browser_input(int *kbinput)
|
||||
case '/':
|
||||
return do_search_forward;
|
||||
case 'N':
|
||||
#ifndef NANO_TINY
|
||||
return do_findprevious;
|
||||
#endif
|
||||
case 'n':
|
||||
return do_research;
|
||||
return do_findnext;
|
||||
}
|
||||
}
|
||||
return func_from_key(kbinput);
|
||||
@@ -659,10 +655,11 @@ void browser_select_dirname(const char *needle)
|
||||
}
|
||||
}
|
||||
|
||||
/* Prepare the prompt and ask the user what to search for. Return -2
|
||||
/* Prepare the prompt and ask the user what to search for. If forwards is
|
||||
* TRUE, search forward in the list; otherwise, search backward. Return -2
|
||||
* for a blank answer, -1 for Cancel, 0 when we have a string, and a
|
||||
* positive value when some function was run. */
|
||||
int filesearch_init(void)
|
||||
int filesearch_init(bool forwards)
|
||||
{
|
||||
char *thedefault;
|
||||
int response;
|
||||
@@ -681,7 +678,8 @@ int filesearch_init(void)
|
||||
|
||||
/* Now ask what to search for. */
|
||||
response = do_prompt(FALSE, FALSE, MWHEREISFILE, NULL, &search_history,
|
||||
browser_refresh, "%s%s", _("Search"), thedefault);
|
||||
browser_refresh, "%s%s%s", _("Search"),
|
||||
!forwards ? _(" [Backwards]") : "", thedefault);
|
||||
free(thedefault);
|
||||
|
||||
/* If only Enter was pressed but we have a previous string, it's okay. */
|
||||
@@ -754,11 +752,12 @@ void findfile(const char *needle, bool forwards)
|
||||
selected = looking_at;
|
||||
}
|
||||
|
||||
/* Search for a filename. */
|
||||
void do_filesearch(void)
|
||||
/* Search for a filename. If forwards is TRUE, search forward in the list;
|
||||
* otherwise, search backward.*/
|
||||
void do_filesearch(bool forwards)
|
||||
{
|
||||
/* If the user cancelled or jumped to first or last file, don't search. */
|
||||
if (filesearch_init() != 0)
|
||||
if (filesearch_init(forwards) != 0)
|
||||
return;
|
||||
|
||||
/* If answer is now "", copy last_search into answer. */
|
||||
@@ -773,7 +772,7 @@ void do_filesearch(void)
|
||||
update_history(&search_history, answer);
|
||||
#endif
|
||||
|
||||
findfile(answer, TRUE);
|
||||
findfile(answer, forwards);
|
||||
}
|
||||
|
||||
/* Search again without prompting for the last given search string,
|
||||
|
||||
169
src/chars.c
169
src/chars.c
@@ -62,11 +62,6 @@ bool is_byte(int c)
|
||||
return ((unsigned int)c == (unsigned char)c);
|
||||
}
|
||||
|
||||
void mbtowc_reset(void)
|
||||
{
|
||||
IGNORE_CALL_RESULT(mbtowc(NULL, NULL, 0));
|
||||
}
|
||||
|
||||
/* This function is equivalent to isalpha() for multibyte characters. */
|
||||
bool is_alpha_mbchar(const char *c)
|
||||
{
|
||||
@@ -74,10 +69,8 @@ bool is_alpha_mbchar(const char *c)
|
||||
if (use_utf8) {
|
||||
wchar_t wc;
|
||||
|
||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
|
||||
mbtowc_reset();
|
||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return iswalpha(wc);
|
||||
} else
|
||||
@@ -92,10 +85,8 @@ bool is_alnum_mbchar(const char *c)
|
||||
if (use_utf8) {
|
||||
wchar_t wc;
|
||||
|
||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
|
||||
mbtowc_reset();
|
||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return iswalnum(wc);
|
||||
} else
|
||||
@@ -110,10 +101,8 @@ bool is_blank_mbchar(const char *c)
|
||||
if (use_utf8) {
|
||||
wchar_t wc;
|
||||
|
||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
|
||||
mbtowc_reset();
|
||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return iswblank(wc);
|
||||
} else
|
||||
@@ -128,13 +117,6 @@ bool is_ascii_cntrl_char(int c)
|
||||
return (0 <= c && c < 32);
|
||||
}
|
||||
|
||||
/* This function is equivalent to iscntrl(), except in that it also
|
||||
* handles high-bit control characters. */
|
||||
bool is_cntrl_char(int c)
|
||||
{
|
||||
return ((c & 0x60) == 0 || c == 127);
|
||||
}
|
||||
|
||||
/* This function is equivalent to iscntrl() for multibyte characters,
|
||||
* except in that it also handles multibyte control characters with
|
||||
* their high bits set. */
|
||||
@@ -146,7 +128,7 @@ bool is_cntrl_mbchar(const char *c)
|
||||
((signed char)c[0] == -62 && (signed char)c[1] < -96));
|
||||
} else
|
||||
#endif
|
||||
return is_cntrl_char((unsigned char)*c);
|
||||
return (((unsigned char)*c & 0x60) == 0 || (unsigned char)*c == 127);
|
||||
}
|
||||
|
||||
/* This function is equivalent to ispunct() for multibyte characters. */
|
||||
@@ -156,10 +138,8 @@ bool is_punct_mbchar(const char *c)
|
||||
if (use_utf8) {
|
||||
wchar_t wc;
|
||||
|
||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
|
||||
mbtowc_reset();
|
||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return iswpunct(wc);
|
||||
} else
|
||||
@@ -232,10 +212,8 @@ int length_of_char(const char *c, int *width)
|
||||
int charlen = mbtowc(&wc, c, MAXCHARLEN);
|
||||
|
||||
/* If the sequence is invalid... */
|
||||
if (charlen < 0) {
|
||||
mbtowc_reset();
|
||||
if (charlen < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If the codepoint is invalid... */
|
||||
if (!is_valid_unicode(wc))
|
||||
@@ -260,10 +238,8 @@ int mbwidth(const char *c)
|
||||
wchar_t wc;
|
||||
int width;
|
||||
|
||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
|
||||
mbtowc_reset();
|
||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
width = wcwidth(wc);
|
||||
|
||||
@@ -309,65 +285,45 @@ char *make_mbchar(long chr, int *chr_mb_len)
|
||||
* col isn't NULL, add the character's width (in columns) to it. */
|
||||
int parse_mbchar(const char *buf, char *chr, size_t *col)
|
||||
{
|
||||
int length;
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
/* Get the number of bytes in the multibyte character. */
|
||||
int length = mblen(buf, MAXCHARLEN);
|
||||
/* If this is a UTF-8 starter byte, get the number of bytes of the character. */
|
||||
if ((signed char)*buf < 0) {
|
||||
length = mblen(buf, MAXCHARLEN);
|
||||
|
||||
/* When the multibyte sequence is invalid, only take the first byte. */
|
||||
if (length <= 0) {
|
||||
IGNORE_CALL_RESULT(mblen(NULL, 0));
|
||||
if (length <= 0)
|
||||
length = 1;
|
||||
}
|
||||
|
||||
/* When requested, store the multibyte character in chr. */
|
||||
if (chr != NULL) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
chr[i] = buf[i];
|
||||
}
|
||||
|
||||
/* When requested, add the width of the character to col. */
|
||||
if (col != NULL) {
|
||||
/* If we have a tab, compute its width in columns based on the
|
||||
* current value of col. */
|
||||
if (*buf == '\t')
|
||||
*col += tabsize - *col % tabsize;
|
||||
/* If we have a control character, it's two columns wide: one
|
||||
* column for the "^", and one for the visible character. */
|
||||
else if (is_cntrl_mbchar(buf)) {
|
||||
*col += 2;
|
||||
/* If we have a normal character, get its width normally. */
|
||||
} else
|
||||
*col += mbwidth(buf);
|
||||
}
|
||||
|
||||
return length;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/* When requested, store the byte character in chr. */
|
||||
if (chr != NULL)
|
||||
*chr = *buf;
|
||||
length = 1;
|
||||
|
||||
/* When requested, add the width of the character to col. */
|
||||
if (col != NULL) {
|
||||
/* If we have a tab, compute its width in columns using the
|
||||
* current value of col. */
|
||||
if (*buf == '\t')
|
||||
*col += tabsize - *col % tabsize;
|
||||
/* If we have a control character, it's two columns wide: one
|
||||
* column for the "^", and one for the visible character. */
|
||||
else if (is_cntrl_char((unsigned char)*buf))
|
||||
*col += 2;
|
||||
/* If we have a normal character, it's one column wide. */
|
||||
else
|
||||
(*col)++;
|
||||
}
|
||||
/* When requested, store the multibyte character in chr. */
|
||||
if (chr != NULL)
|
||||
for (int i = 0; i < length; i++)
|
||||
chr[i] = buf[i];
|
||||
|
||||
return 1;
|
||||
/* When requested, add the width of the character to col. */
|
||||
if (col != NULL) {
|
||||
/* If we have a tab, compute its width in columns based on the
|
||||
* current value of col. */
|
||||
if (*buf == '\t')
|
||||
*col += tabsize - *col % tabsize;
|
||||
/* If we have a control character, it's two columns wide: one
|
||||
* column for the "^", and one for the visible character. */
|
||||
else if (is_cntrl_mbchar(buf))
|
||||
*col += 2;
|
||||
/* If we have a normal character, get its width normally. */
|
||||
else if (length == 1)
|
||||
*col += 1;
|
||||
#ifdef ENABLE_UTF8
|
||||
else
|
||||
*col += mbwidth(buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
/* Return the index in buf of the beginning of the multibyte character
|
||||
@@ -430,17 +386,8 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
|
||||
wchar_t wc1, wc2;
|
||||
|
||||
while (*s1 != '\0' && *s2 != '\0' && n > 0) {
|
||||
bool bad1 = FALSE, bad2 = FALSE;
|
||||
|
||||
if (mbtowc(&wc1, s1, MAXCHARLEN) < 0) {
|
||||
mbtowc_reset();
|
||||
bad1 = TRUE;
|
||||
}
|
||||
|
||||
if (mbtowc(&wc2, s2, MAXCHARLEN) < 0) {
|
||||
mbtowc_reset();
|
||||
bad2 = TRUE;
|
||||
}
|
||||
bool bad1 = (mbtowc(&wc1, s1, MAXCHARLEN) < 0);
|
||||
bool bad2 = (mbtowc(&wc2, s2, MAXCHARLEN) < 0);
|
||||
|
||||
if (bad1 || bad2) {
|
||||
if (*s1 != *s2)
|
||||
@@ -556,22 +503,26 @@ char *mbrevstrcasestr(const char *haystack, const char *needle,
|
||||
return revstrcasestr(haystack, needle, pointer);
|
||||
}
|
||||
|
||||
/* This function is equivalent to strlen() for multibyte strings. */
|
||||
/* Count the number of (multibyte) characters in the given string. */
|
||||
size_t mbstrlen(const char *s)
|
||||
{
|
||||
return mbstrnlen(s, (size_t)-1);
|
||||
}
|
||||
size_t maxlen = (size_t)-1;
|
||||
|
||||
/* This function is equivalent to strnlen() for multibyte strings. */
|
||||
size_t mbstrnlen(const char *s, size_t maxlen)
|
||||
{
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8) {
|
||||
size_t n = 0;
|
||||
|
||||
for (; *s != '\0' && maxlen > 0; s += move_mbright(s, 0),
|
||||
maxlen--, n++)
|
||||
;
|
||||
while (*s != '\0' && maxlen > 0) {
|
||||
if ((signed char)*s < 0) {
|
||||
int length = mblen(s, MAXCHARLEN);
|
||||
|
||||
s += (length < 0 ? 1 : length);
|
||||
} else
|
||||
s++;
|
||||
|
||||
maxlen--;
|
||||
n++;
|
||||
}
|
||||
|
||||
return n;
|
||||
} else
|
||||
@@ -591,7 +542,6 @@ char *mbstrchr(const char *s, const char *c)
|
||||
wchar_t ws, wc;
|
||||
|
||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
|
||||
mbtowc_reset();
|
||||
wc = (unsigned char)*c;
|
||||
bad_c_mb = TRUE;
|
||||
}
|
||||
@@ -600,7 +550,6 @@ char *mbstrchr(const char *s, const char *c)
|
||||
int sym_len = parse_mbchar(s, symbol, NULL);
|
||||
|
||||
if (mbtowc(&ws, symbol, sym_len) < 0) {
|
||||
mbtowc_reset();
|
||||
ws = (unsigned char)*s;
|
||||
bad_s_mb = TRUE;
|
||||
}
|
||||
@@ -731,17 +680,3 @@ bool is_valid_unicode(wchar_t wc)
|
||||
(0xFFFF < wc && wc <= 0x10FFFF && (wc & 0xFFFF) <= 0xFFFD));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NANORC
|
||||
/* Check if the string s is a valid multibyte string. Return TRUE if it
|
||||
* is, and FALSE otherwise. */
|
||||
bool is_valid_mbstring(const char *s)
|
||||
{
|
||||
#ifdef ENABLE_UTF8
|
||||
if (use_utf8)
|
||||
return (mbstowcs(NULL, s, 0) != (size_t)-1);
|
||||
else
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
||||
@@ -66,7 +66,7 @@ void set_colorpairs(void)
|
||||
combo->bg = COLOR_BLACK;
|
||||
init_pair(i + 1, combo->fg, combo->bg);
|
||||
interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BANDAID |
|
||||
(combo->bright ? A_BOLD : A_NORMAL);
|
||||
combo->attributes;
|
||||
} else {
|
||||
if (i == FUNCTION_TAG)
|
||||
interface_color_pair[i] = A_NORMAL;
|
||||
@@ -98,8 +98,7 @@ void set_colorpairs(void)
|
||||
else
|
||||
ink->pairnum = new_number++;
|
||||
|
||||
ink->attributes = COLOR_PAIR(ink->pairnum) | A_BANDAID |
|
||||
(ink->bright ? A_BOLD : A_NORMAL);
|
||||
ink->attributes |= COLOR_PAIR(ink->pairnum) | A_BANDAID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
26
src/cut.c
26
src/cut.c
@@ -111,7 +111,7 @@ void cut_to_eof(void)
|
||||
* copy_text is TRUE, copy the text back into the buffer afterward.
|
||||
* If cut_till_eof is TRUE, move all text from the current cursor
|
||||
* position to the end of the file into the cutbuffer. */
|
||||
void do_cut_text(bool copy_text, bool cut_till_eof)
|
||||
void do_cut_text(bool copy_text, bool marked, bool cut_till_eof)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
filestruct *cb_save = NULL;
|
||||
@@ -125,12 +125,12 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
|
||||
#endif
|
||||
size_t was_totsize = openfile->totsize;
|
||||
|
||||
/* If a chain of cuts was broken, empty the cutbuffer. */
|
||||
if (!keep_cutbuffer) {
|
||||
/* If cuts were not continuous, or when cutting a region, clear the slate. */
|
||||
if (!keep_cutbuffer || marked || cut_till_eof) {
|
||||
free_filestruct(cutbuffer);
|
||||
cutbuffer = NULL;
|
||||
/* Indicate that future cuts should add to the cutbuffer. */
|
||||
keep_cutbuffer = TRUE;
|
||||
/* After a line cut, future line cuts should add to the cutbuffer. */
|
||||
keep_cutbuffer = !marked && !cut_till_eof;
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -187,10 +187,6 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
|
||||
set_modified();
|
||||
|
||||
refresh_needed = TRUE;
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_filestruct(cutbuffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Move text from the current buffer into the cutbuffer. */
|
||||
@@ -198,10 +194,10 @@ void do_cut_text_void(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
add_undo(CUT);
|
||||
#endif
|
||||
do_cut_text(FALSE, FALSE);
|
||||
#ifndef NANO_TINY
|
||||
do_cut_text(FALSE, openfile->mark, FALSE);
|
||||
update_undo(CUT);
|
||||
#else
|
||||
do_cut_text(FALSE, FALSE, FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -211,7 +207,7 @@ void do_cut_text_void(void)
|
||||
* was moved, blow away previous contents of the cutbuffer. */
|
||||
void do_copy_text(void)
|
||||
{
|
||||
static struct filestruct *next_contiguous_line = NULL;
|
||||
static filestruct *next_contiguous_line = NULL;
|
||||
bool mark_is_set = (openfile->mark != NULL);
|
||||
|
||||
/* Remember the current viewport and cursor position. */
|
||||
@@ -223,7 +219,7 @@ void do_copy_text(void)
|
||||
if (mark_is_set || openfile->current != next_contiguous_line)
|
||||
cutbuffer_reset();
|
||||
|
||||
do_cut_text(TRUE, FALSE);
|
||||
do_cut_text(TRUE, mark_is_set, FALSE);
|
||||
|
||||
/* If the mark was set, blow away the cutbuffer on the next copy. */
|
||||
next_contiguous_line = (mark_is_set ? NULL : openfile->current);
|
||||
@@ -241,7 +237,7 @@ void do_copy_text(void)
|
||||
void do_cut_till_eof(void)
|
||||
{
|
||||
add_undo(CUT_TO_EOF);
|
||||
do_cut_text(FALSE, TRUE);
|
||||
do_cut_text(FALSE, FALSE, TRUE);
|
||||
update_undo(CUT_TO_EOF);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
147
src/files.c
147
src/files.c
@@ -512,6 +512,7 @@ void replace_buffer(const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
int descriptor;
|
||||
filestruct *was_cutbuffer = cutbuffer;
|
||||
|
||||
/* Open the file quietly. */
|
||||
descriptor = open_file(filename, FALSE, TRUE, &f);
|
||||
@@ -520,29 +521,44 @@ void replace_buffer(const char *filename)
|
||||
if (descriptor < 0)
|
||||
return;
|
||||
|
||||
/* Reinitialize the text of the current buffer. */
|
||||
free_filestruct(openfile->fileage);
|
||||
initialize_buffer_text();
|
||||
#ifndef NANO_TINY
|
||||
add_undo(COUPLE_BEGIN);
|
||||
openfile->undotop->strdata = mallocstrcpy(NULL, _("spelling correction"));
|
||||
#endif
|
||||
|
||||
/* Throw away the text of the file. */
|
||||
cutbuffer = NULL;
|
||||
openfile->current = openfile->fileage;
|
||||
openfile->current_x = 0;
|
||||
#ifndef NANO_TINY
|
||||
add_undo(CUT_TO_EOF);
|
||||
#endif
|
||||
do_cut_text(FALSE, FALSE, TRUE);
|
||||
#ifndef NANO_TINY
|
||||
update_undo(CUT_TO_EOF);
|
||||
#endif
|
||||
free_filestruct(cutbuffer);
|
||||
cutbuffer = was_cutbuffer;
|
||||
|
||||
/* Insert the processed file into its place. */
|
||||
read_file(f, descriptor, filename, FALSE);
|
||||
read_file(f, descriptor, filename, TRUE);
|
||||
|
||||
/* Put current at a place that is certain to exist. */
|
||||
openfile->current = openfile->fileage;
|
||||
#ifndef NANO_TINY
|
||||
add_undo(COUPLE_END);
|
||||
openfile->undotop->strdata = mallocstrcpy(NULL, _("spelling correction"));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Open the specified file, and if that succeeds, blow away the text of
|
||||
* the current buffer at the given coordinates and read the file
|
||||
* the current buffer covered by the mark and read the file
|
||||
* contents into its place. */
|
||||
void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
|
||||
filestruct *bot, size_t bot_x)
|
||||
void replace_marked_buffer(const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
int descriptor;
|
||||
bool old_no_newlines = ISSET(NO_NEWLINES);
|
||||
filestruct *trash_top = NULL;
|
||||
filestruct *trash_bot = NULL;
|
||||
filestruct *was_cutbuffer = cutbuffer;
|
||||
|
||||
descriptor = open_file(filename, FALSE, TRUE, &f);
|
||||
|
||||
@@ -552,15 +568,26 @@ void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
|
||||
/* Don't add a magicline when replacing text in the buffer. */
|
||||
SET(NO_NEWLINES);
|
||||
|
||||
/* Throw away the text under the mark, and insert the processed file
|
||||
* where the marked text was. */
|
||||
extract_buffer(&trash_top, &trash_bot, top, top_x, bot, bot_x);
|
||||
free_filestruct(trash_top);
|
||||
read_file(f, descriptor, filename, FALSE);
|
||||
add_undo(COUPLE_BEGIN);
|
||||
openfile->undotop->strdata = mallocstrcpy(NULL, _("spelling correction"));
|
||||
|
||||
/* Throw away the text under the mark. */
|
||||
cutbuffer = NULL;
|
||||
add_undo(CUT);
|
||||
do_cut_text(FALSE, TRUE, FALSE);
|
||||
update_undo(CUT);
|
||||
free_filestruct(cutbuffer);
|
||||
cutbuffer = was_cutbuffer;
|
||||
|
||||
/* Insert the processed file where the marked text was. */
|
||||
read_file(f, descriptor, filename, TRUE);
|
||||
|
||||
/* Restore the magicline behavior now that we're done fiddling. */
|
||||
if (!old_no_newlines)
|
||||
UNSET(NO_NEWLINES);
|
||||
|
||||
add_undo(COUPLE_END);
|
||||
openfile->undotop->strdata = mallocstrcpy(NULL, _("spelling correction"));
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
#endif /* ENABLE_SPELLER */
|
||||
@@ -585,12 +612,31 @@ void prepare_for_display(void)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* Show name of current buffer and its number of lines on the status bar. */
|
||||
void mention_name_and_linecount(void)
|
||||
{
|
||||
size_t count = openfile->filebot->lineno -
|
||||
(openfile->filebot->data[0] == '\0' ? 1 : 0);
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->fmt != NIX_FILE)
|
||||
/* TRANSLATORS: first %s is file name, second %s is file format. */
|
||||
statusline(HUSH, P_("%s -- %zu line (%s)", "%s -- %zu lines (%s)", count),
|
||||
openfile->filename[0] == '\0' ?
|
||||
_("New Buffer") : tail(openfile->filename), count,
|
||||
openfile->fmt == DOS_FILE ? _("DOS") : _("Mac"));
|
||||
else
|
||||
#endif
|
||||
statusline(HUSH, P_("%s -- %zu line", "%s -- %zu lines", count),
|
||||
openfile->filename[0] == '\0' ?
|
||||
_("New Buffer") : tail(openfile->filename), count);
|
||||
}
|
||||
|
||||
/* Switch to a neighbouring file buffer; to the next if to_next is TRUE;
|
||||
* otherwise, to the previous one. */
|
||||
void switch_to_adjacent_buffer(bool to_next)
|
||||
{
|
||||
/* If only one file buffer is open, say so and get out. */
|
||||
if (openfile == openfile->next && !inhelp) {
|
||||
if (openfile == openfile->next) {
|
||||
statusbar(_("No more open file buffers"));
|
||||
return;
|
||||
}
|
||||
@@ -615,14 +661,8 @@ void switch_to_adjacent_buffer(bool to_next)
|
||||
/* Ensure that the main loop will redraw the help lines. */
|
||||
currmenu = MMOST;
|
||||
|
||||
/* Indicate the switch on the statusbar. */
|
||||
statusline(HUSH, _("Switched to %s"),
|
||||
((openfile->filename[0] == '\0') ?
|
||||
_("New Buffer") : openfile->filename));
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_filestruct(openfile->current);
|
||||
#endif
|
||||
/* Indicate on the status bar where we switched to. */
|
||||
mention_name_and_linecount();
|
||||
}
|
||||
|
||||
/* Switch to the previous entry in the list of open files. */
|
||||
@@ -760,8 +800,12 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
topline = make_new_node(NULL);
|
||||
bottomline = topline;
|
||||
|
||||
/* Lock the file before starting to read it, to avoid the overhead
|
||||
* of locking it for each single byte that we read from it. */
|
||||
flockfile(f);
|
||||
|
||||
/* Read the entire file into the new buffer. */
|
||||
while ((input_int = getc(f)) != EOF) {
|
||||
while ((input_int = getc_unlocked(f)) != EOF) {
|
||||
input = (char)input_int;
|
||||
|
||||
/* If it's a *nix file ("\n") or a DOS file ("\r\n"), and file
|
||||
@@ -828,6 +872,9 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* We are done with the file, unlock it. */
|
||||
funlockfile(f);
|
||||
|
||||
/* Perhaps this could use some better handling. */
|
||||
if (ferror(f))
|
||||
nperror(filename);
|
||||
@@ -1036,7 +1083,7 @@ void do_insertfile(void)
|
||||
if (execute) {
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (ISSET(MULTIBUFFER))
|
||||
/* TRANSLATORS: The next four messages are prompts. */
|
||||
/* TRANSLATORS: The next six messages are prompts. */
|
||||
msg = _("Command to execute in new buffer");
|
||||
else
|
||||
#endif
|
||||
@@ -1046,10 +1093,20 @@ void do_insertfile(void)
|
||||
{
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (ISSET(MULTIBUFFER))
|
||||
msg = _("File to insert into new buffer [from %s]");
|
||||
#ifndef NANO_TINY
|
||||
if ISSET(NO_CONVERT)
|
||||
msg = _("File to read unconverted into new buffer [from %s]");
|
||||
else
|
||||
#endif
|
||||
msg = _("File to read into new buffer [from %s]");
|
||||
else
|
||||
#endif
|
||||
msg = _("File to insert [from %s]");
|
||||
#ifndef NANO_TINY
|
||||
if ISSET(NO_CONVERT)
|
||||
msg = _("File to insert unconverted [from %s]");
|
||||
else
|
||||
#endif
|
||||
msg = _("File to insert [from %s]");
|
||||
}
|
||||
|
||||
present_path = mallocstrcpy(present_path, "./");
|
||||
@@ -1092,6 +1149,10 @@ void do_insertfile(void)
|
||||
}
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
if (func == flip_convert) {
|
||||
TOGGLE(NO_CONVERT);
|
||||
continue;
|
||||
}
|
||||
if (func == flip_execute) {
|
||||
execute = !execute;
|
||||
continue;
|
||||
@@ -1112,18 +1173,7 @@ void do_insertfile(void)
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
if (func == flip_pipe) {
|
||||
/* Remove or add the pipe character at the answer's head. */
|
||||
if (answer[0] == '|') {
|
||||
charmove(answer, answer + 1, strlen(answer) + 1);
|
||||
if (statusbar_x > 0)
|
||||
statusbar_x--;
|
||||
} else {
|
||||
answer = charealloc(answer, strlen(answer) + 2);
|
||||
charmove(answer + 1, answer, strlen(answer) + 1);
|
||||
answer[0] = '|';
|
||||
statusbar_x++;
|
||||
}
|
||||
|
||||
add_or_remove_pipe_symbol_from_answer();
|
||||
given = mallocstrcpy(given, answer);
|
||||
continue;
|
||||
}
|
||||
@@ -1773,6 +1823,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
||||
umask(original_umask);
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If we're prepending, copy the file to a temp file. */
|
||||
if (method == PREPEND) {
|
||||
int fd_source;
|
||||
@@ -1819,6 +1870,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
if (f_open == NULL) {
|
||||
/* Now open the file in place. Use O_EXCL if tmp is TRUE. This
|
||||
@@ -1900,6 +1952,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
||||
lineswritten++;
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If we're prepending, open the temp file, and append it to f. */
|
||||
if (method == PREPEND) {
|
||||
int fd_source;
|
||||
@@ -1927,7 +1980,9 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
||||
}
|
||||
|
||||
unlink(tempname);
|
||||
} else if (fclose(f) != 0) {
|
||||
} else
|
||||
#endif
|
||||
if (fclose(f) != 0) {
|
||||
statusline(ALERT, _("Error writing %s: %s"), realname,
|
||||
strerror(errno));
|
||||
goto cleanup_and_exit;
|
||||
@@ -2156,8 +2211,12 @@ int do_writeout(bool exiting, bool withprompt)
|
||||
* egg. Display the credits. */
|
||||
if (!did_credits && exiting && !ISSET(TEMP_FILE) &&
|
||||
strcasecmp(answer, "zzy") == 0) {
|
||||
do_credits();
|
||||
did_credits = TRUE;
|
||||
if (LINES > 5 && COLS > 31) {
|
||||
do_credits();
|
||||
did_credits = TRUE;
|
||||
} else
|
||||
/* TRANSLATORS: Concisely say the screen is too small. */
|
||||
statusbar(_("Too tiny"));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
449
src/global.c
449
src/global.c
@@ -69,6 +69,7 @@ int didfind = 0;
|
||||
/* Whether the last search found something. */
|
||||
|
||||
int controlleft, controlright, controlup, controldown, controlhome, controlend;
|
||||
int controldelete, controlshiftdelete;
|
||||
#ifndef NANO_TINY
|
||||
int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown;
|
||||
int shiftcontrolhome, shiftcontrolend;
|
||||
@@ -77,12 +78,8 @@ int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
ssize_t fill = 0;
|
||||
ssize_t fill = -COLUMNS_FROM_EOL;
|
||||
/* The column where we will wrap lines. */
|
||||
ssize_t wrap_at = -CHARS_FROM_EOL;
|
||||
/* The position where we will wrap lines. fill is equal to this
|
||||
* if it's greater than zero, and equal to (COLS + this) if it
|
||||
* isn't. */
|
||||
#endif
|
||||
|
||||
char *last_search = NULL;
|
||||
@@ -152,8 +149,6 @@ char *word_chars = NULL;
|
||||
|
||||
char *answer = NULL;
|
||||
/* The answer string used by the statusbar prompt. */
|
||||
size_t statusbar_x = HIGHEST_POSITIVE;
|
||||
/* The cursor position in answer. */
|
||||
|
||||
ssize_t tabsize = -1;
|
||||
/* The width of a tab in spaces. The default is set in main(). */
|
||||
@@ -234,19 +229,33 @@ regmatch_t regmatches[10];
|
||||
int hilite_attribute = A_REVERSE;
|
||||
/* The curses attribute we use to highlight something. */
|
||||
#ifdef ENABLE_COLOR
|
||||
colortype* color_combo[] = {NULL};
|
||||
colortype* color_combo[NUMBER_OF_ELEMENTS] = {NULL};
|
||||
/* The color combinations for interface elements given in the rcfile. */
|
||||
#endif
|
||||
int interface_color_pair[] = {0};
|
||||
int interface_color_pair[NUMBER_OF_ELEMENTS] = {0};
|
||||
/* The processed color pairs for the interface elements. */
|
||||
|
||||
char *homedir = NULL;
|
||||
/* The user's home directory, from $HOME or /etc/passwd. */
|
||||
char *statedir = NULL;
|
||||
/* The directory for nano's history files. */
|
||||
|
||||
#ifdef ENABLE_NANORC
|
||||
#define NUMBER_OF_MENUS 16
|
||||
char *menunames[NUMBER_OF_MENUS] = { "main", "search", "replace", "replacewith",
|
||||
"yesno", "gotoline", "writeout", "insert",
|
||||
"extcmd", "help", "spell", "linter",
|
||||
"browser", "whereisfile", "gotodir",
|
||||
"all" };
|
||||
int menusymbols[NUMBER_OF_MENUS] = { MMAIN, MWHEREIS, MREPLACE, MREPLACEWITH,
|
||||
MYESNO, MGOTOLINE, MWRITEFILE, MINSERTFILE,
|
||||
MEXTCMD, MHELP, MSPELL, MLINTER,
|
||||
MBROWSER, MWHEREISFILE, MGOTODIR,
|
||||
MMOST|MHELP|MYESNO };
|
||||
|
||||
char *rcfile_with_errors = NULL;
|
||||
/* The first nanorc file, if any, that produced warnings. */
|
||||
|
||||
#endif
|
||||
|
||||
/* Return the number of entries in the shortcut list for a given menu. */
|
||||
size_t length_of_list(int menu)
|
||||
@@ -316,6 +325,9 @@ void flip_execute(void)
|
||||
void flip_pipe(void)
|
||||
{
|
||||
}
|
||||
void flip_convert(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
void flip_newbuffer(void)
|
||||
@@ -450,20 +462,24 @@ int keycode_from_string(const char *keystring)
|
||||
if (keystring[0] == '^') {
|
||||
if (strcasecmp(keystring, "^Space") == 0)
|
||||
return 0;
|
||||
if (strlen(keystring) == 2)
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
|
||||
if (strcasecmp(keystring, "^H") == 0)
|
||||
return KEY_BACKSPACE;
|
||||
#endif
|
||||
if (keystring[1] <= '_' && strlen(keystring) == 2)
|
||||
return keystring[1] - 64;
|
||||
else
|
||||
return -1;
|
||||
} else if (keystring[0] == 'M') {
|
||||
if (strcasecmp(keystring, "M-Space") == 0)
|
||||
return (int)' ';
|
||||
if (keystring[1] == '-')
|
||||
if (keystring[1] == '-' && strlen(keystring) == 3)
|
||||
return tolower((unsigned char)keystring[2]);
|
||||
else
|
||||
return -1;
|
||||
} else if (keystring[0] == 'F') {
|
||||
int fn = atoi(&keystring[1]);
|
||||
if (fn < 0 || fn > 63)
|
||||
if (fn < 1 || fn > 16)
|
||||
return -1;
|
||||
return KEY_F0 + fn;
|
||||
} else if (!strcasecmp(keystring, "Ins"))
|
||||
@@ -491,7 +507,7 @@ void print_sclist(void)
|
||||
#endif
|
||||
|
||||
/* These four tags are used elsewhere too, so they are global. */
|
||||
/* TRANSLATORS: Try to keep the next fifteen strings at most 10 characters. */
|
||||
/* TRANSLATORS: Try to keep the next four strings at most 10 characters. */
|
||||
const char *exit_tag = N_("Exit");
|
||||
const char *close_tag = N_("Close");
|
||||
const char *uncut_tag = N_("Uncut Text");
|
||||
@@ -502,22 +518,6 @@ const char *unjust_tag = N_("Unjustify");
|
||||
/* Initialize the list of functions and the list of shortcuts. */
|
||||
void shortcut_init(void)
|
||||
{
|
||||
const char *readfile_tag = N_("Read File");
|
||||
const char *whereis_tag = N_("Where Is");
|
||||
const char *replace_tag = N_("Replace");
|
||||
const char *gotoline_tag = N_("Go To Line");
|
||||
const char *prevline_tag = N_("Prev Line");
|
||||
const char *nextline_tag = N_("Next Line");
|
||||
const char *prevpage_tag = N_("Prev Page");
|
||||
const char *nextpage_tag = N_("Next Page");
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
const char *justify_tag = N_("Justify");
|
||||
const char *fulljustify_tag = N_("FullJstify");
|
||||
#endif
|
||||
const char *refresh_tag = N_("Refresh");
|
||||
/* TRANSLATORS: Try to keep this string at most 12 characters. */
|
||||
const char *whereisnext_tag = N_("WhereIs Next");
|
||||
|
||||
#ifdef ENABLE_HELP
|
||||
/* TRANSLATORS: The next long series of strings are shortcut descriptions;
|
||||
* they are best kept shorter than 56 characters, but may be longer. */
|
||||
@@ -534,7 +534,8 @@ void shortcut_init(void)
|
||||
const char *wherewas_gist =
|
||||
N_("Search backward for a string or a regular expression");
|
||||
#ifdef ENABLE_BROWSER
|
||||
const char *browserwhereis_gist = N_("Search for a string");
|
||||
const char *browserwhereis_gist = N_("Search forward for a string");
|
||||
const char *browserwherewas_gist = N_("Search backward for a string");
|
||||
const char *browserrefresh_gist = N_("Refresh the file list");
|
||||
#ifndef NANO_TINY
|
||||
const char *browserlefthand_gist = N_("Go to lefthand column");
|
||||
@@ -555,7 +556,6 @@ void shortcut_init(void)
|
||||
#endif
|
||||
const char *replace_gist = N_("Replace a string or a regular expression");
|
||||
const char *gotoline_gist = N_("Go to line and column number");
|
||||
const char *whereisnext_gist = N_("Repeat the last search");
|
||||
#ifndef NANO_TINY
|
||||
const char *mark_gist = N_("Mark text starting from the cursor position");
|
||||
const char *copy_gist =
|
||||
@@ -630,9 +630,9 @@ void shortcut_init(void)
|
||||
N_("Comment/uncomment the current line (or marked lines)");
|
||||
#endif
|
||||
const char *savefile_gist = N_("Save file without prompting");
|
||||
#ifndef NANO_TINY
|
||||
const char *findprev_gist = N_("Search next occurrence backward");
|
||||
const char *findnext_gist = N_("Search next occurrence forward");
|
||||
#ifndef NANO_TINY
|
||||
const char *recordmacro_gist = N_("Start/stop recording a macro");
|
||||
const char *runmacro_gist = N_("Run the last recorded macro");
|
||||
#endif
|
||||
@@ -657,6 +657,7 @@ void shortcut_init(void)
|
||||
const char *execute_gist = N_("Execute external command");
|
||||
const char *pipe_gist =
|
||||
N_("Pipe the current buffer (or marked region) to the command");
|
||||
const char *convert_gist = N_("Do not convert from DOS/Mac format");
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
const char *newbuffer_gist = N_("Toggle the use of a new buffer");
|
||||
@@ -675,9 +676,6 @@ void shortcut_init(void)
|
||||
const char *lint_gist = N_("Invoke the linter, if available");
|
||||
const char *prevlint_gist = N_("Go to previous linter msg");
|
||||
const char *nextlint_gist = N_("Go to next linter msg");
|
||||
#ifdef ENABLE_SPELLER
|
||||
const char *formatter_gist = N_("Invoke formatter, if available");
|
||||
#endif
|
||||
#endif
|
||||
#endif /* ENABLE_HELP */
|
||||
|
||||
@@ -690,7 +688,8 @@ void shortcut_init(void)
|
||||
/* Start populating the different menus with functions. */
|
||||
|
||||
add_to_funcs(do_help_void, MMOST & ~MFINDINHELP,
|
||||
/* TRANSLATORS: Try to keep the following strings at most 10 characters. */
|
||||
/* TRANSLATORS: Try to keep the next ninety strings or so at most 10
|
||||
* characters. Some strings may be longer -- run nano and see. */
|
||||
N_("Get Help"), WITHORSANS(help_gist), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(do_cancel, ((MMOST & ~MMAIN & ~MBROWSER) | MYESNO),
|
||||
@@ -717,7 +716,7 @@ void shortcut_init(void)
|
||||
if (TRUE) {
|
||||
#endif
|
||||
add_to_funcs(do_insertfile_void, MMAIN,
|
||||
readfile_tag, WITHORSANS(readfile_gist), BLANKAFTER,
|
||||
N_("Read File"), WITHORSANS(readfile_gist), BLANKAFTER,
|
||||
/* We allow inserting files in view mode if multibuffer mode
|
||||
* is switched on, so that we can view multiple files. */
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
@@ -728,38 +727,29 @@ void shortcut_init(void)
|
||||
} else {
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_funcs(do_justify_void, MMAIN,
|
||||
justify_tag, WITHORSANS(justify_gist), BLANKAFTER, NOVIEW);
|
||||
N_("Justify"), WITHORSANS(justify_gist), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
}
|
||||
|
||||
add_to_funcs(do_search_forward, MMAIN,
|
||||
whereis_tag, WITHORSANS(whereis_gist), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(do_replace, MMAIN,
|
||||
replace_tag, WITHORSANS(replace_gist), TOGETHER, NOVIEW);
|
||||
|
||||
#ifdef ENABLE_BROWSER
|
||||
add_to_funcs(do_search_forward, MBROWSER,
|
||||
whereis_tag, WITHORSANS(browserwhereis_gist), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(do_research, MBROWSER,
|
||||
whereisnext_tag, WITHORSANS(whereisnext_gist), BLANKAFTER, VIEW);
|
||||
|
||||
add_to_funcs(goto_dir_void, MBROWSER,
|
||||
N_("Go To Dir"), WITHORSANS(gotodir_gist), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(total_refresh, MBROWSER,
|
||||
refresh_tag, WITHORSANS(browserrefresh_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_HELP
|
||||
/* The description ("x") and blank_after (0) are irrelevant,
|
||||
* because the help viewer does not have a help text. */
|
||||
add_to_funcs(total_refresh, MHELP, refresh_tag, "x", 0, VIEW);
|
||||
add_to_funcs(total_refresh, MHELP, N_("Refresh"), "x", 0, VIEW);
|
||||
add_to_funcs(do_exit, MHELP, close_tag, "x", 0, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_search_forward, MHELP, whereis_tag, "x", 0, VIEW);
|
||||
add_to_funcs(do_research, MHELP, whereisnext_tag, "x", 0, VIEW);
|
||||
add_to_funcs(do_search_forward, MMAIN|MHELP,
|
||||
N_("Where Is"), WITHORSANS(whereis_gist), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(do_replace, MMAIN,
|
||||
N_("Replace"), WITHORSANS(replace_gist), TOGETHER, NOVIEW);
|
||||
|
||||
#ifdef ENABLE_BROWSER
|
||||
add_to_funcs(goto_dir_void, MBROWSER,
|
||||
N_("Go To Dir"), WITHORSANS(gotodir_gist), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(total_refresh, MBROWSER,
|
||||
N_("Refresh"), WITHORSANS(browserrefresh_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_cut_text_void, MMAIN,
|
||||
@@ -773,7 +763,7 @@ void shortcut_init(void)
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_funcs(do_justify_void, MMAIN,
|
||||
justify_tag, WITHORSANS(justify_gist), TOGETHER, NOVIEW);
|
||||
N_("Justify"), WITHORSANS(justify_gist), TOGETHER, NOVIEW);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SPELLER
|
||||
@@ -783,10 +773,6 @@ void shortcut_init(void)
|
||||
#ifdef ENABLE_COLOR
|
||||
add_to_funcs(do_linter, MMAIN,
|
||||
N_("To Linter"), WITHORSANS(lint_gist), TOGETHER, NOVIEW);
|
||||
#ifdef ENABLE_SPELLER
|
||||
add_to_funcs(do_formatter, MMAIN,
|
||||
N_("Formatter"), WITHORSANS(formatter_gist), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -798,7 +784,7 @@ void shortcut_init(void)
|
||||
/* Conditionally placing this one here or further on, to keep the
|
||||
* help items nicely paired in most conditions. */
|
||||
add_to_funcs(do_gotolinecolumn_void, MMAIN,
|
||||
gotoline_tag, WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
|
||||
N_("Go To Line"), WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -821,33 +807,44 @@ void shortcut_init(void)
|
||||
N_("Backwards"), WITHORSANS(reverse_gist), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(flip_replace, MWHEREIS,
|
||||
replace_tag, WITHORSANS(replace_gist), BLANKAFTER, VIEW);
|
||||
N_("Replace"), WITHORSANS(replace_gist), BLANKAFTER, VIEW);
|
||||
|
||||
add_to_funcs(flip_replace, MREPLACE,
|
||||
N_("No Replace"), WITHORSANS(whereis_gist), BLANKAFTER, VIEW);
|
||||
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_funcs(do_full_justify, MWHEREIS,
|
||||
fulljustify_tag, WITHORSANS(fulljustify_gist), TOGETHER, NOVIEW);
|
||||
N_("FullJstify"), WITHORSANS(fulljustify_gist), TOGETHER, NOVIEW);
|
||||
|
||||
add_to_funcs(flip_goto, MWHEREIS,
|
||||
gotoline_tag, WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
|
||||
N_("Go To Line"), WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(do_find_bracket, MMAIN,
|
||||
N_("To Bracket"), WITHORSANS(bracket_gist), BLANKAFTER, VIEW);
|
||||
#else
|
||||
/* Place this one here only in the tiny version; otherwise further down. */
|
||||
add_to_funcs(do_savefile, MMAIN,
|
||||
N_("Save"), WITHORSANS(savefile_gist), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_research, MMAIN,
|
||||
whereisnext_tag, WITHORSANS(whereisnext_gist), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(do_findprevious, MMAIN,
|
||||
#ifdef ENABLE_BROWSER
|
||||
add_to_funcs(do_search_forward, MBROWSER,
|
||||
N_("Where Is"), WITHORSANS(browserwhereis_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(do_search_backward, MBROWSER,
|
||||
N_("Where Was"), WITHORSANS(browserwherewas_gist), TOGETHER, VIEW);
|
||||
#endif
|
||||
add_to_funcs(do_search_backward, MMAIN|MHELP,
|
||||
/* TRANSLATORS: This starts a backward search. */
|
||||
N_("Where Was"), WITHORSANS(wherewas_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(do_findprevious, MMAIN|MHELP|MBROWSER,
|
||||
N_("Previous"), WITHORSANS(findprev_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(do_findnext, MMAIN,
|
||||
add_to_funcs(do_findnext, MMAIN|MHELP|MBROWSER,
|
||||
N_("Next"), WITHORSANS(findnext_gist), BLANKAFTER, VIEW);
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
add_to_funcs(do_left, MMAIN,
|
||||
/* TRANSLATORS: This means move the cursor one character back. */
|
||||
N_("Back"), WITHORSANS(back_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(do_right, MMAIN,
|
||||
N_("Forward"), WITHORSANS(forward_gist), TOGETHER, VIEW);
|
||||
@@ -869,9 +866,9 @@ void shortcut_init(void)
|
||||
N_("End"), WITHORSANS(end_gist), BLANKAFTER, VIEW);
|
||||
|
||||
add_to_funcs(do_up, MMAIN|MHELP|MBROWSER,
|
||||
prevline_tag, WITHORSANS(prevline_gist), TOGETHER, VIEW);
|
||||
N_("Prev Line"), WITHORSANS(prevline_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(do_down, MMAIN|MHELP|MBROWSER,
|
||||
nextline_tag, WITHORSANS(nextline_gist), TOGETHER, VIEW);
|
||||
N_("Next Line"), WITHORSANS(nextline_gist), TOGETHER, VIEW);
|
||||
#ifdef ENABLE_HELP
|
||||
add_to_funcs(do_scroll_up, MMAIN,
|
||||
N_("Scroll Up"), WITHORSANS(scrollup_gist), TOGETHER, VIEW);
|
||||
@@ -891,9 +888,9 @@ void shortcut_init(void)
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_page_up, MMAIN|MHELP,
|
||||
prevpage_tag, WITHORSANS(prevpage_gist), TOGETHER, VIEW);
|
||||
N_("Prev Page"), WITHORSANS(prevpage_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(do_page_down, MMAIN|MHELP,
|
||||
nextpage_tag, WITHORSANS(nextpage_gist), TOGETHER, VIEW);
|
||||
N_("Next Page"), WITHORSANS(nextpage_gist), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(to_first_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
|
||||
N_("First Line"), WITHORSANS(firstline_gist), TOGETHER, VIEW);
|
||||
@@ -910,13 +907,7 @@ void shortcut_init(void)
|
||||
#if (!defined(ENABLE_JUSTIFY) && (defined(ENABLE_SPELLER) || defined(ENABLE_COLOR)) || \
|
||||
defined(ENABLE_JUSTIFY) && !defined(ENABLE_SPELLER) && !defined(ENABLE_COLOR))
|
||||
add_to_funcs(do_gotolinecolumn_void, MMAIN,
|
||||
gotoline_tag, WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
#ifdef NANO_TINY
|
||||
/* Place this one here only in the tiny version; otherwise further up. */
|
||||
add_to_funcs(do_research, MMAIN,
|
||||
whereisnext_tag, WITHORSANS(whereisnext_gist), TOGETHER, VIEW);
|
||||
N_("Go To Line"), WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(do_tab, MMAIN,
|
||||
@@ -947,7 +938,7 @@ void shortcut_init(void)
|
||||
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_funcs(do_full_justify, MMAIN,
|
||||
fulljustify_tag, WITHORSANS(fulljustify_gist), TOGETHER, NOVIEW);
|
||||
N_("FullJstify"), WITHORSANS(fulljustify_gist), TOGETHER, NOVIEW);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -959,16 +950,16 @@ void shortcut_init(void)
|
||||
N_("Verbatim"), WITHORSANS(verbatim_gist), BLANKAFTER, NOVIEW);
|
||||
|
||||
add_to_funcs(total_refresh, MMAIN,
|
||||
refresh_tag, WITHORSANS(refresh_gist), TOGETHER, VIEW);
|
||||
N_("Refresh"), WITHORSANS(refresh_gist), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(do_suspend_void, MMAIN,
|
||||
N_("Suspend"), WITHORSANS(suspend_gist), BLANKAFTER, VIEW);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(do_indent, MMAIN,
|
||||
N_("Indent Text"), WITHORSANS(indent_gist), TOGETHER, NOVIEW);
|
||||
N_("Indent"), WITHORSANS(indent_gist), TOGETHER, NOVIEW);
|
||||
add_to_funcs(do_unindent, MMAIN,
|
||||
N_("Unindent Text"), WITHORSANS(unindent_gist), BLANKAFTER, NOVIEW);
|
||||
N_("Unindent"), WITHORSANS(unindent_gist), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
#ifdef ENABLE_COMMENT
|
||||
add_to_funcs(do_comment, MMAIN,
|
||||
@@ -983,14 +974,10 @@ void shortcut_init(void)
|
||||
N_("Record"), WITHORSANS(recordmacro_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(run_macro, MMAIN,
|
||||
N_("Run Macro"), WITHORSANS(runmacro_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
add_to_funcs(do_search_backward, MMAIN,
|
||||
/* TRANSLATORS: This starts a backward search. */
|
||||
N_("Where Was"), WITHORSANS(wherewas_gist), BLANKAFTER, VIEW);
|
||||
|
||||
add_to_funcs(do_savefile, MMAIN,
|
||||
N_("Save"), WITHORSANS(savefile_gist), BLANKAFTER, NOVIEW);
|
||||
|
||||
#endif
|
||||
#ifdef ENABLE_HISTORIES
|
||||
add_to_funcs(get_history_older_void, MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE,
|
||||
N_("PrevHstory"), WITHORSANS(prevhistory_gist), TOGETHER, VIEW);
|
||||
@@ -1000,7 +987,7 @@ void shortcut_init(void)
|
||||
|
||||
#ifndef ENABLE_JUSTIFY
|
||||
add_to_funcs(flip_goto, MWHEREIS,
|
||||
gotoline_tag, WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
|
||||
N_("Go To Line"), WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(flip_goto, MGOTOLINE,
|
||||
@@ -1025,15 +1012,6 @@ void shortcut_init(void)
|
||||
add_to_funcs(backup_file_void, MWRITEFILE,
|
||||
N_("Backup File"), WITHORSANS(backup_gist), BLANKAFTER, NOVIEW);
|
||||
}
|
||||
|
||||
/* Command execution is only available when not in restricted mode. */
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
add_to_funcs(flip_execute, MINSERTFILE,
|
||||
N_("Execute Command"), WITHORSANS(execute_gist), TOGETHER, NOVIEW);
|
||||
|
||||
add_to_funcs(flip_execute, MEXTCMD,
|
||||
readfile_tag, WITHORSANS(readfile_gist), TOGETHER, NOVIEW);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* Multiple buffers are only available when not in restricted mode. */
|
||||
@@ -1042,9 +1020,20 @@ void shortcut_init(void)
|
||||
N_("New Buffer"), WITHORSANS(newbuffer_gist), TOGETHER, NOVIEW);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
if (!ISSET(RESTRICTED))
|
||||
add_to_funcs(flip_convert, MINSERTFILE,
|
||||
N_("No Conversion"), WITHORSANS(convert_gist), TOGETHER, NOVIEW);
|
||||
|
||||
/* Command execution is only available when not in restricted mode. */
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
add_to_funcs(flip_execute, MINSERTFILE,
|
||||
N_("Execute Command"), WITHORSANS(execute_gist), TOGETHER, NOVIEW);
|
||||
|
||||
add_to_funcs(flip_pipe, MEXTCMD,
|
||||
N_("Pipe Text"), WITHORSANS(pipe_gist), TOGETHER, NOVIEW);
|
||||
|
||||
add_to_funcs(flip_execute, MEXTCMD,
|
||||
N_("Read File"), WITHORSANS(readfile_gist), TOGETHER, NOVIEW);
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_BROWSER
|
||||
/* The file browser is only available when not in restricted mode. */
|
||||
@@ -1053,9 +1042,9 @@ void shortcut_init(void)
|
||||
N_("To Files"), WITHORSANS(tofiles_gist), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(do_page_up, MBROWSER,
|
||||
prevpage_tag, WITHORSANS(prevpage_gist), TOGETHER, VIEW);
|
||||
N_("Prev Page"), WITHORSANS(prevpage_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(do_page_down, MBROWSER,
|
||||
nextpage_tag, WITHORSANS(nextpage_gist), TOGETHER, VIEW);
|
||||
N_("Prev Page"), WITHORSANS(nextpage_gist), TOGETHER, VIEW);
|
||||
|
||||
add_to_funcs(to_first_file, MBROWSER|MWHEREISFILE,
|
||||
N_("First File"), WITHORSANS(firstfile_gist), TOGETHER, VIEW);
|
||||
@@ -1091,6 +1080,11 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMOST, "Bsp", KEY_BACKSPACE, do_backspace, 0);
|
||||
add_to_sclist(MMOST, "^D", 0, do_delete, 0);
|
||||
add_to_sclist(MMOST, "Del", 0, do_delete, 0);
|
||||
/* Make ASCII DEL do a delete when requested, otherwise a backspace. */
|
||||
if (ISSET(REBIND_DELETE))
|
||||
add_to_sclist(MMOST, "Del", DEL_CODE, do_delete, 0);
|
||||
else
|
||||
add_to_sclist(MMOST, "Bsp", DEL_CODE, do_backspace, 0);
|
||||
add_to_sclist(MMOST, "^I", 0, do_tab, 0);
|
||||
add_to_sclist(MMOST, "Tab", TAB_CODE, do_tab, 0);
|
||||
add_to_sclist(MMOST & ~MFINDINHELP, "^G", 0, do_help_void, 0);
|
||||
@@ -1103,7 +1097,7 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN, "^R", 0, do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN, "F5", 0, do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN, "Ins", 0, do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN, "^Q", 0, do_search_backward, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "^Q", 0, do_search_backward, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "^W", 0, do_search_forward, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "F6", 0, do_search_forward, 0);
|
||||
add_to_sclist(MMAIN, "^\\", 0, do_replace, 0);
|
||||
@@ -1132,20 +1126,19 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN, "M-G", 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN, "F13", 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^Y", 0, do_page_up, 0);
|
||||
add_to_sclist(MHELP|MBROWSER, "Bsp", KEY_BACKSPACE, do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F7", 0, do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgUp", KEY_PPAGE, do_page_up, 0);
|
||||
add_to_sclist(MHELP|MBROWSER, "Bsp", KEY_BACKSPACE, do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^V", 0, do_page_down, 0);
|
||||
add_to_sclist(MHELP|MBROWSER, "Space", 0x20, do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F8", 0, do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgDn", KEY_NPAGE, do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-\\", 0, to_first_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "^Home", CONTROL_HOME, to_first_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-|", 0, to_first_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-/", 0, to_last_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "^End", CONTROL_END, to_last_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-?", 0, to_last_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "M-W", 0, do_research, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "F16", 0, do_research, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "M-W", 0, do_findnext, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER, "M-Q", 0, do_findprevious, 0);
|
||||
#ifndef NANO_TINY
|
||||
add_to_sclist(MMAIN, "M-]", 0, do_find_bracket, 0);
|
||||
add_to_sclist(MMAIN, "M-A", 0, do_mark, 0);
|
||||
@@ -1162,6 +1155,8 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN, "M-;", 0, run_macro, 0);
|
||||
add_to_sclist(MMAIN, "M-U", 0, do_undo, 0);
|
||||
add_to_sclist(MMAIN, "M-E", 0, do_redo, 0);
|
||||
add_to_sclist(MMAIN, "M-|", 0, do_cut_prev_word, 0);
|
||||
add_to_sclist(MMAIN, "^Del", CONTROL_DELETE, do_cut_next_word, 0);
|
||||
#endif
|
||||
#ifdef ENABLE_WORDCOMPLETION
|
||||
add_to_sclist(MMAIN, "^]", 0, complete_a_word, 0);
|
||||
@@ -1250,7 +1245,6 @@ void shortcut_init(void)
|
||||
/* Group of "Appearance" toggles. */
|
||||
add_to_sclist(MMAIN, "M-X", 0, do_toggle_void, NO_HELP);
|
||||
add_to_sclist(MMAIN, "M-C", 0, do_toggle_void, CONSTANT_SHOW);
|
||||
add_to_sclist(MMAIN, "M-O", 0, do_toggle_void, MORE_SPACE);
|
||||
add_to_sclist(MMAIN, "M-S", 0, do_toggle_void, SMOOTH_SCROLL);
|
||||
add_to_sclist(MMAIN, "M-$", 0, do_toggle_void, SOFTWRAP);
|
||||
#ifdef ENABLE_LINENUMBERS
|
||||
@@ -1268,17 +1262,12 @@ void shortcut_init(void)
|
||||
#ifdef ENABLE_WRAPPING
|
||||
add_to_sclist(MMAIN, "M-L", 0, do_toggle_void, NO_WRAP);
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "M-Q", 0, do_toggle_void, TABS_TO_SPACES);
|
||||
add_to_sclist(MMAIN, "M-O", 0, do_toggle_void, TABS_TO_SPACES);
|
||||
|
||||
/* Group of "Peripheral-feature" toggles. */
|
||||
add_to_sclist(MMAIN, "M-B", 0, do_toggle_void, BACKUP_FILE);
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
add_to_sclist(MMAIN, "M-F", 0, do_toggle_void, MULTIBUFFER);
|
||||
#endif
|
||||
#ifdef ENABLE_MOUSE
|
||||
add_to_sclist(MMAIN, "M-M", 0, do_toggle_void, USE_MOUSE);
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "M-N", 0, do_toggle_void, NO_CONVERT);
|
||||
add_to_sclist(MMAIN, "M-Z", 0, do_toggle_void, SUSPEND);
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
@@ -1316,8 +1305,6 @@ void shortcut_init(void)
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-/", 0, to_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "Home", KEY_HOME, to_first_file, 0);
|
||||
add_to_sclist(MBROWSER, "End", KEY_END, to_last_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", 0, to_first_file, 0);
|
||||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", 0, to_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "^Home", CONTROL_HOME, to_first_file, 0);
|
||||
add_to_sclist(MBROWSER, "^End", CONTROL_END, to_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "^_", 0, goto_dir_void, 0);
|
||||
@@ -1337,6 +1324,7 @@ void shortcut_init(void)
|
||||
add_to_sclist(MWRITEFILE, "M-B", 0, backup_file_void, 0);
|
||||
add_to_sclist(MINSERTFILE|MEXTCMD, "^X", 0, flip_execute, 0);
|
||||
}
|
||||
add_to_sclist(MINSERTFILE, "M-N", 0, flip_convert, 0);
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* Only when not in restricted mode, allow multiple buffers. */
|
||||
@@ -1379,21 +1367,14 @@ void replace_scs_for(void (*oldfunc)(void), void (*newfunc)(void))
|
||||
s->func = newfunc;
|
||||
}
|
||||
|
||||
void set_lint_or_format_shortcuts(void)
|
||||
void set_linter_shortcut(void)
|
||||
{
|
||||
if (openfile->syntax->formatter) {
|
||||
replace_scs_for(do_spell, do_formatter);
|
||||
replace_scs_for(do_linter, do_formatter);
|
||||
} else {
|
||||
replace_scs_for(do_spell, do_linter);
|
||||
replace_scs_for(do_formatter, do_linter);
|
||||
}
|
||||
replace_scs_for(do_spell, do_linter);
|
||||
}
|
||||
|
||||
void set_spell_shortcuts(void)
|
||||
void set_speller_shortcut(void)
|
||||
{
|
||||
replace_scs_for(do_formatter, do_spell);
|
||||
replace_scs_for(do_linter, do_spell);
|
||||
replace_scs_for(do_linter, do_spell);
|
||||
}
|
||||
#endif /* ENABLE_COLOR && ENABLE_SPELLER */
|
||||
|
||||
@@ -1413,13 +1394,11 @@ const char *flagtostr(int flag)
|
||||
{
|
||||
switch (flag) {
|
||||
case NO_HELP:
|
||||
/* TRANSLATORS: The next eighteen strings are toggle descriptions;
|
||||
/* TRANSLATORS: The next fourteen strings are toggle descriptions;
|
||||
* they are best kept shorter than 40 characters, but may be longer. */
|
||||
return N_("Help mode");
|
||||
case CONSTANT_SHOW:
|
||||
return N_("Constant cursor position display");
|
||||
case MORE_SPACE:
|
||||
return N_("Use of one more line for editing");
|
||||
case SMOOTH_SCROLL:
|
||||
return N_("Smooth scrolling");
|
||||
case SOFTWRAP:
|
||||
@@ -1438,14 +1417,8 @@ const char *flagtostr(int flag)
|
||||
return N_("Hard wrapping of overlong lines");
|
||||
case TABS_TO_SPACES:
|
||||
return N_("Conversion of typed tabs to spaces");
|
||||
case BACKUP_FILE:
|
||||
return N_("Backup files");
|
||||
case MULTIBUFFER:
|
||||
return N_("Reading file into separate buffer");
|
||||
case USE_MOUSE:
|
||||
return N_("Mouse support");
|
||||
case NO_CONVERT:
|
||||
return N_("No conversion from DOS/Mac format");
|
||||
case SUSPEND:
|
||||
return N_("Suspension");
|
||||
case LINE_NUMBERS:
|
||||
@@ -1458,7 +1431,7 @@ const char *flagtostr(int flag)
|
||||
|
||||
#ifdef ENABLE_NANORC
|
||||
/* Interpret a function string given in the rc file, and return a
|
||||
* shortcut struct with the corresponding function filled in. */
|
||||
* shortcut record with the corresponding function filled in. */
|
||||
sc *strtosc(const char *input)
|
||||
{
|
||||
sc *s = nmalloc(sizeof(sc));
|
||||
@@ -1488,24 +1461,22 @@ sc *strtosc(const char *input)
|
||||
s->func = do_search_forward;
|
||||
else if (!strcasecmp(input, "wherewas"))
|
||||
s->func = do_search_backward;
|
||||
else if (!strcasecmp(input, "searchagain"))
|
||||
s->func = do_research;
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcasecmp(input, "findprevious"))
|
||||
s->func = do_findprevious;
|
||||
else if (!strcasecmp(input, "findnext"))
|
||||
s->func = do_findnext;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "replace"))
|
||||
s->func = do_replace;
|
||||
else if (!strcasecmp(input, "cut"))
|
||||
s->func = do_cut_text_void;
|
||||
else if (!strcasecmp(input, "uncut"))
|
||||
else if (!strcasecmp(input, "paste") ||
|
||||
!strcasecmp(input, "uncut")) /* Deprecated. Remove end of 2018. */
|
||||
s->func = do_uncut_text;
|
||||
#ifndef NANO_TINY
|
||||
else if (!strcasecmp(input, "cutrestoffile"))
|
||||
s->func = do_cut_till_eof;
|
||||
else if (!strcasecmp(input, "copytext"))
|
||||
else if (!strcasecmp(input, "copy") ||
|
||||
!strcasecmp(input, "copytext")) /* Deprecated. Remove end of 2018. */
|
||||
s->func = do_copy_text;
|
||||
else if (!strcasecmp(input, "mark"))
|
||||
s->func = do_mark;
|
||||
@@ -1655,6 +1626,8 @@ sc *strtosc(const char *input)
|
||||
s->func = flip_execute;
|
||||
else if (!strcasecmp(input, "flippipe"))
|
||||
s->func = flip_pipe;
|
||||
else if (!strcasecmp(input, "flipconvert"))
|
||||
s->func = flip_convert;
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
else if (!strcasecmp(input, "flipnewbuffer"))
|
||||
@@ -1679,8 +1652,6 @@ sc *strtosc(const char *input)
|
||||
else if (!strcasecmp(input, "constantshow") ||
|
||||
!strcasecmp(input, "constupdate")) /* Deprecated. Remove end of 2018. */
|
||||
s->toggle = CONSTANT_SHOW;
|
||||
else if (!strcasecmp(input, "morespace"))
|
||||
s->toggle = MORE_SPACE;
|
||||
else if (!strcasecmp(input, "smoothscroll"))
|
||||
s->toggle = SMOOTH_SCROLL;
|
||||
else if (!strcasecmp(input, "softwrap"))
|
||||
@@ -1708,18 +1679,10 @@ sc *strtosc(const char *input)
|
||||
#endif
|
||||
else if (!strcasecmp(input, "tabstospaces"))
|
||||
s->toggle = TABS_TO_SPACES;
|
||||
else if (!strcasecmp(input, "backupfile"))
|
||||
s->toggle = BACKUP_FILE;
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
else if (!strcasecmp(input, "multibuffer"))
|
||||
s->toggle = MULTIBUFFER;
|
||||
#endif
|
||||
#ifdef ENABLE_MOUSE
|
||||
else if (!strcasecmp(input, "mouse"))
|
||||
s->toggle = USE_MOUSE;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "noconvert"))
|
||||
s->toggle = NO_CONVERT;
|
||||
else if (!strcasecmp(input, "suspendenable"))
|
||||
s->toggle = SUSPEND;
|
||||
else
|
||||
@@ -1732,157 +1695,27 @@ sc *strtosc(const char *input)
|
||||
return s;
|
||||
}
|
||||
|
||||
/* Interpret a menu name and return the corresponding menu flag. */
|
||||
int strtomenu(const char *input)
|
||||
/* Return the symbol that corresponds to the given menu name. */
|
||||
int name_to_menu(const char *name)
|
||||
{
|
||||
if (!strcasecmp(input, "all"))
|
||||
return (MMOST|MHELP|MYESNO);
|
||||
else if (!strcasecmp(input, "main"))
|
||||
return MMAIN;
|
||||
else if (!strcasecmp(input, "search"))
|
||||
return MWHEREIS;
|
||||
else if (!strcasecmp(input, "replace"))
|
||||
return MREPLACE;
|
||||
else if (!strcasecmp(input, "replacewith"))
|
||||
return MREPLACEWITH;
|
||||
else if (!strcasecmp(input, "gotoline"))
|
||||
return MGOTOLINE;
|
||||
else if (!strcasecmp(input, "writeout"))
|
||||
return MWRITEFILE;
|
||||
else if (!strcasecmp(input, "insert"))
|
||||
return MINSERTFILE;
|
||||
else if (!strcasecmp(input, "externalcmd") ||
|
||||
!strcasecmp(input, "extcmd"))
|
||||
return MEXTCMD;
|
||||
#ifdef ENABLE_HELP
|
||||
else if (!strcasecmp(input, "help"))
|
||||
return MHELP;
|
||||
#endif
|
||||
#ifdef ENABLE_SPELLER
|
||||
else if (!strcasecmp(input, "spell"))
|
||||
return MSPELL;
|
||||
#endif
|
||||
else if (!strcasecmp(input, "linter"))
|
||||
return MLINTER;
|
||||
#ifdef ENABLE_BROWSER
|
||||
else if (!strcasecmp(input, "browser"))
|
||||
return MBROWSER;
|
||||
else if (!strcasecmp(input, "whereisfile"))
|
||||
return MWHEREISFILE;
|
||||
else if (!strcasecmp(input, "gotodir"))
|
||||
return MGOTODIR;
|
||||
#endif
|
||||
int index = -1;
|
||||
|
||||
while (++index < NUMBER_OF_MENUS)
|
||||
if (strcasecmp(name, menunames[index]) == 0)
|
||||
return menusymbols[index];
|
||||
|
||||
return -1;
|
||||
}
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
/* This function is used to gracefully return all the memory we've used.
|
||||
* It should be called just before calling exit(). Practically, the
|
||||
* only effect is to cause a segmentation fault if the various data
|
||||
* structures got bolloxed earlier. Thus, we don't bother having this
|
||||
* function unless debugging is turned on. */
|
||||
void thanks_for_all_the_fish(void)
|
||||
/* Return the name that corresponds to the given menu symbol. */
|
||||
char *menu_to_name(int menu)
|
||||
{
|
||||
if (topwin != NULL)
|
||||
delwin(topwin);
|
||||
delwin(edit);
|
||||
delwin(bottomwin);
|
||||
int index = -1;
|
||||
|
||||
free(word_chars);
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
free(quotestr);
|
||||
regfree("ereg);
|
||||
free(quoteerr);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
free(backup_dir);
|
||||
#endif
|
||||
#ifdef ENABLE_OPERATINGDIR
|
||||
free(operating_dir);
|
||||
#endif
|
||||
free(answer);
|
||||
free(last_search);
|
||||
free(present_path);
|
||||
#ifdef ENABLE_SPELLER
|
||||
free(alt_speller);
|
||||
#endif
|
||||
free_filestruct(cutbuffer);
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* Free the memory associated with each open file buffer. */
|
||||
while (openfile != openfile->next) {
|
||||
openfile = openfile->next;
|
||||
delete_opennode(openfile->prev);
|
||||
}
|
||||
delete_opennode(openfile);
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
free(syntaxstr);
|
||||
while (syntaxes != NULL) {
|
||||
syntaxtype *sint = syntaxes;
|
||||
syntaxes = syntaxes->next;
|
||||
while (++index < NUMBER_OF_MENUS)
|
||||
if (menusymbols[index] == menu)
|
||||
return menunames[index];
|
||||
|
||||
free(sint->name);
|
||||
free(sint->linter);
|
||||
free(sint->formatter);
|
||||
|
||||
while (sint->extensions != NULL) {
|
||||
regexlisttype *item = sint->extensions;
|
||||
sint->extensions = sint->extensions->next;
|
||||
free(item->full_regex);
|
||||
free(item);
|
||||
}
|
||||
while (sint->headers != NULL) {
|
||||
regexlisttype *item = sint->headers;
|
||||
sint->headers = sint->headers->next;
|
||||
free(item->full_regex);
|
||||
free(item);
|
||||
}
|
||||
while (sint->magics != NULL) {
|
||||
regexlisttype *item = sint->magics;
|
||||
sint->magics = sint->magics->next;
|
||||
free(item->full_regex);
|
||||
free(item);
|
||||
}
|
||||
|
||||
while (sint->color != NULL) {
|
||||
colortype *ink = sint->color;
|
||||
sint->color = sint->color->next;
|
||||
free(ink->start_regex);
|
||||
if (ink->start != NULL) {
|
||||
regfree(ink->start);
|
||||
free(ink->start);
|
||||
}
|
||||
free(ink->end_regex);
|
||||
if (ink->end != NULL) {
|
||||
regfree(ink->end);
|
||||
free(ink->end);
|
||||
}
|
||||
free(ink);
|
||||
}
|
||||
|
||||
free(sint);
|
||||
}
|
||||
#endif /* ENABLE_COLOR */
|
||||
#ifdef ENABLE_HISTORIES
|
||||
/* Free the search, replace, and execute history lists. */
|
||||
free_filestruct(searchtop);
|
||||
free_filestruct(replacetop);
|
||||
free_filestruct(executetop);
|
||||
#endif
|
||||
/* Free the list of functions. */
|
||||
while (allfuncs != NULL) {
|
||||
subnfunc *f = allfuncs;
|
||||
allfuncs = allfuncs->next;
|
||||
free(f);
|
||||
}
|
||||
/* Free the list of shortcuts. */
|
||||
while (sclist != NULL) {
|
||||
sc *s = sclist;
|
||||
sclist = sclist->next;
|
||||
free(s);
|
||||
}
|
||||
free(homedir);
|
||||
return "boooo";
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
||||
45
src/help.c
45
src/help.c
@@ -161,7 +161,6 @@ void do_help(void)
|
||||
didfind = 0;
|
||||
|
||||
bottombars(MHELP);
|
||||
wnoutrefresh(bottomwin);
|
||||
|
||||
/* Extract the title from the head of the help text. */
|
||||
length = break_line(help_text, MAX_BUF_SIZE, TRUE);
|
||||
@@ -206,11 +205,11 @@ void do_help(void)
|
||||
} else if (func == to_last_line) {
|
||||
to_last_line();
|
||||
} else if (func == do_search_forward) {
|
||||
do_search();
|
||||
do_search_forward();
|
||||
bottombars(MHELP);
|
||||
} else if (func == do_search_backward) {
|
||||
do_search_backward();
|
||||
bottombars(MHELP);
|
||||
} else if (func == do_research) {
|
||||
do_research();
|
||||
#ifndef NANO_TINY
|
||||
} else if (func == do_findprevious) {
|
||||
do_findprevious();
|
||||
} else if (func == do_findnext) {
|
||||
@@ -219,6 +218,7 @@ void do_help(void)
|
||||
} else if (func == (functionptrtype)implant) {
|
||||
implant(first_sc_for(MHELP, func)->expansion);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
} else if (kbinput == KEY_WINCH) {
|
||||
; /* Nothing to do. */
|
||||
#endif
|
||||
@@ -414,12 +414,13 @@ void help_init(void)
|
||||
htx[0] = N_("Execute Command Help Text\n\n "
|
||||
"This mode allows you to insert the output of a "
|
||||
"command run by the shell into the current buffer (or "
|
||||
"a new buffer in multiple file buffer mode). If you "
|
||||
"need another blank buffer, do not enter any "
|
||||
"command.\n\n The following function keys are "
|
||||
"into a new buffer). If the command is preceded by '|' "
|
||||
"(the pipe symbol), the current contents of the buffer "
|
||||
"(or marked region) will be piped to the command. ");
|
||||
htx[1] = N_("If you just need another blank buffer, do not enter any "
|
||||
"command.\n\n");
|
||||
htx[2] = N_(" The following function keys are "
|
||||
"available in Execute Command mode:\n\n");
|
||||
htx[1] = NULL;
|
||||
htx[2] = NULL;
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
else {
|
||||
@@ -498,28 +499,20 @@ void help_init(void)
|
||||
|
||||
/* Now add our shortcut info. */
|
||||
for (f = allfuncs; f != NULL; f = f->next) {
|
||||
int scsfound = 0;
|
||||
int tally = 0;
|
||||
|
||||
if ((f->menus & currmenu) == 0)
|
||||
continue;
|
||||
|
||||
/* Let's simply show the first two shortcuts from the list. */
|
||||
for (s = sclist; s != NULL; s = s->next) {
|
||||
|
||||
if ((s->menus & currmenu) == 0)
|
||||
continue;
|
||||
|
||||
if (s->func == f->func) {
|
||||
scsfound++;
|
||||
if ((s->menus & currmenu) && s->func == f->func) {
|
||||
/* Make the first column narrower (6) than the second (10),
|
||||
* but allow it to spill into the second, for "M-Space". */
|
||||
if (scsfound == 1) {
|
||||
if (++tally == 1) {
|
||||
sprintf(ptr, "%s ", s->keystr);
|
||||
/* Unicode arrows take three bytes instead of one. */
|
||||
if (strstr(s->keystr, "\xE2") != NULL)
|
||||
ptr += 8;
|
||||
else
|
||||
ptr += 6;
|
||||
ptr += (strstr(s->keystr, "\xE2") != NULL ? 8 : 6);
|
||||
} else {
|
||||
ptr += sprintf(ptr, "(%s)\t", s->keystr);
|
||||
break;
|
||||
@@ -527,9 +520,9 @@ void help_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (scsfound == 0)
|
||||
if (tally == 0)
|
||||
ptr += sprintf(ptr, "\t\t");
|
||||
else if (scsfound == 1)
|
||||
else if (tally == 1)
|
||||
ptr += 10;
|
||||
|
||||
/* The shortcut's help text. */
|
||||
@@ -582,11 +575,9 @@ functionptrtype parse_help_input(int *kbinput)
|
||||
case '/':
|
||||
return do_search_forward;
|
||||
case 'N':
|
||||
#ifndef NANO_TINY
|
||||
return do_findprevious;
|
||||
#endif
|
||||
case 'n':
|
||||
return do_research;
|
||||
return do_findnext;
|
||||
case 'E':
|
||||
case 'e':
|
||||
case 'Q':
|
||||
|
||||
54
src/nano.c
54
src/nano.c
@@ -465,11 +465,18 @@ void ingraft_buffer(filestruct *somebuffer)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <time.h>
|
||||
clock_t start = clock();
|
||||
#endif
|
||||
/* Add the number of characters in the copied text to the file size. */
|
||||
openfile->totsize += get_totsize(openfile->fileage, openfile->filebot);
|
||||
#ifdef DEBUG
|
||||
statusline(ALERT, "Took: %.2f", (double)(clock() - start) / CLOCKS_PER_SEC);
|
||||
#endif
|
||||
|
||||
/* If we pasted onto the first line of the edit window, the corresponding
|
||||
* struct has been freed, so... point at the start of the copied text. */
|
||||
* record has been freed, so... point at the start of the copied text. */
|
||||
if (edittop_inside)
|
||||
openfile->edittop = openfile->fileage;
|
||||
|
||||
@@ -559,6 +566,13 @@ void finish(void)
|
||||
blank_bottombars();
|
||||
wrefresh(bottomwin);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Deallocate the two or three subwindows. */
|
||||
if (topwin != NULL)
|
||||
delwin(topwin);
|
||||
delwin(edit);
|
||||
delwin(bottomwin);
|
||||
#endif
|
||||
/* Switch on the cursor and exit from curses mode. */
|
||||
curs_set(1);
|
||||
endwin();
|
||||
@@ -575,10 +589,6 @@ void finish(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
thanks_for_all_the_fish();
|
||||
#endif
|
||||
|
||||
/* Get out. */
|
||||
exit(0);
|
||||
}
|
||||
@@ -711,7 +721,6 @@ void window_init(void)
|
||||
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
/* Set up the wrapping point, accounting for screen width when negative. */
|
||||
fill = wrap_at;
|
||||
if (fill <= 0)
|
||||
fill += COLS;
|
||||
if (fill < 0)
|
||||
@@ -1061,10 +1070,6 @@ void do_exit(void)
|
||||
"(Answering \"No\" will DISCARD changes.) "));
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_filestruct(openfile->fileage);
|
||||
#endif
|
||||
|
||||
/* If the user chose not to save, or if the user chose to save and
|
||||
* the save succeeded, we're ready to exit. */
|
||||
if (i == 0 || (i == 1 && do_writeout(TRUE, TRUE) > 0))
|
||||
@@ -1258,6 +1263,9 @@ RETSIGTYPE do_suspend(int signal)
|
||||
/* Restore the old terminal settings. */
|
||||
tcsetattr(0, TCSANOW, &oldterm);
|
||||
|
||||
/* The suspend keystroke must not elicit cursor-position display. */
|
||||
suppress_cursorpos=TRUE;
|
||||
|
||||
#ifdef SIGSTOP
|
||||
/* Do what mutt does: send ourselves a SIGSTOP. */
|
||||
kill(0, SIGSTOP);
|
||||
@@ -1386,7 +1394,6 @@ void do_toggle(int flag)
|
||||
mouse_init();
|
||||
break;
|
||||
#endif
|
||||
case MORE_SPACE:
|
||||
case NO_HELP:
|
||||
window_init();
|
||||
focusing = FALSE;
|
||||
@@ -1577,7 +1584,7 @@ void unbound_key(int code)
|
||||
statusline(ALERT, _("Unbound key: M-%c"), toupper(code));
|
||||
} else if (code < 0x20)
|
||||
statusline(ALERT, _("Unbound key: ^%c"), code + 0x40);
|
||||
else if (currmenu != MHELP)
|
||||
else
|
||||
statusline(ALERT, _("Unbound key: %c"), code);
|
||||
}
|
||||
|
||||
@@ -1749,7 +1756,8 @@ int do_input(bool allow_funcs)
|
||||
if (shortcut == NULL)
|
||||
pletion_line = NULL;
|
||||
else {
|
||||
if (ISSET(VIEW_MODE) && !okay_for_view(shortcut)) {
|
||||
if (ISSET(VIEW_MODE) && shortcut->func != do_toggle_void &&
|
||||
!okay_for_view(shortcut)) {
|
||||
print_view_warning();
|
||||
return ERR;
|
||||
}
|
||||
@@ -1759,7 +1767,6 @@ int do_input(bool allow_funcs)
|
||||
if (shortcut->func == do_cut_text_void
|
||||
#ifndef NANO_TINY
|
||||
|| shortcut->func == do_copy_text
|
||||
|| shortcut->func == do_cut_till_eof
|
||||
#endif
|
||||
)
|
||||
retain_cuts = TRUE;
|
||||
@@ -2244,7 +2251,7 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
case 'r':
|
||||
if (!parse_num(optarg, &wrap_at)) {
|
||||
if (!parse_num(optarg, &fill)) {
|
||||
fprintf(stderr, _("Requested fill size \"%s\" is invalid"), optarg);
|
||||
fprintf(stderr, "\n");
|
||||
exit(1);
|
||||
@@ -2332,7 +2339,7 @@ int main(int argc, char **argv)
|
||||
char *operating_dir_cpy = operating_dir;
|
||||
#endif
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
ssize_t wrap_at_cpy = wrap_at;
|
||||
ssize_t fill_cpy = fill;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
char *backup_dir_cpy = backup_dir;
|
||||
@@ -2380,7 +2387,7 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
if (fill_used)
|
||||
wrap_at = wrap_at_cpy;
|
||||
fill = fill_cpy;
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
if (backup_dir_cpy != NULL) {
|
||||
@@ -2576,6 +2583,8 @@ int main(int argc, char **argv)
|
||||
/* Ask for the codes for Control+Home/End. */
|
||||
controlhome = get_keycode("kHOM5", CONTROL_HOME);
|
||||
controlend = get_keycode("kEND5", CONTROL_END);
|
||||
controldelete = get_keycode("kDC5", CONTROL_DELETE);
|
||||
controlshiftdelete = get_keycode("kDC6", CONTROL_SHIFT_DELETE);
|
||||
#ifndef NANO_TINY
|
||||
/* Ask for the codes for Shift+Control+Left/Right/Up/Down. */
|
||||
shiftcontrolleft = get_keycode("kLFT6", SHIFT_CONTROL_LEFT);
|
||||
@@ -2646,8 +2655,11 @@ int main(int argc, char **argv)
|
||||
UNSET(VIEW_MODE);
|
||||
}
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
else
|
||||
else {
|
||||
openfile = openfile->next;
|
||||
if (more_than_one)
|
||||
mention_name_and_linecount();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -2656,8 +2668,10 @@ int main(int argc, char **argv)
|
||||
|
||||
prepare_for_display();
|
||||
|
||||
#ifdef ENABLE_NANORC
|
||||
if (rcfile_with_errors != NULL)
|
||||
statusline(ALERT, _("Mistakes in '%s'"), rcfile_with_errors);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_HELP
|
||||
if (*openfile->filename == '\0' && openfile->totsize == 0 &&
|
||||
@@ -2690,8 +2704,8 @@ int main(int argc, char **argv)
|
||||
errno = 0;
|
||||
focusing = TRUE;
|
||||
|
||||
/* Forget any earlier statusbar x position. */
|
||||
reinit_statusbar_x();
|
||||
/* Forget any earlier cursor position at the prompt. */
|
||||
put_cursor_at_end_of_answer();
|
||||
|
||||
/* Read in and interpret keystrokes. */
|
||||
do_input(TRUE);
|
||||
|
||||
12
src/nano.h
12
src/nano.h
@@ -188,8 +188,6 @@ typedef struct colortype {
|
||||
/* This syntax's foreground color. */
|
||||
short bg;
|
||||
/* This syntax's background color. */
|
||||
bool bright;
|
||||
/* Is this color A_BOLD? */
|
||||
int pairnum;
|
||||
/* The color pair number used for this foreground color and
|
||||
* background color. */
|
||||
@@ -229,8 +227,6 @@ typedef struct syntaxtype {
|
||||
/* The list of libmagic results that this syntax applies to. */
|
||||
char *linter;
|
||||
/* The command with which to lint this type of file. */
|
||||
char *formatter;
|
||||
/* The formatting command (for programming languages mainly). */
|
||||
#ifdef ENABLE_COMMENT
|
||||
char *comment;
|
||||
/* The line comment prefix (and postfix) for this type of file. */
|
||||
@@ -585,12 +581,14 @@ enum
|
||||
#define CONTROL_DOWN 0x404
|
||||
#define CONTROL_HOME 0x405
|
||||
#define CONTROL_END 0x406
|
||||
#define CONTROL_DELETE 0x407
|
||||
#define SHIFT_CONTROL_LEFT 0x411
|
||||
#define SHIFT_CONTROL_RIGHT 0x412
|
||||
#define SHIFT_CONTROL_UP 0x413
|
||||
#define SHIFT_CONTROL_DOWN 0x414
|
||||
#define SHIFT_CONTROL_HOME 0x415
|
||||
#define SHIFT_CONTROL_END 0x416
|
||||
#define CONTROL_SHIFT_DELETE 0x417
|
||||
#define ALT_LEFT 0x421
|
||||
#define ALT_RIGHT 0x422
|
||||
#define ALT_UP 0x423
|
||||
@@ -622,7 +620,6 @@ enum
|
||||
#define WAS_FINAL_BACKSPACE (1<<1)
|
||||
#define WAS_WHOLE_LINE (1<<2)
|
||||
#define WAS_FINAL_LINE (1<<3)
|
||||
/* The flags for the mark need to be the highest. */
|
||||
#define MARK_WAS_SET (1<<4)
|
||||
#define WAS_MARKED_FORWARD (1<<5)
|
||||
#endif /* !NANO_TINY */
|
||||
@@ -630,9 +627,8 @@ enum
|
||||
/* The maximum number of entries displayed in the main shortcut list. */
|
||||
#define MAIN_VISIBLE (((COLS + 40) / 20) * 2)
|
||||
|
||||
/* The default number of characters from the end of the line where
|
||||
* wrapping occurs. */
|
||||
#define CHARS_FROM_EOL 8
|
||||
/* The default number of columns from end of line where wrapping occurs. */
|
||||
#define COLUMNS_FROM_EOL 8
|
||||
|
||||
/* The default width of a tab in spaces. */
|
||||
#define WIDTH_OF_TAB 8
|
||||
|
||||
165
src/prompt.c
165
src/prompt.c
@@ -25,6 +25,8 @@
|
||||
|
||||
static char *prompt = NULL;
|
||||
/* The prompt string used for statusbar questions. */
|
||||
static size_t typing_x = HIGHEST_POSITIVE;
|
||||
/* The cursor position in answer. */
|
||||
|
||||
#ifdef ENABLE_MOUSE
|
||||
/* Handle a mouse click on the statusbar prompt or the shortcut list. */
|
||||
@@ -38,12 +40,10 @@ int do_statusbar_mouse(void)
|
||||
size_t start_col = strlenpt(prompt) + 2;
|
||||
|
||||
/* Move to where the click occurred. */
|
||||
if (click_row == 0 && click_col >= start_col) {
|
||||
statusbar_x = actual_x(answer,
|
||||
if (click_row == 0 && click_col >= start_col)
|
||||
typing_x = actual_x(answer,
|
||||
get_statusbar_page_start(start_col, start_col +
|
||||
statusbar_xplustabs()) + click_col - start_col);
|
||||
update_the_statusbar();
|
||||
}
|
||||
strnlenpt(answer, typing_x)) + click_col - start_col);
|
||||
}
|
||||
|
||||
return retval;
|
||||
@@ -208,113 +208,99 @@ void do_statusbar_output(int *the_input, size_t input_len,
|
||||
|
||||
/* Insert the typed character into the existing answer string. */
|
||||
answer = charealloc(answer, strlen(answer) + char_len + 1);
|
||||
charmove(answer + statusbar_x + char_len, answer + statusbar_x,
|
||||
strlen(answer) - statusbar_x + 1);
|
||||
strncpy(answer + statusbar_x, onechar, char_len);
|
||||
charmove(answer + typing_x + char_len, answer + typing_x,
|
||||
strlen(answer) - typing_x + 1);
|
||||
strncpy(answer + typing_x, onechar, char_len);
|
||||
|
||||
statusbar_x += char_len;
|
||||
typing_x += char_len;
|
||||
}
|
||||
|
||||
free(output);
|
||||
|
||||
update_the_statusbar();
|
||||
}
|
||||
|
||||
/* Move to the beginning of the answer. */
|
||||
void do_statusbar_home(void)
|
||||
{
|
||||
statusbar_x = 0;
|
||||
update_the_statusbar();
|
||||
typing_x = 0;
|
||||
}
|
||||
|
||||
/* Move to the end of the answer. */
|
||||
void do_statusbar_end(void)
|
||||
{
|
||||
statusbar_x = strlen(answer);
|
||||
update_the_statusbar();
|
||||
typing_x = strlen(answer);
|
||||
}
|
||||
|
||||
/* Move left one character. */
|
||||
void do_statusbar_left(void)
|
||||
{
|
||||
if (statusbar_x > 0) {
|
||||
statusbar_x = move_mbleft(answer, statusbar_x);
|
||||
update_the_statusbar();
|
||||
}
|
||||
if (typing_x > 0)
|
||||
typing_x = move_mbleft(answer, typing_x);
|
||||
}
|
||||
|
||||
/* Move right one character. */
|
||||
void do_statusbar_right(void)
|
||||
{
|
||||
if (answer[statusbar_x] != '\0') {
|
||||
statusbar_x = move_mbright(answer, statusbar_x);
|
||||
update_the_statusbar();
|
||||
if (answer[typing_x] != '\0')
|
||||
typing_x = move_mbright(answer, typing_x);
|
||||
}
|
||||
|
||||
/* Delete one character. */
|
||||
void do_statusbar_delete(void)
|
||||
{
|
||||
if (answer[typing_x] != '\0') {
|
||||
int char_len = parse_mbchar(answer + typing_x, NULL, NULL);
|
||||
|
||||
charmove(answer + typing_x, answer + typing_x + char_len,
|
||||
strlen(answer) - typing_x - char_len + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Backspace over one character. */
|
||||
void do_statusbar_backspace(void)
|
||||
{
|
||||
if (statusbar_x > 0) {
|
||||
statusbar_x = move_mbleft(answer, statusbar_x);
|
||||
if (typing_x > 0) {
|
||||
typing_x = move_mbleft(answer, typing_x);
|
||||
do_statusbar_delete();
|
||||
}
|
||||
}
|
||||
|
||||
/* Delete one character. */
|
||||
void do_statusbar_delete(void)
|
||||
{
|
||||
if (answer[statusbar_x] != '\0') {
|
||||
int char_len = parse_mbchar(answer + statusbar_x, NULL, NULL);
|
||||
|
||||
charmove(answer + statusbar_x, answer + statusbar_x + char_len,
|
||||
strlen(answer) - statusbar_x - char_len + 1);
|
||||
|
||||
update_the_statusbar();
|
||||
}
|
||||
}
|
||||
|
||||
/* Zap some or all text from the answer. */
|
||||
void do_statusbar_cut_text(void)
|
||||
{
|
||||
if (!ISSET(CUT_FROM_CURSOR))
|
||||
statusbar_x = 0;
|
||||
typing_x = 0;
|
||||
|
||||
answer[statusbar_x] = '\0';
|
||||
|
||||
update_the_statusbar();
|
||||
answer[typing_x] = '\0';
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Move to the next word in the answer. */
|
||||
void do_statusbar_next_word(void)
|
||||
{
|
||||
bool seen_space = !is_word_mbchar(answer + statusbar_x, FALSE);
|
||||
bool seen_space = !is_word_mbchar(answer + typing_x, FALSE);
|
||||
bool seen_word = !seen_space;
|
||||
|
||||
/* Move forward until we reach either the end or the start of a word,
|
||||
* depending on whether the AFTER_ENDS flag is set or not. */
|
||||
while (answer[statusbar_x] != '\0') {
|
||||
statusbar_x = move_mbright(answer, statusbar_x);
|
||||
while (answer[typing_x] != '\0') {
|
||||
typing_x = move_mbright(answer, typing_x);
|
||||
|
||||
if (ISSET(AFTER_ENDS)) {
|
||||
/* If this is a word character, continue; else it's a separator,
|
||||
* and if we've already seen a word, then it's a word end. */
|
||||
if (is_word_mbchar(answer + statusbar_x, FALSE))
|
||||
if (is_word_mbchar(answer + typing_x, FALSE))
|
||||
seen_word = TRUE;
|
||||
else if (seen_word)
|
||||
break;
|
||||
} else {
|
||||
/* If this is not a word character, then it's a separator; else
|
||||
* if we've already seen a separator, then it's a word start. */
|
||||
if (!is_word_mbchar(answer + statusbar_x, FALSE))
|
||||
if (!is_word_mbchar(answer + typing_x, FALSE))
|
||||
seen_space = TRUE;
|
||||
else if (seen_space)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
update_the_statusbar();
|
||||
}
|
||||
|
||||
/* Move to the previous word in the answer. */
|
||||
@@ -323,10 +309,10 @@ void do_statusbar_prev_word(void)
|
||||
bool seen_a_word = FALSE, step_forward = FALSE;
|
||||
|
||||
/* Move backward until we pass over the start of a word. */
|
||||
while (statusbar_x != 0) {
|
||||
statusbar_x = move_mbleft(answer, statusbar_x);
|
||||
while (typing_x != 0) {
|
||||
typing_x = move_mbleft(answer, typing_x);
|
||||
|
||||
if (is_word_mbchar(answer + statusbar_x, FALSE))
|
||||
if (is_word_mbchar(answer + typing_x, FALSE))
|
||||
seen_a_word = TRUE;
|
||||
else if (seen_a_word) {
|
||||
/* This is space now: we've overshot the start of the word. */
|
||||
@@ -337,9 +323,7 @@ void do_statusbar_prev_word(void)
|
||||
|
||||
if (step_forward)
|
||||
/* Move one character forward again to sit on the start of the word. */
|
||||
statusbar_x = move_mbright(answer, statusbar_x);
|
||||
|
||||
update_the_statusbar();
|
||||
typing_x = move_mbright(answer, typing_x);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
@@ -356,12 +340,6 @@ void do_statusbar_verbatim_input(void)
|
||||
free(kbinput);
|
||||
}
|
||||
|
||||
/* Return the zero-based column position of the cursor in the answer. */
|
||||
size_t statusbar_xplustabs(void)
|
||||
{
|
||||
return strnlenpt(answer, statusbar_x);
|
||||
}
|
||||
|
||||
/* Paste the first line of the cutbuffer into the current answer. */
|
||||
void do_statusbar_uncut_text(void)
|
||||
{
|
||||
@@ -370,13 +348,13 @@ void do_statusbar_uncut_text(void)
|
||||
|
||||
/* Concatenate: the current answer before the cursor, the first line
|
||||
* of the cutbuffer, plus the rest of the current answer. */
|
||||
strncpy(fusion, answer, statusbar_x);
|
||||
strncpy(fusion + statusbar_x, cutbuffer->data, pastelen);
|
||||
strcpy(fusion + statusbar_x + pastelen, answer + statusbar_x);
|
||||
strncpy(fusion, answer, typing_x);
|
||||
strncpy(fusion + typing_x, cutbuffer->data, pastelen);
|
||||
strcpy(fusion + typing_x + pastelen, answer + typing_x);
|
||||
|
||||
free(answer);
|
||||
answer = fusion;
|
||||
statusbar_x += pastelen;
|
||||
typing_x += pastelen;
|
||||
}
|
||||
|
||||
/* Return the column number of the first character of the answer that is
|
||||
@@ -394,19 +372,19 @@ size_t get_statusbar_page_start(size_t base, size_t column)
|
||||
}
|
||||
|
||||
/* Reinitialize the cursor position in the answer. */
|
||||
void reinit_statusbar_x(void)
|
||||
void put_cursor_at_end_of_answer(void)
|
||||
{
|
||||
statusbar_x = HIGHEST_POSITIVE;
|
||||
typing_x = HIGHEST_POSITIVE;
|
||||
}
|
||||
|
||||
/* Redraw the promptbar and place the cursor at the right spot. */
|
||||
void update_the_statusbar(void)
|
||||
void draw_the_promptbar(void)
|
||||
{
|
||||
size_t base = strlenpt(prompt) + 2;
|
||||
size_t the_page, end_page, column;
|
||||
char *expanded;
|
||||
|
||||
the_page = get_statusbar_page_start(base, base + strnlenpt(answer, statusbar_x));
|
||||
the_page = get_statusbar_page_start(base, base + strnlenpt(answer, typing_x));
|
||||
end_page = get_statusbar_page_start(base, base + strlenpt(answer) - 1);
|
||||
|
||||
/* Color the promptbar over its full width. */
|
||||
@@ -429,12 +407,29 @@ void update_the_statusbar(void)
|
||||
wmove(bottomwin, 0, 0);
|
||||
wrefresh(bottomwin);
|
||||
|
||||
/* Place the cursor at statusbar_x in the answer. */
|
||||
column = base + statusbar_xplustabs();
|
||||
/* Place the cursor at the right spot. */
|
||||
column = base + strnlenpt(answer, typing_x);
|
||||
wmove(bottomwin, 0, column - get_statusbar_page_start(base, column));
|
||||
wnoutrefresh(bottomwin);
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Remove or add the pipe character at the answer's head. */
|
||||
void add_or_remove_pipe_symbol_from_answer(void)
|
||||
{
|
||||
if (answer[0] == '|') {
|
||||
charmove(answer, answer + 1, strlen(answer) + 1);
|
||||
if (typing_x > 0)
|
||||
typing_x--;
|
||||
} else {
|
||||
answer = charealloc(answer, strlen(answer) + 2);
|
||||
charmove(answer + 1, answer, strlen(answer) + 1);
|
||||
answer[0] = '|';
|
||||
typing_x++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get a string of input at the statusbar prompt. */
|
||||
functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
bool allow_files, bool *listed, filestruct **history_list,
|
||||
@@ -462,12 +457,12 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
#endif
|
||||
#endif /* ENABLE_HISTORIES */
|
||||
|
||||
if (statusbar_x > strlen(answer))
|
||||
statusbar_x = strlen(answer);
|
||||
|
||||
update_the_statusbar();
|
||||
if (typing_x > strlen(answer))
|
||||
typing_x = strlen(answer);
|
||||
|
||||
while (TRUE) {
|
||||
draw_the_promptbar();
|
||||
|
||||
kbinput = do_statusbar_input(&finished);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -500,12 +495,12 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
if (complete_len > 0) {
|
||||
answer = get_history_completion(history_list,
|
||||
answer, complete_len);
|
||||
statusbar_x = strlen(answer);
|
||||
typing_x = strlen(answer);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (allow_tabs)
|
||||
answer = input_tab(answer, allow_files, &statusbar_x,
|
||||
answer = input_tab(answer, allow_files, &typing_x,
|
||||
&tabbed, refresh_func, listed);
|
||||
} else
|
||||
#endif /* ENABLE_TABCOMP */
|
||||
@@ -521,7 +516,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
* answer. If there is no older search, don't do anything. */
|
||||
if ((history = get_history_older(history_list)) != NULL) {
|
||||
answer = mallocstrcpy(answer, history);
|
||||
statusbar_x = strlen(answer);
|
||||
typing_x = strlen(answer);
|
||||
}
|
||||
|
||||
/* This key has a shortcut-list entry when it's used to
|
||||
@@ -536,7 +531,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
* answer. If there is no newer search, don't do anything. */
|
||||
if ((history = get_history_newer(history_list)) != NULL) {
|
||||
answer = mallocstrcpy(answer, history);
|
||||
statusbar_x = strlen(answer);
|
||||
typing_x = strlen(answer);
|
||||
}
|
||||
|
||||
/* If, after scrolling down, we're at the bottom of the
|
||||
@@ -545,7 +540,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
if ((*history_list)->next == NULL &&
|
||||
*answer == '\0' && magichistory != NULL) {
|
||||
answer = mallocstrcpy(answer, magichistory);
|
||||
statusbar_x = strlen(answer);
|
||||
typing_x = strlen(answer);
|
||||
}
|
||||
|
||||
/* This key has a shortcut-list entry when it's used to
|
||||
@@ -570,8 +565,6 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||
if (finished)
|
||||
break;
|
||||
|
||||
update_the_statusbar();
|
||||
|
||||
#if defined(ENABLE_HISTORIES) && defined(ENABLE_TABCOMP)
|
||||
last_kbinput = kbinput;
|
||||
#endif
|
||||
@@ -610,7 +603,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
|
||||
functionptrtype func = NULL;
|
||||
bool listed = FALSE;
|
||||
/* Save a possible current statusbar x position and prompt. */
|
||||
size_t was_statusbar_x = statusbar_x;
|
||||
size_t was_typing_x = typing_x;
|
||||
char *saved_prompt = prompt;
|
||||
|
||||
bottombars(menu);
|
||||
@@ -641,7 +634,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
|
||||
/* If we're done with this prompt, restore the x position to what
|
||||
* it was at a possible previous prompt. */
|
||||
if (func == do_cancel || func == do_enter)
|
||||
statusbar_x = was_statusbar_x;
|
||||
typing_x = was_typing_x;
|
||||
|
||||
/* If we left the prompt via Cancel or Enter, set the return value
|
||||
* properly. */
|
||||
@@ -685,6 +678,8 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
if (!ISSET(NO_HELP)) {
|
||||
char shortstr[MAXCHARLEN + 2];
|
||||
/* Temporary string for (translated) " Y", " N" and " A". */
|
||||
const sc *cancelshortcut = first_sc_for(MYESNO, do_cancel);
|
||||
/* The keystroke that is bound to the Cancel function. */
|
||||
|
||||
if (COLS < 32)
|
||||
width = COLS / 2;
|
||||
@@ -708,7 +703,7 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
}
|
||||
|
||||
wmove(bottomwin, 2, width);
|
||||
post_one_key("^C", _("Cancel"), width);
|
||||
post_one_key(cancelshortcut->keystr, _("Cancel"), width);
|
||||
}
|
||||
|
||||
/* Color the statusbar over its full width and display the question. */
|
||||
@@ -758,7 +753,7 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
else if (kbinput == KEY_MOUSE) {
|
||||
int mouse_x, mouse_y;
|
||||
/* We can click on the Yes/No/All shortcuts to select an answer. */
|
||||
if (get_mouseinput(&mouse_x, &mouse_y, FALSE) == 0 &&
|
||||
if (get_mouseinput(&mouse_y, &mouse_x, FALSE) == 0 &&
|
||||
wmouse_trafo(bottomwin, &mouse_y, &mouse_x, FALSE) &&
|
||||
mouse_x < (width * 2) && mouse_y > 0) {
|
||||
int x = mouse_x / width;
|
||||
|
||||
41
src/proto.h
41
src/proto.h
@@ -61,6 +61,8 @@ extern int controlup;
|
||||
extern int controldown;
|
||||
extern int controlhome;
|
||||
extern int controlend;
|
||||
extern int controldelete;
|
||||
extern int controlshiftdelete;
|
||||
#ifndef NANO_TINY
|
||||
extern int shiftcontrolleft;
|
||||
extern int shiftcontrolright;
|
||||
@@ -80,7 +82,6 @@ extern int shiftaltdown;
|
||||
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
extern ssize_t fill;
|
||||
extern ssize_t wrap_at;
|
||||
#endif
|
||||
|
||||
extern char *last_search;
|
||||
@@ -124,7 +125,6 @@ extern char *quoteerr;
|
||||
extern char *word_chars;
|
||||
|
||||
extern char *answer;
|
||||
extern size_t statusbar_x;
|
||||
|
||||
extern ssize_t tabsize;
|
||||
|
||||
@@ -179,7 +179,9 @@ extern int interface_color_pair[NUMBER_OF_ELEMENTS];
|
||||
|
||||
extern char *homedir;
|
||||
extern char *statedir;
|
||||
#ifdef ENABLE_NANORC
|
||||
extern char *rcfile_with_errors;
|
||||
#endif
|
||||
|
||||
typedef void (*functionptrtype)(void);
|
||||
|
||||
@@ -190,7 +192,7 @@ void read_the_list(const char *path, DIR *dir);
|
||||
functionptrtype parse_browser_input(int *kbinput);
|
||||
void browser_refresh(void);
|
||||
void browser_select_dirname(const char *needle);
|
||||
void do_filesearch(void);
|
||||
void do_filesearch(bool forwards);
|
||||
void do_fileresearch(bool forwards);
|
||||
void to_first_file(void);
|
||||
void to_last_file(void);
|
||||
@@ -222,7 +224,6 @@ char *mbstrcasestr(const char *haystack, const char *needle);
|
||||
char *revstrstr(const char *haystack, const char *needle, const char *index);
|
||||
char *mbrevstrcasestr(const char *haystack, const char *needle, const char *index);
|
||||
size_t mbstrlen(const char *s);
|
||||
size_t mbstrnlen(const char *s, size_t maxlen);
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
|
||||
char *mbstrchr(const char *s, const char *c);
|
||||
#endif
|
||||
@@ -237,9 +238,6 @@ bool has_blank_mbchars(const char *s);
|
||||
#ifdef ENABLE_UTF8
|
||||
bool is_valid_unicode(wchar_t wc);
|
||||
#endif
|
||||
#ifdef ENABLE_NANORC
|
||||
bool is_valid_mbstring(const char *s);
|
||||
#endif
|
||||
|
||||
/* Most functions in color.c. */
|
||||
#ifdef ENABLE_COLOR
|
||||
@@ -257,7 +255,7 @@ bool keeping_cutbuffer(void);
|
||||
#ifndef NANO_TINY
|
||||
void cut_marked(bool *right_side_up);
|
||||
#endif
|
||||
void do_cut_text(bool copy_text, bool cut_till_eof);
|
||||
void do_cut_text(bool copy_text, bool marked, bool cut_till_eof);
|
||||
void do_cut_text_void(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_copy_text(void);
|
||||
@@ -272,12 +270,12 @@ bool open_buffer(const char *filename, bool new_buffer);
|
||||
#ifdef ENABLE_SPELLER
|
||||
void replace_buffer(const char *filename);
|
||||
#ifndef NANO_TINY
|
||||
void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
|
||||
filestruct *bot, size_t bot_x);
|
||||
void replace_marked_buffer(const char *filename);
|
||||
#endif
|
||||
#endif
|
||||
void prepare_for_display(void);
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
void mention_name_and_linecount(void);
|
||||
void switch_to_prev_buffer(void);
|
||||
void switch_to_next_buffer(void);
|
||||
bool close_buffer(void);
|
||||
@@ -326,15 +324,15 @@ void assign_keyinfo(sc *s, const char *keystring, const int keycode);
|
||||
void print_sclist(void);
|
||||
void shortcut_init(void);
|
||||
#ifdef ENABLE_COLOR
|
||||
void set_lint_or_format_shortcuts(void);
|
||||
void set_spell_shortcuts(void);
|
||||
void set_linter_shortcut(void);
|
||||
void set_speller_shortcut(void);
|
||||
#endif
|
||||
const subnfunc *sctofunc(const sc *s);
|
||||
const char *flagtostr(int flag);
|
||||
#ifdef ENABLE_NANORC
|
||||
sc *strtosc(const char *input);
|
||||
int strtomenu(const char *input);
|
||||
#ifdef DEBUG
|
||||
void thanks_for_all_the_fish(void);
|
||||
int name_to_menu(const char *name);
|
||||
char *menu_to_name(int menu);
|
||||
#endif
|
||||
|
||||
/* All functions in help.c. */
|
||||
@@ -465,10 +463,9 @@ void do_statusbar_prev_word(void);
|
||||
void do_statusbar_next_word(void);
|
||||
#endif
|
||||
void do_statusbar_verbatim_input(void);
|
||||
size_t statusbar_xplustabs(void);
|
||||
size_t get_statusbar_page_start(size_t start_col, size_t column);
|
||||
void reinit_statusbar_x(void);
|
||||
void update_the_statusbar(void);
|
||||
void put_cursor_at_end_of_answer(void);
|
||||
void add_or_remove_pipe_symbol_from_answer(void);
|
||||
int do_prompt(bool allow_tabs, bool allow_files,
|
||||
int menu, const char *curranswer, filestruct **history_list,
|
||||
void (*refresh_func)(void), const char *msg, ...);
|
||||
@@ -490,11 +487,8 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
void do_search(void);
|
||||
void do_search_forward(void);
|
||||
void do_search_backward(void);
|
||||
void do_research(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_findprevious(void);
|
||||
void do_findnext(void);
|
||||
#endif
|
||||
void not_found_msg(const char *str);
|
||||
void go_looking(void);
|
||||
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
@@ -562,7 +556,6 @@ void do_spell(void);
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
void do_linter(void);
|
||||
void do_formatter(void);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
void do_wordlinechar_count(void);
|
||||
@@ -616,9 +609,6 @@ size_t get_totsize(const filestruct *begin, const filestruct *end);
|
||||
#ifndef NANO_TINY
|
||||
filestruct *fsfromline(ssize_t lineno);
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
void dump_filestruct(const filestruct *inptr);
|
||||
#endif
|
||||
|
||||
/* Most functions in winio.c. */
|
||||
void record_macro(void);
|
||||
@@ -714,6 +704,7 @@ void prepend_void(void);
|
||||
void backup_file_void(void);
|
||||
void flip_execute(void);
|
||||
void flip_pipe(void);
|
||||
void flip_convert(void);
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
void flip_newbuffer(void);
|
||||
|
||||
107
src/rcfile.c
107
src/rcfile.c
@@ -94,7 +94,6 @@ static const rcoption rcopts[] = {
|
||||
{"autoindent", AUTOINDENT},
|
||||
{"backup", BACKUP_FILE},
|
||||
{"backupdir", 0},
|
||||
{"backwards", BACKWARDS_SEARCH},
|
||||
{"casesensitive", CASE_SENSITIVE},
|
||||
{"cut", CUT_FROM_CURSOR}, /* deprecated form, remove end of 2018 */
|
||||
{"cutfromcursor", CUT_FROM_CURSOR},
|
||||
@@ -301,7 +300,6 @@ void parse_syntax(char *ptr)
|
||||
live_syntax->headers = NULL;
|
||||
live_syntax->magics = NULL;
|
||||
live_syntax->linter = NULL;
|
||||
live_syntax->formatter = NULL;
|
||||
#ifdef ENABLE_COMMENT
|
||||
live_syntax->comment = mallocstrcpy(NULL, GENERAL_COMMENT_CHARACTER);
|
||||
#endif
|
||||
@@ -315,10 +313,6 @@ void parse_syntax(char *ptr)
|
||||
|
||||
opensyntax = TRUE;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Starting a new syntax type: \"%s\"\n", nameptr);
|
||||
#endif
|
||||
|
||||
/* The default syntax should have no associated extensions. */
|
||||
if (strcmp(live_syntax->name, "default") == 0 && *ptr != '\0') {
|
||||
rcfile_error(N_("The \"default\" syntax does not accept extensions"));
|
||||
@@ -351,10 +345,6 @@ void parse_binding(char *ptr, bool dobind)
|
||||
sc *s, *newsc = NULL;
|
||||
int menu;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Starting the rebinding code...\n");
|
||||
#endif
|
||||
|
||||
if (*ptr == '\0') {
|
||||
rcfile_error(N_("Missing key name"));
|
||||
return;
|
||||
@@ -424,7 +414,7 @@ void parse_binding(char *ptr, bool dobind)
|
||||
newsc->toggle = 0;
|
||||
#endif
|
||||
} else
|
||||
newsc = strtosc(funcptr);
|
||||
newsc = strtosc(funcptr);
|
||||
|
||||
if (newsc == NULL) {
|
||||
rcfile_error(N_("Cannot map name \"%s\" to a function"), funcptr);
|
||||
@@ -432,7 +422,7 @@ void parse_binding(char *ptr, bool dobind)
|
||||
}
|
||||
}
|
||||
|
||||
menu = strtomenu(menuptr);
|
||||
menu = name_to_menu(menuptr);
|
||||
if (menu < 1) {
|
||||
rcfile_error(N_("Cannot map name \"%s\" to a menu"), menuptr);
|
||||
goto free_things;
|
||||
@@ -544,10 +534,6 @@ static void parse_one_include(char *file)
|
||||
nanorc = file;
|
||||
lineno = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Parsing file \"%s\"\n", file);
|
||||
#endif
|
||||
|
||||
parse_rcfile(rcstream, TRUE);
|
||||
}
|
||||
|
||||
@@ -616,13 +602,16 @@ short color_to_short(const char *colorname, bool *bright)
|
||||
|
||||
/* Parse the color name (or pair of color names) in the given string.
|
||||
* Return FALSE when any color name is invalid; otherwise return TRUE. */
|
||||
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
|
||||
bool parse_color_names(char *combostr, short *fg, short *bg, int *attributes)
|
||||
{
|
||||
char *comma = strchr(combostr, ',');
|
||||
bool bright;
|
||||
|
||||
*attributes = A_NORMAL;
|
||||
|
||||
if (comma != NULL) {
|
||||
*bg = color_to_short(comma + 1, bright);
|
||||
if (*bright) {
|
||||
*bg = color_to_short(comma + 1, &bright);
|
||||
if (bright) {
|
||||
rcfile_error(N_("A background color cannot be bright"));
|
||||
return FALSE;
|
||||
}
|
||||
@@ -633,9 +622,12 @@ bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
|
||||
*bg = USE_THE_DEFAULT;
|
||||
|
||||
if (comma != combostr) {
|
||||
*fg = color_to_short(combostr, bright);
|
||||
*fg = color_to_short(combostr, &bright);
|
||||
if (*fg == BAD_COLOR)
|
||||
return FALSE;
|
||||
|
||||
if (bright)
|
||||
*attributes = A_BOLD;
|
||||
} else
|
||||
*fg = USE_THE_DEFAULT;
|
||||
|
||||
@@ -648,7 +640,7 @@ bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
|
||||
void parse_colors(char *ptr, int rex_flags)
|
||||
{
|
||||
short fg, bg;
|
||||
bool bright;
|
||||
int attributes;
|
||||
char *item;
|
||||
|
||||
if (!opensyntax) {
|
||||
@@ -664,7 +656,7 @@ void parse_colors(char *ptr, int rex_flags)
|
||||
|
||||
item = ptr;
|
||||
ptr = parse_next_word(ptr);
|
||||
if (!parse_color_names(item, &fg, &bg, &bright))
|
||||
if (!parse_color_names(item, &fg, &bg, &attributes))
|
||||
return;
|
||||
|
||||
if (*ptr == '\0') {
|
||||
@@ -711,7 +703,7 @@ void parse_colors(char *ptr, int rex_flags)
|
||||
|
||||
newcolor->fg = fg;
|
||||
newcolor->bg = bg;
|
||||
newcolor->bright = bright;
|
||||
newcolor->attributes = attributes;
|
||||
newcolor->rex_flags = rex_flags;
|
||||
|
||||
newcolor->start_regex = mallocstrcpy(NULL, item);
|
||||
@@ -774,7 +766,7 @@ colortype *parse_interface_color(char *combostr)
|
||||
{
|
||||
colortype *trio = nmalloc(sizeof(colortype));
|
||||
|
||||
if (parse_color_names(combostr, &trio->fg, &trio->bg, &trio->bright)) {
|
||||
if (parse_color_names(combostr, &trio->fg, &trio->bg, &trio->attributes)) {
|
||||
free(combostr);
|
||||
return trio;
|
||||
} else {
|
||||
@@ -847,7 +839,7 @@ void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
|
||||
}
|
||||
}
|
||||
|
||||
/* Gather and store the string after a comment/linter/formatter command. */
|
||||
/* Gather and store the string after a comment/linter command. */
|
||||
void pick_up_name(const char *kind, char *ptr, char **storage)
|
||||
{
|
||||
if (!opensyntax) {
|
||||
@@ -886,17 +878,18 @@ static void check_vitals_mapped(void)
|
||||
{
|
||||
subnfunc *f;
|
||||
int v;
|
||||
#define VITALS 5
|
||||
void (*vitals[VITALS])(void) = { do_exit, do_exit, do_cancel, do_cancel, do_cancel };
|
||||
int inmenus[VITALS] = { MMAIN, MHELP, MWHEREIS, MREPLACE, MGOTOLINE };
|
||||
#define VITALS 3
|
||||
void (*vitals[VITALS])(void) = { do_exit, do_exit, do_cancel };
|
||||
int inmenus[VITALS] = { MMAIN, MHELP, MYESNO };
|
||||
|
||||
for (v = 0; v < VITALS; v++) {
|
||||
for (f = allfuncs; f != NULL; f = f->next) {
|
||||
if (f->func == vitals[v] && f->menus & inmenus[v]) {
|
||||
const sc *s = first_sc_for(inmenus[v], f->func);
|
||||
if (!s) {
|
||||
fprintf(stderr, _("Fatal error: no keys mapped for function "
|
||||
"\"%s\". Exiting.\n"), f->desc);
|
||||
fprintf(stderr, _("No key is bound to function '%s' in "
|
||||
"menu '%s'. Exiting.\n"), f->desc,
|
||||
menu_to_name(inmenus[v]));
|
||||
fprintf(stderr, _("If needed, use nano with the -I option "
|
||||
"to adjust your nanorc settings.\n"));
|
||||
exit(1);
|
||||
@@ -941,7 +934,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
/* Handle extending first... */
|
||||
if (strcasecmp(keyword, "extendsyntax") == 0) {
|
||||
if (strcasecmp(keyword, "extendsyntax") == 0 && !syntax_only) {
|
||||
syntaxtype *sint;
|
||||
char *syntaxname = ptr;
|
||||
|
||||
@@ -998,13 +991,12 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
|
||||
parse_colors(ptr, NANO_REG_EXTENDED | REG_ICASE);
|
||||
else if (strcasecmp(keyword, "linter") == 0)
|
||||
pick_up_name("linter", ptr, &live_syntax->linter);
|
||||
else if (strcasecmp(keyword, "formatter") == 0)
|
||||
#ifdef ENABLE_SPELLER
|
||||
pick_up_name("formatter", ptr, &live_syntax->formatter);
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
else if (syntax_only)
|
||||
else if (syntax_only && (strcasecmp(keyword, "set") == 0 ||
|
||||
strcasecmp(keyword, "unset") == 0 ||
|
||||
strcasecmp(keyword, "bind") == 0 ||
|
||||
strcasecmp(keyword, "unbind") == 0 ||
|
||||
strcasecmp(keyword, "include") == 0 ||
|
||||
strcasecmp(keyword, "extendsyntax") == 0))
|
||||
rcfile_error(N_("Command \"%s\" not allowed in included file"),
|
||||
keyword);
|
||||
else if (strcasecmp(keyword, "include") == 0)
|
||||
@@ -1050,10 +1042,6 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " Option name = \"%s\"\n", rcopts[i].name);
|
||||
fprintf(stderr, " Flag = %ld\n", rcopts[i].flag);
|
||||
#endif
|
||||
/* First handle unsetting. */
|
||||
if (set == -1) {
|
||||
if (rcopts[i].flag != 0)
|
||||
@@ -1082,15 +1070,14 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
|
||||
ptr = parse_argument(ptr);
|
||||
|
||||
option = mallocstrcpy(NULL, option);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " Option argument = \"%s\"\n", option);
|
||||
#endif
|
||||
/* Make sure the option argument is a valid multibyte string. */
|
||||
if (!is_valid_mbstring(option)) {
|
||||
|
||||
#ifdef ENABLE_UTF8
|
||||
/* When in a UTF-8 locale, ignore arguments with invalid sequences. */
|
||||
if (using_utf8() && mbstowcs(NULL, option, 0) == (size_t)-1) {
|
||||
rcfile_error(N_("Argument is not a valid multibyte string"));
|
||||
continue;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
if (strcasecmp(rcopts[i].name, "titlecolor") == 0)
|
||||
color_combo[TITLE_BAR] = parse_interface_color(option);
|
||||
@@ -1115,10 +1102,10 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
|
||||
#endif
|
||||
#ifdef ENABLED_WRAPORJUSTIFY
|
||||
if (strcasecmp(rcopts[i].name, "fill") == 0) {
|
||||
if (!parse_num(option, &wrap_at)) {
|
||||
if (!parse_num(option, &fill)) {
|
||||
rcfile_error(N_("Requested fill size \"%s\" is invalid"),
|
||||
option);
|
||||
wrap_at = -CHARS_FROM_EOL;
|
||||
fill = -COLUMNS_FROM_EOL;
|
||||
} else
|
||||
UNSET(NO_WRAP);
|
||||
free(option);
|
||||
@@ -1209,9 +1196,6 @@ void parse_one_nanorc(void)
|
||||
if (!is_good_file(nanorc))
|
||||
return;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Going to parse file \"%s\"\n", nanorc);
|
||||
#endif
|
||||
rcstream = fopen(nanorc, "rb");
|
||||
|
||||
/* If opening the file succeeded, parse it. Otherwise, only
|
||||
@@ -1238,9 +1222,8 @@ void do_rcfiles(void)
|
||||
{
|
||||
const char *xdgconfdir;
|
||||
|
||||
/* First process the system-wide nanorc, if there is one. */
|
||||
nanorc = mallocstrcpy(nanorc, SYSCONFDIR "/nanorc");
|
||||
|
||||
/* Process the system-wide nanorc. */
|
||||
parse_one_nanorc();
|
||||
|
||||
/* When configured with --disable-wrapping-as-root, turn wrapping off
|
||||
@@ -1253,8 +1236,8 @@ void do_rcfiles(void)
|
||||
get_homedir();
|
||||
xdgconfdir = getenv("XDG_CONFIG_HOME");
|
||||
|
||||
/* Now try the to find a nanorc file in the user's home directory
|
||||
* or in the XDG configuration directories. */
|
||||
/* Now try the to find a nanorc file in the user's home directory or in
|
||||
* the XDG configuration directories, and process the first one found. */
|
||||
if (have_nanorc(homedir, "/" HOME_RC_NAME))
|
||||
parse_one_nanorc();
|
||||
else if (have_nanorc(xdgconfdir, "/nano/" RCFILE_NAME))
|
||||
@@ -1266,6 +1249,16 @@ void do_rcfiles(void)
|
||||
|
||||
check_vitals_mapped();
|
||||
|
||||
#ifdef __linux__
|
||||
/* On a Linux console, don't start nano when there are rcfile errors,
|
||||
* because otherwise these error messages get wiped. */
|
||||
if (on_a_vt && rcfile_with_errors) {
|
||||
fprintf(stderr, _("If needed, use nano with the -I option "
|
||||
"to adjust your nanorc settings.\n"));
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
free(nanorc);
|
||||
}
|
||||
|
||||
|
||||
11
src/search.c
11
src/search.c
@@ -101,12 +101,11 @@ void search_init(bool replacing, bool keep_the_answer)
|
||||
answer, &search_history,
|
||||
/* TRANSLATORS: This is the main search prompt. */
|
||||
edit_refresh, "%s%s%s%s%s%s", _("Search"),
|
||||
/* TRANSLATORS: The next three modify the search prompt. */
|
||||
/* TRANSLATORS: The next four modify the search prompt. */
|
||||
ISSET(CASE_SENSITIVE) ? _(" [Case Sensitive]") : "",
|
||||
ISSET(USE_REGEXP) ? _(" [Regexp]") : "",
|
||||
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") : "", replacing ?
|
||||
#ifndef NANO_TINY
|
||||
/* TRANSLATORS: The next two modify the search prompt. */
|
||||
openfile->mark ? _(" (to replace) in selection") :
|
||||
#endif
|
||||
_(" (to replace)") : "", thedefault);
|
||||
@@ -156,6 +155,12 @@ void search_init(bool replacing, bool keep_the_answer)
|
||||
} else if (func == regexp_void) {
|
||||
TOGGLE(USE_REGEXP);
|
||||
} else if (func == flip_replace) {
|
||||
if (ISSET(VIEW_MODE)) {
|
||||
print_view_warning();
|
||||
tidy_up_after_search();
|
||||
free(thedefault);
|
||||
return;
|
||||
}
|
||||
replacing = !replacing;
|
||||
} else {
|
||||
if (func == flip_goto)
|
||||
@@ -366,7 +371,6 @@ void do_research(void)
|
||||
tidy_up_after_search();
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Search in the backward direction for the next occurrence. */
|
||||
void do_findprevious(void)
|
||||
{
|
||||
@@ -380,7 +384,6 @@ void do_findnext(void)
|
||||
UNSET(BACKWARDS_SEARCH);
|
||||
do_research();
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Report on the status bar that the given string was not found. */
|
||||
void not_found_msg(const char *str)
|
||||
|
||||
322
src/text.c
322
src/text.c
@@ -32,9 +32,8 @@
|
||||
#include <sys/wait.h>
|
||||
|
||||
#ifndef NANO_TINY
|
||||
static pid_t pid = -1;
|
||||
/* The PID of the forked process in execute_command(), for use
|
||||
* with the cancel_command() signal handler. */
|
||||
static pid_t pid_of_command = -1;
|
||||
/* The PID of the forked process -- needed when wanting to abort it. */
|
||||
#endif
|
||||
#ifdef ENABLE_WRAPPING
|
||||
static bool prepend_wrap = FALSE;
|
||||
@@ -206,11 +205,27 @@ void do_cutword(bool backward)
|
||||
cutbuffer = NULL;
|
||||
cutbottom = NULL;
|
||||
|
||||
/* Move the cursor to a word start, to the left or to the right. */
|
||||
if (backward)
|
||||
/* Move the cursor to a word start, to the left or to the right.
|
||||
* If that word is on another line and the cursor was not already
|
||||
* on the edge of the original line, then put the cursor on that
|
||||
* edge instead, so that lines will not be joined unexpectedly. */
|
||||
if (backward) {
|
||||
do_prev_word(ISSET(WORD_BOUNDS), FALSE);
|
||||
else
|
||||
if (openfile->current != is_current) {
|
||||
if (is_current_x > 0) {
|
||||
openfile->current = is_current;
|
||||
openfile->current_x = 0;
|
||||
} else
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
}
|
||||
} else {
|
||||
do_next_word(FALSE, ISSET(WORD_BOUNDS), FALSE);
|
||||
if (openfile->current != is_current &&
|
||||
is_current->data[is_current_x] != '\0') {
|
||||
openfile->current = is_current;
|
||||
openfile->current_x = strlen(is_current->data);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the mark at the start of that word. */
|
||||
openfile->mark = openfile->current;
|
||||
@@ -633,16 +648,16 @@ void handle_comment_action(undo *u, bool undoing, bool add_comment)
|
||||
/* Undo a cut, or redo an uncut. */
|
||||
void undo_cut(undo *u)
|
||||
{
|
||||
/* If we cut the magicline, we may as well not crash. :/ */
|
||||
if (!u->cutbuffer)
|
||||
return;
|
||||
|
||||
/* Get to where we need to uncut from. */
|
||||
if (u->xflags == WAS_WHOLE_LINE)
|
||||
goto_line_posx(u->mark_begin_lineno, 0);
|
||||
else
|
||||
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
|
||||
|
||||
/* If nothing was actually cut, positioning the cursor was enough. */
|
||||
if (!u->cutbuffer)
|
||||
return;
|
||||
|
||||
copy_from_buffer(u->cutbuffer);
|
||||
|
||||
if (u->xflags != WAS_MARKED_FORWARD && u->type != PASTE)
|
||||
@@ -654,19 +669,19 @@ void redo_cut(undo *u)
|
||||
{
|
||||
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
|
||||
|
||||
/* If we cut the magicline, we may as well not crash. :/ */
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
|
||||
/* If nothing was actually cut, positioning the cursor was enough. */
|
||||
if (!u->cutbuffer)
|
||||
return;
|
||||
|
||||
cutbuffer = NULL;
|
||||
cutbottom = NULL;
|
||||
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
|
||||
openfile->mark = fsfromline(u->mark_begin_lineno);
|
||||
openfile->mark_x = (u->xflags == WAS_WHOLE_LINE) ? 0 : u->mark_begin_x;
|
||||
|
||||
do_cut_text(FALSE, FALSE);
|
||||
do_cut_text(FALSE, TRUE, FALSE);
|
||||
|
||||
free_filestruct(cutbuffer);
|
||||
cutbuffer = oldcutbuffer;
|
||||
@@ -693,10 +708,6 @@ void do_undo(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " >> Undoing a type %d...\n", u->type);
|
||||
#endif
|
||||
|
||||
openfile->current_x = u->begin;
|
||||
switch (u->type) {
|
||||
case ADD:
|
||||
@@ -768,7 +779,6 @@ void do_undo(void)
|
||||
case SPLIT_END:
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
openfile->current_undo = openfile->current_undo->next;
|
||||
openfile->last_action = OTHER;
|
||||
while (openfile->current_undo->type != SPLIT_BEGIN)
|
||||
do_undo();
|
||||
u = openfile->current_undo;
|
||||
@@ -802,7 +812,8 @@ void do_undo(void)
|
||||
cutbottom = oldcutbottom;
|
||||
break;
|
||||
case COUPLE_BEGIN:
|
||||
undidmsg = _("filtering");
|
||||
undidmsg = u->strdata;
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
break;
|
||||
case COUPLE_END:
|
||||
openfile->current_undo = openfile->current_undo->next;
|
||||
@@ -867,7 +878,7 @@ void do_redo(void)
|
||||
while (u != NULL && u->next != openfile->current_undo)
|
||||
u = u->next;
|
||||
|
||||
if (u->next != openfile->current_undo) {
|
||||
if (u == NULL) {
|
||||
statusline(ALERT, "Bad undo stack -- please report a bug");
|
||||
return;
|
||||
}
|
||||
@@ -878,10 +889,6 @@ void do_redo(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " >> Redoing a type %d...\n", u->type);
|
||||
#endif
|
||||
|
||||
switch (u->type) {
|
||||
case ADD:
|
||||
redidmsg = _("text add");
|
||||
@@ -947,7 +954,6 @@ void do_redo(void)
|
||||
case SPLIT_BEGIN:
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
openfile->current_undo = u;
|
||||
openfile->last_action = OTHER;
|
||||
while (openfile->current_undo->type != SPLIT_END)
|
||||
do_redo();
|
||||
u = openfile->current_undo;
|
||||
@@ -979,7 +985,8 @@ void do_redo(void)
|
||||
do_redo();
|
||||
return;
|
||||
case COUPLE_END:
|
||||
redidmsg = _("filtering");
|
||||
redidmsg = u->strdata;
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
break;
|
||||
case INDENT:
|
||||
handle_indent_action(u, FALSE, TRUE);
|
||||
@@ -1060,8 +1067,6 @@ void do_enter(void)
|
||||
/* If there were only blanks before the cursor, trim them. */
|
||||
if (allblanks)
|
||||
openfile->current_x = 0;
|
||||
else
|
||||
openfile->totsize += extra;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1091,6 +1096,8 @@ void do_enter(void)
|
||||
set_modified();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(AUTOINDENT) && !allblanks)
|
||||
openfile->totsize += extra;
|
||||
update_undo(ENTER);
|
||||
#endif
|
||||
|
||||
@@ -1099,12 +1106,10 @@ void do_enter(void)
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Send a SIGKILL (unconditional kill) to the forked process in
|
||||
* execute_command(). */
|
||||
RETSIGTYPE cancel_command(int signal)
|
||||
/* Send an unconditional kill signal to the running external command. */
|
||||
RETSIGTYPE cancel_the_command(int signal)
|
||||
{
|
||||
if (kill(pid, SIGKILL) == -1)
|
||||
nperror("kill");
|
||||
kill(pid_of_command, SIGKILL);
|
||||
}
|
||||
|
||||
/* Send the text that starts at the given line to file descriptor fd. */
|
||||
@@ -1150,7 +1155,7 @@ bool execute_command(const char *command)
|
||||
shellenv = (char *) "/bin/sh";
|
||||
|
||||
/* Fork a child process to run the command in. */
|
||||
if ((pid = fork()) == 0) {
|
||||
if ((pid_of_command = fork()) == 0) {
|
||||
/* Child: close the unused read end of the output pipe. */
|
||||
close(from_fd[0]);
|
||||
|
||||
@@ -1175,7 +1180,7 @@ bool execute_command(const char *command)
|
||||
/* Parent: close the unused write end of the pipe. */
|
||||
close(from_fd[1]);
|
||||
|
||||
if (pid == -1) {
|
||||
if (pid_of_command == -1) {
|
||||
statusbar(_("Could not fork"));
|
||||
close(from_fd[0]);
|
||||
return FALSE;
|
||||
@@ -1190,17 +1195,18 @@ bool execute_command(const char *command)
|
||||
if (ISSET(MULTIBUFFER)) {
|
||||
switch_to_prev_buffer();
|
||||
if (openfile->mark)
|
||||
do_cut_text(TRUE, FALSE);
|
||||
do_cut_text(TRUE, TRUE, FALSE);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
add_undo(COUPLE_BEGIN);
|
||||
openfile->undotop->strdata = mallocstrcpy(NULL, _("filtering"));
|
||||
if (openfile->mark == NULL) {
|
||||
openfile->current = openfile->fileage;
|
||||
openfile->current_x = 0;
|
||||
}
|
||||
add_undo(CUT);
|
||||
do_cut_text(FALSE, openfile->mark == NULL);
|
||||
do_cut_text(FALSE, openfile->mark, openfile->mark == NULL);
|
||||
update_undo(CUT);
|
||||
}
|
||||
|
||||
@@ -1231,7 +1237,7 @@ bool execute_command(const char *command)
|
||||
setup_failed = TRUE;
|
||||
nperror("sigaction");
|
||||
} else {
|
||||
newaction.sa_handler = cancel_command;
|
||||
newaction.sa_handler = cancel_the_command;
|
||||
if (sigaction(SIGINT, &newaction, &oldaction) == -1) {
|
||||
setup_failed = TRUE;
|
||||
nperror("sigaction");
|
||||
@@ -1244,11 +1250,16 @@ bool execute_command(const char *command)
|
||||
else
|
||||
read_file(stream, 0, "pipe", TRUE);
|
||||
|
||||
if (should_pipe && !ISSET(MULTIBUFFER))
|
||||
if (should_pipe && !ISSET(MULTIBUFFER)) {
|
||||
add_undo(COUPLE_END);
|
||||
openfile->undotop->strdata = mallocstrcpy(NULL, _("filtering"));
|
||||
}
|
||||
|
||||
/* Wait for the external command (and possibly data sender) to terminate. */
|
||||
if (wait(NULL) == -1)
|
||||
nperror("wait");
|
||||
if (should_pipe && (wait(NULL) == -1))
|
||||
nperror("wait");
|
||||
|
||||
/* If it was changed, restore the handler for SIGINT. */
|
||||
if (!setup_failed && sigaction(SIGINT, &oldaction, NULL) == -1)
|
||||
@@ -1296,26 +1307,22 @@ void discard_until(const undo *thisitem, openfilestruct *thefile, bool keep)
|
||||
thefile->last_saved = (undo *)0xbeeb;
|
||||
}
|
||||
|
||||
/* Add a new undo struct of the given type to the top of the current pile. */
|
||||
/* Add a new undo item of the given type to the top of the current pile. */
|
||||
void add_undo(undo_type action)
|
||||
{
|
||||
undo *u = openfile->current_undo;
|
||||
/* The thing we did previously. */
|
||||
|
||||
/* When doing contiguous adds or contiguous cuts -- which means: with
|
||||
* no cursor movement in between -- don't add a new undo item. */
|
||||
if (u && u->mark_begin_lineno == openfile->current->lineno && action == openfile->last_action &&
|
||||
((action == ADD && u->type == ADD && u->mark_begin_x == openfile->current_x) ||
|
||||
(action == CUT && u->type == CUT && u->xflags < MARK_WAS_SET && keeping_cutbuffer())))
|
||||
/* When doing contiguous adds or cuts, don't add a new undo item. */
|
||||
if (u != NULL && action == openfile->last_action && action == u->type &&
|
||||
openfile->current->lineno == u->mark_begin_lineno &&
|
||||
((action == ADD && u->mark_begin_x == openfile->current_x) ||
|
||||
(action == CUT && keeping_cutbuffer())))
|
||||
return;
|
||||
|
||||
/* Blow away newer undo items if we add somewhere in the middle. */
|
||||
discard_until(u, openfile, TRUE);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " >> Adding an undo... action = %d\n", action);
|
||||
#endif
|
||||
|
||||
/* Allocate and initialize a new undo item. */
|
||||
u = (undo *) nmalloc(sizeof(undo));
|
||||
u->type = action;
|
||||
@@ -1327,6 +1334,7 @@ void add_undo(undo_type action)
|
||||
u->mark_begin_lineno = openfile->current->lineno;
|
||||
u->mark_begin_x = openfile->current_x;
|
||||
u->wassize = openfile->totsize;
|
||||
u->newsize = openfile->totsize;
|
||||
u->xflags = 0;
|
||||
u->grouping = NULL;
|
||||
|
||||
@@ -1395,10 +1403,8 @@ void add_undo(undo_type action)
|
||||
break;
|
||||
#endif
|
||||
case CUT_TO_EOF:
|
||||
cutbuffer_reset();
|
||||
break;
|
||||
case CUT:
|
||||
cutbuffer_reset();
|
||||
if (openfile->mark) {
|
||||
u->mark_begin_lineno = openfile->mark->lineno;
|
||||
u->mark_begin_x = openfile->mark_x;
|
||||
@@ -1475,14 +1481,11 @@ void update_undo(undo_type action)
|
||||
char *char_buf;
|
||||
int char_len;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " >> Updating an undo... action = %d\n", action);
|
||||
#endif
|
||||
|
||||
/* If the action is different or the position changed, don't update the
|
||||
* current record but add a new one instead. */
|
||||
if (action != openfile->last_action ||
|
||||
(action != ENTER && action != CUT && action != INSERT &&
|
||||
action != COUPLE_END &&
|
||||
openfile->current->lineno != openfile->current_undo->lineno)) {
|
||||
add_undo(action);
|
||||
return;
|
||||
@@ -1577,7 +1580,10 @@ fprintf(stderr, " >> Updating an undo... action = %d\n", action);
|
||||
u->mark_begin_lineno = openfile->current->lineno;
|
||||
u->mark_begin_x = openfile->current_x;
|
||||
case COUPLE_BEGIN:
|
||||
break;
|
||||
case COUPLE_END:
|
||||
u->lineno = openfile->current->lineno;
|
||||
u->begin = openfile->current_x;
|
||||
break;
|
||||
default:
|
||||
statusline(ALERT, "Wrong undo update type -- please report a bug");
|
||||
@@ -2158,9 +2164,9 @@ bool find_paragraph(size_t *const quote, size_t *const par)
|
||||
}
|
||||
}
|
||||
|
||||
/* If the current line isn't the first line of the paragraph, move
|
||||
/* If the current line is in a paragraph and isn't its first line, move
|
||||
* back to the first line of the paragraph. */
|
||||
if (!begpar(openfile->current, 0))
|
||||
if (inpar(openfile->current) && !begpar(openfile->current, 0))
|
||||
do_para_begin(FALSE);
|
||||
|
||||
/* Now current is the first line of the paragraph. Set quote_len to
|
||||
@@ -2681,8 +2687,10 @@ const char *do_int_speller(const char *tempfile_name)
|
||||
if ((tempfile_fd = open(tempfile_name, O_RDONLY)) == -1)
|
||||
goto close_pipes_and_exit;
|
||||
|
||||
if (dup2(tempfile_fd, STDIN_FILENO) != STDIN_FILENO)
|
||||
if (dup2(tempfile_fd, STDIN_FILENO) != STDIN_FILENO) {
|
||||
close(tempfile_fd);
|
||||
goto close_pipes_and_exit;
|
||||
}
|
||||
|
||||
close(tempfile_fd);
|
||||
|
||||
@@ -2828,7 +2836,6 @@ const char *do_int_speller(const char *tempfile_name)
|
||||
|
||||
close_pipes_and_exit:
|
||||
/* Don't leak any handles. */
|
||||
close(tempfile_fd);
|
||||
close(spell_fd[0]);
|
||||
close(spell_fd[1]);
|
||||
close(sort_fd[0]);
|
||||
@@ -2891,51 +2898,46 @@ const char *do_alt_speller(char *tempfile_name)
|
||||
if (!WIFEXITED(alt_spell_status) || WEXITSTATUS(alt_spell_status) != 0)
|
||||
return invocation_error(alt_speller);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Replace the marked text (or the entire text) of the current buffer
|
||||
* with the spell-checked text. */
|
||||
if (openfile->mark) {
|
||||
filestruct *top, *bot;
|
||||
size_t top_x, bot_x;
|
||||
bool right_side_up;
|
||||
ssize_t was_mark_lineno = openfile->mark->lineno;
|
||||
|
||||
mark_order((const filestruct **)&top, &top_x,
|
||||
(const filestruct **)&bot, &bot_x, &right_side_up);
|
||||
openfile->mark = NULL;
|
||||
|
||||
replace_marked_buffer(tempfile_name, top, top_x, bot, bot_x);
|
||||
|
||||
/* Adjust the end point of the marked region for any change in
|
||||
* length of the region's last line. */
|
||||
if (right_side_up)
|
||||
current_x_save = openfile->current_x;
|
||||
else
|
||||
openfile->mark_x = openfile->current_x;
|
||||
|
||||
/* Restore the mark. */
|
||||
openfile->mark = fsfromline(was_mark_lineno);
|
||||
} else
|
||||
#endif
|
||||
replace_buffer(tempfile_name);
|
||||
|
||||
/* Go back to the old position. */
|
||||
goto_line_posx(lineno_save, current_x_save);
|
||||
if (was_at_eol || openfile->current_x > strlen(openfile->current->data))
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
openfile->placewewant = pww_save;
|
||||
adjust_viewport(STATIONARY);
|
||||
|
||||
/* Stat the temporary file again, and mark the buffer as modified only
|
||||
* if this file was changed since it was written. */
|
||||
/* Stat the temporary file again. */
|
||||
stat(tempfile_name, &spellfileinfo);
|
||||
|
||||
/* Use the spell-checked file only when it changed. */
|
||||
if (spellfileinfo.st_mtime != timestamp) {
|
||||
set_modified();
|
||||
#ifndef NANO_TINY
|
||||
/* Flush the undo stack, to avoid making a mess when the user
|
||||
* tries to undo things in spell-corrected lines. */
|
||||
discard_until(NULL, openfile, FALSE);
|
||||
/* Replace the marked text (or entire text) with the corrected text. */
|
||||
if (openfile->mark) {
|
||||
filestruct *top, *bot;
|
||||
size_t top_x, bot_x;
|
||||
bool right_side_up;
|
||||
ssize_t was_mark_lineno = openfile->mark->lineno;
|
||||
|
||||
mark_order((const filestruct **)&top, &top_x,
|
||||
(const filestruct **)&bot, &bot_x, &right_side_up);
|
||||
|
||||
replace_marked_buffer(tempfile_name);
|
||||
|
||||
/* Adjust the end point of the marked region for any change in
|
||||
* length of the region's last line. */
|
||||
if (right_side_up)
|
||||
current_x_save = openfile->current_x;
|
||||
else
|
||||
openfile->mark_x = openfile->current_x;
|
||||
|
||||
/* Restore the mark. */
|
||||
openfile->mark = fsfromline(was_mark_lineno);
|
||||
} else
|
||||
#endif
|
||||
replace_buffer(tempfile_name);
|
||||
|
||||
/* Go back to the old position. */
|
||||
goto_line_posx(lineno_save, current_x_save);
|
||||
if (was_at_eol || openfile->current_x > strlen(openfile->current->data))
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
#ifndef NANO_TINY
|
||||
update_undo(COUPLE_END);
|
||||
#endif
|
||||
openfile->placewewant = pww_save;
|
||||
adjust_viewport(STATIONARY);
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -3258,6 +3260,8 @@ void do_linter(void)
|
||||
}
|
||||
}
|
||||
|
||||
free(dontwantfile);
|
||||
|
||||
if (restlint == NULL) {
|
||||
statusbar(_("No more errors in unopened files, cancelling"));
|
||||
napms(2400);
|
||||
@@ -3266,8 +3270,6 @@ void do_linter(void)
|
||||
curlint = restlint;
|
||||
continue;
|
||||
}
|
||||
|
||||
free(dontwantfile);
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
}
|
||||
}
|
||||
@@ -3330,119 +3332,6 @@ void do_linter(void)
|
||||
free(tmplint);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SPELLER
|
||||
/* Run a formatter for the current syntax. This expects the formatter
|
||||
* to be non-interactive and operate on a file in-place, which we'll
|
||||
* pass it on the command line. */
|
||||
void do_formatter(void)
|
||||
{
|
||||
bool status;
|
||||
FILE *temp_file;
|
||||
int format_status;
|
||||
ssize_t lineno_save = openfile->current->lineno;
|
||||
size_t current_x_save = openfile->current_x;
|
||||
size_t pww_save = openfile->placewewant;
|
||||
bool was_at_eol = (openfile->current->data[openfile->current_x] == '\0');
|
||||
pid_t pid_format;
|
||||
static char **formatargs = NULL;
|
||||
char *temp, *finalstatus = NULL;
|
||||
|
||||
if (openfile->totsize == 0) {
|
||||
statusbar(_("Finished"));
|
||||
return;
|
||||
}
|
||||
|
||||
temp = safe_tempfile(&temp_file);
|
||||
|
||||
if (temp == NULL) {
|
||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* We're not supporting partial formatting, oi vey. */
|
||||
openfile->mark = NULL;
|
||||
#endif
|
||||
status = write_file(temp, temp_file, TRUE, OVERWRITE, TRUE);
|
||||
|
||||
if (!status) {
|
||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
blank_bottombars();
|
||||
statusbar(_("Invoking formatter, please wait"));
|
||||
|
||||
construct_argument_list(&formatargs, openfile->syntax->formatter, temp);
|
||||
|
||||
/* Start a new process for the formatter. */
|
||||
if ((pid_format = fork()) == 0) {
|
||||
/* Start the formatting program; we are using $PATH. */
|
||||
execvp(formatargs[0], formatargs);
|
||||
|
||||
/* Should not be reached, if the formatter is found! */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* If we couldn't fork, get out. */
|
||||
if (pid_format < 0) {
|
||||
statusbar(_("Could not fork"));
|
||||
unlink(temp);
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Block SIGWINCHes so the formatter doesn't get any. */
|
||||
allow_sigwinch(FALSE);
|
||||
#endif
|
||||
|
||||
/* Wait for the formatter to finish. */
|
||||
wait(&format_status);
|
||||
|
||||
if (!WIFEXITED(format_status) || WEXITSTATUS(format_status) != 0)
|
||||
finalstatus = invocation_error(openfile->syntax->formatter);
|
||||
else {
|
||||
/* Replace the text of the current buffer with the formatted text. */
|
||||
replace_buffer(temp);
|
||||
|
||||
/* Restore the cursor position. */
|
||||
goto_line_posx(lineno_save, current_x_save);
|
||||
if (was_at_eol || openfile->current_x > strlen(openfile->current->data))
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
openfile->placewewant = pww_save;
|
||||
adjust_viewport(STATIONARY);
|
||||
|
||||
set_modified();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Flush the undo stack, to avoid a mess or crash when
|
||||
* the user tries to undo things in reformatted lines. */
|
||||
discard_until(NULL, openfile, FALSE);
|
||||
#endif
|
||||
finalstatus = _("Finished formatting");
|
||||
}
|
||||
|
||||
unlink(temp);
|
||||
free(temp);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Unblock SIGWINCHes again. */
|
||||
allow_sigwinch(TRUE);
|
||||
#endif
|
||||
|
||||
statusbar(finalstatus);
|
||||
|
||||
/* If there were error messages, allow the user some time to read them. */
|
||||
if (WIFEXITED(format_status) && WEXITSTATUS(format_status) == 2)
|
||||
sleep(4);
|
||||
|
||||
/* If there were any messages, clear them off. */
|
||||
total_refresh();
|
||||
}
|
||||
#endif /* ENABLE_SPELLER */
|
||||
#endif /* ENABLE_COLOR */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -3619,6 +3508,7 @@ void complete_a_word(void)
|
||||
|
||||
/* If there is no word fragment before the cursor, do nothing. */
|
||||
if (start_of_shard == openfile->current_x) {
|
||||
statusbar(_("No word fragment"));
|
||||
pletion_line = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
18
src/utils.c
18
src/utils.c
@@ -590,21 +590,3 @@ size_t get_totsize(const filestruct *begin, const filestruct *end)
|
||||
|
||||
return totsize;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* Dump the given buffer to stderr. */
|
||||
void dump_filestruct(const filestruct *inptr)
|
||||
{
|
||||
if (inptr == openfile->fileage)
|
||||
fprintf(stderr, "Dumping file buffer to stderr...\n");
|
||||
else if (inptr == cutbuffer)
|
||||
fprintf(stderr, "Dumping cutbuffer to stderr...\n");
|
||||
else
|
||||
fprintf(stderr, "Dumping a buffer to stderr...\n");
|
||||
|
||||
while (inptr != NULL) {
|
||||
fprintf(stderr, "(%zd) %s\n", inptr->lineno, inptr->data);
|
||||
inptr = inptr->next;
|
||||
}
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
95
src/winio.c
95
src/winio.c
@@ -385,7 +385,7 @@ int parse_kbinput(WINDOW *win)
|
||||
if (escapes > 3)
|
||||
escapes = 1;
|
||||
/* Take note when an Esc arrived by itself. */
|
||||
solitary = (escapes == 1 && key_buffer_len == 0);
|
||||
solitary = (key_buffer_len == 0);
|
||||
return ERR;
|
||||
}
|
||||
|
||||
@@ -476,12 +476,13 @@ int parse_kbinput(WINDOW *win)
|
||||
}
|
||||
} else {
|
||||
if (digit_count == 0)
|
||||
/* Two escapes followed by a non-decimal
|
||||
* digit (or a decimal digit that would
|
||||
* create a byte sequence greater than 2XX)
|
||||
* and there aren't any other codes waiting:
|
||||
* control character sequence mode. */
|
||||
retval = get_control_kbinput(keycode);
|
||||
/* Two escapes followed by a non-digit: meta key
|
||||
* or control character sequence mode. */
|
||||
if (!solitary) {
|
||||
meta_key = TRUE;
|
||||
retval = keycode;
|
||||
} else
|
||||
retval = get_control_kbinput(keycode);
|
||||
else {
|
||||
/* An invalid digit in the middle of a byte
|
||||
* sequence: reset the byte sequence counter
|
||||
@@ -505,11 +506,13 @@ int parse_kbinput(WINDOW *win)
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (key_buffer_len == 0)
|
||||
if (key_buffer_len == 0) {
|
||||
if (!solitary)
|
||||
meta_key = TRUE;
|
||||
/* Three escapes followed by a non-escape, and no
|
||||
* other codes are waiting: normal input mode. */
|
||||
retval = keycode;
|
||||
else
|
||||
} else
|
||||
/* Three escapes followed by a non-escape, and more
|
||||
* codes are waiting: combined control character and
|
||||
* escape sequence mode. First interpret the escape
|
||||
@@ -535,7 +538,11 @@ int parse_kbinput(WINDOW *win)
|
||||
return CONTROL_HOME;
|
||||
else if (retval == controlend)
|
||||
return CONTROL_END;
|
||||
else if (retval == controldelete)
|
||||
return CONTROL_DELETE;
|
||||
#ifndef NANO_TINY
|
||||
else if (retval == controlshiftdelete)
|
||||
return the_code_for(do_cut_prev_word, KEY_BACKSPACE);
|
||||
else if (retval == shiftcontrolleft) {
|
||||
shift_held = TRUE;
|
||||
return CONTROL_LEFT;
|
||||
@@ -606,6 +613,8 @@ int parse_kbinput(WINDOW *win)
|
||||
return CONTROL_HOME;
|
||||
else if (retval == KEY_END)
|
||||
return CONTROL_END;
|
||||
else if (retval == KEY_DC)
|
||||
return CONTROL_DELETE;
|
||||
}
|
||||
#ifndef NANO_TINY
|
||||
/* Are both Shift and Alt being held? */
|
||||
@@ -698,12 +707,8 @@ int parse_kbinput(WINDOW *win)
|
||||
return KEY_NPAGE;
|
||||
#ifdef KEY_SDC /* Slang doesn't support KEY_SDC. */
|
||||
case KEY_SDC:
|
||||
#endif
|
||||
case DEL_CODE:
|
||||
if (ISSET(REBIND_DELETE))
|
||||
return the_code_for(do_delete, KEY_DC);
|
||||
else
|
||||
return KEY_BACKSPACE;
|
||||
#endif
|
||||
#ifdef KEY_SIC /* Slang doesn't support KEY_SIC. */
|
||||
case KEY_SIC:
|
||||
return the_code_for(do_insertfile_void, KEY_IC);
|
||||
@@ -1077,11 +1082,29 @@ int convert_sequence(const int *seq, size_t length, int *consumed)
|
||||
/* Esc [ 2 ~ == Insert on VT220/VT320/
|
||||
* Linux console/xterm/Terminal. */
|
||||
return KEY_IC;
|
||||
else if (length > 4 && seq[2] == ';' && seq[4] == '~')
|
||||
/* Esc [ 2 ; x ~ == modified Insert on xterm. */
|
||||
*consumed = 5;
|
||||
break;
|
||||
case '3': /* Esc [ 3 ~ == Delete on VT220/VT320/
|
||||
* Linux console/xterm/Terminal. */
|
||||
if (length > 2 && seq[2] == '~')
|
||||
return KEY_DC;
|
||||
if (length > 4 && seq[2] == ';' && seq[4] == '~') {
|
||||
*consumed = 5;
|
||||
if (seq[3] == '5')
|
||||
/* Esc [ 3 ; 5 ~ == Ctrl-Delete on xterm. */
|
||||
return CONTROL_DELETE;
|
||||
if (seq[3] == '6')
|
||||
/* Esc [ 3 ; 6 ~ == Ctrl-Shift-Delete on xterm. */
|
||||
return controlshiftdelete;
|
||||
}
|
||||
if (length > 2 && seq[2] == '^')
|
||||
/* Esc [ 3 ^ == Ctrl-Delete on urxvt. */
|
||||
return CONTROL_DELETE;
|
||||
if (length > 2 && seq[2] == '@')
|
||||
/* Esc [ 3 @ == Ctrl-Shift-Delete on urxvt. */
|
||||
return controlshiftdelete;
|
||||
break;
|
||||
case '4': /* Esc [ 4 ~ == End on VT220/VT320/
|
||||
* Linux console/xterm. */
|
||||
@@ -1093,26 +1116,26 @@ int convert_sequence(const int *seq, size_t length, int *consumed)
|
||||
* Esc [ 5 ^ == PageUp on Eterm. */
|
||||
if (length > 2 && (seq[2] == '~' || seq[2] == '^'))
|
||||
return KEY_PPAGE;
|
||||
#ifndef NANO_TINY
|
||||
else if (length > 4 && seq[2] == ';' &&
|
||||
seq[3] == '2' && seq[4] == '~') {
|
||||
else if (length > 4 && seq[2] == ';' && seq[4] == '~') {
|
||||
*consumed = 5;
|
||||
return shiftaltup;
|
||||
}
|
||||
#ifndef NANO_TINY
|
||||
if (seq[3] == '2')
|
||||
return shiftaltup;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case '6': /* Esc [ 6 ~ == PageDown on VT220/VT320/
|
||||
* Linux console/xterm/Terminal;
|
||||
* Esc [ 6 ^ == PageDown on Eterm. */
|
||||
if (length > 2 && (seq[2] == '~' || seq[2] == '^'))
|
||||
return KEY_NPAGE;
|
||||
#ifndef NANO_TINY
|
||||
else if (length > 4 && seq[2] == ';' &&
|
||||
seq[3] == '2' && seq[4] == '~') {
|
||||
else if (length > 4 && seq[2] == ';' && seq[4] == '~') {
|
||||
*consumed = 5;
|
||||
return shiftaltdown;
|
||||
}
|
||||
#ifndef NANO_TINY
|
||||
if (seq[3] == '2')
|
||||
return shiftaltdown;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case '7': /* Esc [ 7 ~ == Home on Eterm/rxvt;
|
||||
* Esc [ 7 $ == Shift-Home on Eterm/rxvt;
|
||||
@@ -1291,6 +1314,7 @@ int parse_escape_sequence(WINDOW *win, int kbinput)
|
||||
lastmessage = HUSH;
|
||||
if (currmenu == MMAIN) {
|
||||
place_the_cursor();
|
||||
wnoutrefresh(edit); /* Needed for correct placement on NetBSD. */
|
||||
curs_set(1);
|
||||
}
|
||||
}
|
||||
@@ -1736,7 +1760,8 @@ const sc *get_shortcut(int *kbinput)
|
||||
#endif
|
||||
|
||||
/* Plain characters cannot be shortcuts, so just skip those. */
|
||||
if (!meta_key && (*kbinput & 0x7F) >= 0x20 && *kbinput <= 0xFF)
|
||||
if (!meta_key && ((*kbinput >= 0x20 && *kbinput < 0x7F) ||
|
||||
(*kbinput >= 0xA0 && *kbinput <= 0xFF)))
|
||||
return NULL;
|
||||
|
||||
for (s = sclist; s != NULL; s = s->next) {
|
||||
@@ -2132,8 +2157,7 @@ void statusbar(const char *msg)
|
||||
* message can be noticed and read. */
|
||||
void warn_and_shortly_pause(const char *msg)
|
||||
{
|
||||
statusbar(msg);
|
||||
beep();
|
||||
statusline(ALERT, msg);
|
||||
napms(1800);
|
||||
}
|
||||
|
||||
@@ -2154,6 +2178,11 @@ void statusline(message_type importance, const char *msg, ...)
|
||||
UNSET(WHITESPACE_DISPLAY);
|
||||
#endif
|
||||
|
||||
/* Ignore a message with an importance that is lower than the last one. */
|
||||
if ((lastmessage == ALERT && importance != ALERT) ||
|
||||
(lastmessage == MILD && importance == HUSH))
|
||||
return;
|
||||
|
||||
va_start(ap, msg);
|
||||
|
||||
/* Curses mode is turned off. If we use wmove() now, it will muck
|
||||
@@ -2165,11 +2194,6 @@ void statusline(message_type importance, const char *msg, ...)
|
||||
return;
|
||||
}
|
||||
|
||||
/* If there already was an alert message, ignore lesser ones. */
|
||||
if ((lastmessage == ALERT && importance != ALERT) ||
|
||||
(lastmessage == MILD && importance == HUSH))
|
||||
return;
|
||||
|
||||
/* If the ALERT status has been reset, reset the counter. */
|
||||
if (lastmessage == HUSH)
|
||||
alerts = 0;
|
||||
@@ -3312,11 +3336,10 @@ void total_refresh(void)
|
||||
void display_main_list(void)
|
||||
{
|
||||
#if defined(ENABLE_COLOR) && defined(ENABLE_SPELLER)
|
||||
if (openfile->syntax &&
|
||||
(openfile->syntax->formatter || openfile->syntax->linter))
|
||||
set_lint_or_format_shortcuts();
|
||||
if (openfile->syntax && openfile->syntax->linter)
|
||||
set_linter_shortcut();
|
||||
else
|
||||
set_spell_shortcuts();
|
||||
set_speller_shortcut();
|
||||
#endif
|
||||
|
||||
bottombars(MMAIN);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
## Here is an example for awk.
|
||||
|
||||
syntax awk "\.awk$"
|
||||
header "^#!.*awk"
|
||||
magic "awk script"
|
||||
comment "#"
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ color cyan "^[[:space:]]*#.*"
|
||||
color ,red " + +"
|
||||
|
||||
# Nano's name, including version.
|
||||
color brightred "(GNU )?nano [1-9]\.[0-9]\.[^[:space:][:punct:]]+"
|
||||
color brightred "(GNU )?[Nn]ano [1-3]\.[0-9][-.[:alnum:]]*\>"
|
||||
|
||||
# Email addresses.
|
||||
color magenta "<[[:alnum:].%_+-]+@[[:alnum:].-]+\.[[:alpha:]]{2,}>"
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
syntax go "\.go$"
|
||||
comment "//"
|
||||
|
||||
# Set up a formatter since spelling is probably useless...
|
||||
formatter gofmt -w
|
||||
|
||||
# Types.
|
||||
color green "\<(bool|u?int(8|16|32|64)?|float(32|64)|complex(64|128)|byte|rune|uintptr|string|error)\>"
|
||||
color green "\<((<-[[:space:]]*)chan|chan[[:space:]]*<-|const|func|interface|map|struct|type|var)\>"
|
||||
|
||||
@@ -5,12 +5,15 @@
|
||||
|
||||
syntax lua "\.lua$"
|
||||
magic "Lua script"
|
||||
linter "luacheck --no-color"
|
||||
comment "--"
|
||||
|
||||
color brightwhite "\[\[.*\]\]"
|
||||
|
||||
# Operators
|
||||
color brightyellow ":|\*|/|%|\+|-|\^|>|>=|<|<=|~=|=|\.\.|\<(not|and|or)\>"
|
||||
color brightyellow ":|\*|/|%|\+|-|\^|>|>=|<|<=|~=|=|\.\.|#|\<(not|and|or)\>"
|
||||
# Don't partially color ... as an operator
|
||||
color normal "\.\.\."
|
||||
|
||||
# Statements
|
||||
color brightblue "\<(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return|break)\>"
|
||||
@@ -49,9 +52,9 @@ color brightmagenta "\(|\)|\[|\]|\{|\}"
|
||||
# Shebang
|
||||
color brightcyan "^#!.*"
|
||||
|
||||
# Strings
|
||||
color red ""(\\.|[^"\])*"|'(\\.|[^'\])*'"
|
||||
|
||||
# Simple comments and multiline comments
|
||||
color green "--.*"
|
||||
color green start="--\[\[" end="\]\]"
|
||||
|
||||
# Strings
|
||||
color red ""(\\.|[^"\])*"|'(\\.|[^'\])*'"
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
syntax nanohelp
|
||||
|
||||
# Key combos:
|
||||
color cyan "\^[]4-8A-Z^\_◀▶▲▼]" "[◀▶▲▼]" "(\^|M-)Space" "\<M-." "\<F1?[0-9]"
|
||||
color cyan "\<(Tab|Sh-Tab|Enter|Ins|Del|Bsp|Up|Down|Left|Right|Home|End|PgUp|PgDn)\>"
|
||||
color cyan "\^[]4-8A-Z^\_◀▶▲▼]" "[◀▶▲▼]" "\<M-." "\<F1?[0-9]"
|
||||
color cyan "\<(Tab|Sh-Tab|Enter|Ins|Del|Space|Bsp|Up|Down|Left|Right|Home|End|PgUp|PgDn)\>"
|
||||
|
||||
# Quoted indicators:
|
||||
color brightred "'(\^|M-)'"
|
||||
|
||||
@@ -4,17 +4,17 @@ syntax nanorc "\.?nanorc$"
|
||||
comment "#"
|
||||
|
||||
# Possible errors and parameters
|
||||
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|formatter|i?color|extendsyntax).*$"
|
||||
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|i?color|extendsyntax).*$"
|
||||
|
||||
# Keywords
|
||||
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cutfromcursor|fill[[:space:]]+-?[[:digit:]]+|historylog|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize[[:space:]]+[1-9][0-9]*|tabstospaces|tempfile|trimblanks|unix|view|wordbounds)\>"
|
||||
icolor yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|selected|status|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"
|
||||
icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|selectedcolor|speller|statuscolor|titlecolor|whitespace|wordchars)[[:space:]]+"
|
||||
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^([[:alpha:]]|[]0-9\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+([[:alpha:]]+|".*")[[:space:]]+(all|main|search|replace(with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
|
||||
icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([[:alpha:]]|[]0-9\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+(all|main|search|replace(with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
|
||||
icolor brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|linter|formatter)[[:space:]]+.*$"
|
||||
icolor brightgreen "^[[:space:]]*(syntax|linter|formatter)[[:space:]]+[^[:blank:]]+"
|
||||
icolor green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|formatter|extendsyntax)\>"
|
||||
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^([[:alpha:]]|[]@\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+([[:alpha:]]+|".*")[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
|
||||
icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([[:alpha:]]|[]@\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
|
||||
icolor brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|linter)[[:space:]]+.*$"
|
||||
icolor brightgreen "^[[:space:]]*(syntax|linter)[[:space:]]+[^[:blank:]]+"
|
||||
icolor green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|extendsyntax)\>"
|
||||
|
||||
# Strings
|
||||
color brightmagenta "".+"([[:space:]]|$)"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## Here is an example for Perl.
|
||||
|
||||
syntax perl "\.p[lm]$"
|
||||
header "^#!.*perl[-0-9._]*"
|
||||
header "^#!.*perl"
|
||||
magic "Perl script"
|
||||
comment "#"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## Here is an example for Python.
|
||||
|
||||
syntax python "\.py$"
|
||||
header "^#!.*python[-0-9._]*"
|
||||
header "^#!.*python"
|
||||
magic "Python script"
|
||||
linter pyflakes
|
||||
comment "#"
|
||||
@@ -14,6 +14,9 @@ color brightcyan "\<(def|del|elif|else|except|exec|finally|for|from)\>"
|
||||
color brightcyan "\<(global|if|import|in|is|lambda|nonlocal|not|or)\>"
|
||||
color brightcyan "\<(pass|print|raise|return|try|while|with|yield)\>"
|
||||
|
||||
# Special values.
|
||||
color brightmagenta "\<(False|None|True)\>"
|
||||
|
||||
# Single-quoted strings.
|
||||
color brightgreen "'([^'\]|\\.)+'"
|
||||
color brightgreen ""([^"\]|\\.)+""
|
||||
@@ -23,9 +26,6 @@ color brightred "(^|[[:blank:]])#.*$"
|
||||
color brightgreen start="'''([^'),]|$)" end="(^|[^(\])'''"
|
||||
color brightgreen start="\"\"\"([^"),]|$)" end="(^|[^(\])\"\"\""
|
||||
|
||||
# Special values.
|
||||
color brightmagenta "\<(False|None|True)\>"
|
||||
|
||||
# Reminders.
|
||||
color brightwhite,yellow "(FIXME|TODO|XXX)"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## Here is an example for Ruby.
|
||||
|
||||
syntax ruby "\.rb$"
|
||||
header "^#!.*ruby[-0-9._]*"
|
||||
header "^#!.*ruby"
|
||||
magic "Ruby script"
|
||||
linter ruby -w -c
|
||||
comment "#"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## Here is an example for Bourne shell scripts.
|
||||
|
||||
syntax sh "\.sh$"
|
||||
header "^#!.*((ba|da|k|pdk)?sh[-0-9_]*|openrc-run|runscript)"
|
||||
syntax sh "(\.sh|\.(a|ba|c|da|k|mk|pdk|tc|z)(sh|shrc|sh_profile)|/(etc/|\.)profile)$"
|
||||
header "^#!.*/(((a|ba|c|da|k|mk|pdk|tc|z)?sh)|(busybox|env) +sh|openrc-run|runscript)"
|
||||
magic "(POSIX|Bourne-Again) shell script.*text"
|
||||
linter dash -n
|
||||
comment "#"
|
||||
|
||||
Reference in New Issue
Block a user