Commit Graph

33 Commits

Author SHA1 Message Date
Juhani Krekelä 42f6a359d1 Add search to editor(1). 2021-12-13 09:52:21 +02:00
Juhani Krekelä 7e5a816749 Refactor movement code in editor(1).
Firstly, lots of places in editor(1) would do a move from (x₀,y₀) to
(x,y) by first moving to (x,y₀) or (x₀,y) and only then (x,y). If the
intermediate positions were not valid cursor positions, this might cause
out of bounds access. Categorically fixed this by removing functions for
moving only horizontally or only vertically.

Secondly, editor_select_set() would set the column before setting the
line. Since the code for setting the column accesses the currently set
line at the new cursor position, it might cause out of bounds access
even on valid cursor positions. Fixed this by swapping the order in
which column and row are set.

Thirdly, the order of arguments passed to row_column_smallest() and
row_column_biggest() was wrong, with column being passed before the row,
even though they were defined the other way. However, this did not
result in out of bounds memory accesses due to the parameters to
editor_cursor_set() also being swapped at relevant callsites.

Finally, the boundary condition for control-down was off by one.
2021-12-06 07:50:37 +02:00
Juhani Krekelä 5e666dce8a Change `go to line` keybind in editor(1) from ^I to ^G
Since this is a console program, ctrl + letter gets mapped to a
control character in the range 1 to 26. Most of these control
characters are no longer in use and can safely be assumed to be
result of ctrl + letter, but ^I maps to the tab character.

I chose ^G since the keybind is memorable, and a user is unlikely
to try to type the BEL character.
2021-05-02 22:42:37 +02:00
Juhani Krekelä 86fa692c74 Do not try to copy zero-length buffers in editor_type_newline()
While under Sortix these operations ought to be safe, UBSan will
complain regardless if you do a zero-byte memmove from NULL. This
caused the editor forcibly quit whenever it tried to open a file
that had an empty first line and at least one another line.
2021-05-02 22:42:37 +02:00
Alexandros Alexandrou 48d826bfc5 Fix indentation in editor/display.c. 2019-04-09 15:11:53 +02:00
Alexandros Alexandrou 5723610d0a Fix Ctrl+Down selecting text instead of moving cursor in editor(1). 2018-03-11 18:39:00 +02:00
Alexandros Alexandrou 82b98b4899 Fix indention in editor(1). 2018-03-11 18:10:09 +02:00
Jonas 'Sortie' Termansen 723f8e964c Fix date format in manual pages. 2017-07-02 22:07:39 +02:00
Jonas 'Sortie' Termansen 92397f6042 Remove VERSIONSTR define for programs not using it. 2017-03-19 17:34:19 +01:00
Nicholas De Nova d217621649 Correct manpage spacing per roff(7) convention.
roff(7) dictates that "Each sentence should terminate at the end of an
input line." Instead of doing this, Sortix manpages (incorrectly) used
double-spaces to separate sentences.

Additionally, fix a few small typos.
2017-02-16 14:42:28 -06:00
Jonas 'Sortie' Termansen 1240a44298 Type escape colon to enter commands in editor(1). 2016-11-22 21:36:43 +01:00
Jonas 'Sortie' Termansen e5ed21520c Port the editor to non-sortix operating systems. 2016-05-15 22:43:29 +02:00
Jonas 'Sortie' Termansen 63146072a4 Fix getline(3) and getdelim(3) usage. 2016-05-15 19:32:04 +02:00
Jonas 'Sortie' Termansen 0705fabd6d Fix editor multiline copy. 2016-03-06 14:55:03 +01:00
Jonas 'Sortie' Termansen a0c61a53e1 Fix editor language modal. 2016-03-06 00:54:15 +01:00
Jonas 'Sortie' Termansen 2b72262b4f Relicense Sortix to the ISC license.
I hereby relicense all my work on Sortix under the ISC license as below.

All Sortix contributions by other people are already under this license,
are not substantial enough to be copyrightable, or have been removed.

All imported code from other projects is compatible with this license.

All GPL licensed code from other projects had previously been removed.

Copyright 2011-2016 Jonas 'Sortie' Termansen and contributors.

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2016-03-05 22:21:50 +01:00
Jonas 'Sortie' Termansen e004de8827 Convert editor to C. 2016-03-03 23:02:23 +01:00
Jonas 'Sortie' Termansen c5948fdd28 Fix executable manual pages. 2016-02-29 01:37:30 +01:00
Jonas 'Sortie' Termansen 4ee8f9ec38 Save modified file on editor(1) open and quit. 2016-02-24 23:55:35 +01:00
Jonas 'Sortie' Termansen 01ee906d25 Add editor(5). 2016-02-07 14:58:38 +01:00
Jonas 'Sortie' Termansen 31394e4014 Document editor(1). 2016-02-03 21:51:10 +01:00
Jonas 'Sortie' Termansen aff8f4d89c Fix files with incorrect copyright headers. 2016-02-03 01:01:20 +01:00
Jonas 'Sortie' Termansen 9554bab714 Add editor highlight support for diff. 2015-10-28 16:28:17 +01:00
Jonas 'Sortie' Termansen 158716f96a Fix ctype invocations with wrong domain. 2015-08-11 15:57:56 +02:00
Jonas 'Sortie' Termansen be1585488d Fix editor rendering special characters to the terminal. 2015-04-05 01:20:09 +02:00
Jonas 'Sortie' Termansen 0a63d26bf7 Fix double semicolons. 2015-04-05 01:20:09 +02:00
Jonas 'Sortie' Termansen 6c339085fe Highlight binary constants in the editor. 2014-12-28 20:18:58 +01:00
Jonas 'Sortie' Termansen 29ca566d43 Improve editor syntax highlighting of include statements. 2014-12-07 20:31:23 +01:00
Jonas 'Sortie' Termansen e97032761e Add line numbering to editor. 2014-12-07 20:31:22 +01:00
Jonas 'Sortie' Termansen 915ce1367b Refactor editor viewport positioning. 2014-12-07 20:31:05 +01:00
Jonas 'Sortie' Termansen 18539b2240 Handle movement between editor lines with tabs. 2014-12-07 20:31:04 +01:00
Jonas 'Sortie' Termansen 8cf873e6d3 Add control-arrow commands to editor. 2014-12-07 20:30:53 +01:00
Jonas 'Sortie' Termansen 08461c72fa Move editor to its own subdirectory. 2014-12-07 20:29:08 +01:00