Age | Commit message (Collapse) | Author |
|
Turns out I move around using these a lot too. I do tend to have very
tall terminals...
|
|
The forward movement seems okay (no worse than the equivalent arrow key
movement), but I haven't yet worked out how to move the cursor back when
necessary.
Also fix the location of the cursor in ex mode, and stop showing ex
commands in bold.
|
|
As soon as mmap() is done, we can close the fd. xmmap() also will exit
rather than return failure so we can remove that check, and fdlength()
will fall back to lseek() so there's no need to have the fallback in vi
itself.
Spotted because the `TT.fd = 0` in linelist_unload() seemed suspicious;
-1 would have been more natural.
|
|
Place function calls in order so that there is no unneeded
declarations, clear some whitespace stuff. Add few commands
that are commonly used.
cleanup: reorganize functions
cleanup: some whitespace stuff
add: vi_o vi_O vi_I
fix: stop at edges when h and l
fix: fix dd not updating screen
fix: render after all delete moves
|
|
Going to $ made draw_page render cursor to wrong line
|
|
|
|
Replaced dlist linelist with continuous memory blocks. This will allow
editing huge files without billion mallocs. File is first opened with
mmap() and mapped region is fully described in block_list as one block.
Currently "valid" data is described as slices, when first loading file
there is only one slice that points to memory existing in block_list.
When cutting text, block_list is not freed or modified, but instead
slice_list is modified to have "hole" between 2 slices. when inserting
new mem_block is added, previos slices are cut in cursor position and
new slice is added...
Added functions to handling data inside block_list+slice_list
insert_str(), cut_str() are used for all delete and add operations
text_strrchr(), text_strchr() are used for searching lineendings
text_byte(), text_codepoint(), text_getline() are for simple data access
Implemented: more or less all previous functionality
Implemented more proper file write:
file is saved to .swp, blocks are unloaded, file permissions are copied,
and atomic rename is called, block is reloaded
chmod some defaults(rw-rw-r--) if original file could not be fstat (does
not exist)
FIX make all tests pass
Removed: Some unused functions
|
|
Test file integrity after load, move, delete and save+exit. Drawing
of buffer is not tested yet.
Added -s script option, accept file that is run as startup script of
commands. File is parsed byte at time and handled as you had typed it.
If EOF has been reached without editor close command, editing is
continued normally using keyboard. This functionality is in vim and
neovim, but not in POSIX vi standard. nvi (vi used in some macs) has
-s with different meaning...
Some simple tests added, dw last line test fails, so test is disabled.
|
|
fix: first line delete
fix: delete with e move
fix: statusline 1 row lower, remove eol
cleanup: use dlist_pop on delete
cleanup: move globals into GLOBALS
|
|
^D is the opposite of ^U in vi (the ^D/^U pair is the half-screen
version of ^F/^B). ^C is unbound in vi. It's pretty surprising for these
to cause toybox vi to exit, and it's annoying as long as toybox vi
unconditionally exits rather than checks whether there are unsaved
modifications!
(I'm tempted to implement ^D/^U and ^F/^B, but I don't want to make
Jarno's rebase of his in-progress changes any harder.)
|
|
mbtowc(0, 0, 4) is weird, and ignoring the result is weird. Avoid all
this by just reusing the toybox lib utf8 functions.
Also fix the row/column display on the status line to count from 1 and
correctly distinguish bytes and characters in non-ASCII, and change the
mode output to only explicitly say when we're in insert mode, in the
same way that vim does. (Every time I saw the old blue-on-black text for
COMMAND I thought toybox vi had crashed!)
|
|
add: linelist unload
fix: proper utf8 handling on insert mode backspace
fix: free allocated data at exit
cleanup: rename some variables to be describive but short
cleanup: reorganize some variables in main
|
|
fix: force redraw after :set (no)list
fix: force redraw after insert
fix: split on zero cursor position
fix: yank and push with utf-8 content
|
|
Scroll visual buffer up and down using standard escapes when content
has not changed, instead of redrawing every keypress.
Sidescroll now moves all the lines instead of only cursor one.
Side scrolling long lines unfortunately causes redraw to whole screen.
-Jarno
|
|
Added: yank and push
Rewrote: delete operations
Minor cleanups:
Rewrote delete operations to use one delete function instead of having
separate behavior here and there.
Now delete and yank both always move cursor and then clip the whole
cursor area into yank register. For example x is just ld or jd depeding
are we right edge or not, and dd is jd with some special flags etc.
Now only default yank register is implemented, but implemeting
yank register list should be trivial since cmd execution already passes
register char.
|
|
Replaced: draw_str_until with lib/crunch_str() where possible
Removed: Unused char draw functions.
Implemented: crunch_nstr() which is crunch_str with additional check
for byte length, this can be used to draw substrings or non null
terminated strings. (This can be moved to lib/ if its useful for others)
Reimplemented: Buffer drawing without line wrapping. Now too long lines are
drawn with @ in end. And cursor line scrolls left and right when hitting
right margin point. This will simplify buffer handling alot.
Linewrapping can be reimplemented later if needed but will add
complexity
Implemented: set list and set nolist ex commands, set list will show
escape codes such as tabs
Fix: Bug on splitting 2 lines, split was 1 byte off.
|
|
Add: tabs, follows tabstop variable currently hardcoded to 8. Should be adjustable with :set tabstop N according to man page
fix: search, issue with searching substring that is more left than
cursor position on following lines.
|
|
I really needed to be able to edit a file on the device, and this was
the nearest thing handy, and it turns out to be more or less usable for
basic editing, so...
Support cursor keys.
Support :q (since there's currently no record of whether the file's
modified or not, :q is the same as :q!).
Add 'A' to insert at end of line.
Add 'n' to find next after '/'.
Fix backspace all the way to get out of ex command mode.
Fix escape sequences to not hard-code assumptions about the terminal's
default background and foreground colors.
Fix 'spesial' typo for 'special', and remove explicit array sizes.
|
|
Reimplemented to command mode execution to follow vi cmd pattern.
(REG)[COUNT0]{CMD}[COUNT1]<MOV>(SYM)
Most of the moves can be executed intependently or before command,
some require character after. (possibly with utf8)
Some of the commands do not require move, such as D, J, dd, yy, x...
There is also tons of special cases where move behaves differently
depending on command. For example 1cw and 1ce appear to be the same
but 1dw and 1de are not...
Most of the operations still need reimplementing and lots of cleanup
in order them to behave correctly
refactored word move to work with utf-8
|
|
|
|
Reimplemented basic cursor movements and char delete.
In order to work more correctly with utf-8 data.
x,h,j,k,l seems to work now with test data such as
tests/files/utf8/test2.txt
hjkl now accept count parameter so 1000j will scroll file 1000 lines
relative move to bottom
word movements w,e,b... still need to be still reimplemented in order to
step correctly on utf-8 data
|
|
Style cleanups:
Removing whitespaces at end of lines, hopefully reduces git am
warnings
Bug fixes:
fix segfault if file did not exist, now creates one empty line
fix insert mode text not showing on start of line
fix append on empty line
fix cursor move right on empty line
|
|
Now calculates utf-8 rune width properly before trying to print on screen.
works with test1.txt and test2.txt on tests/files/utf8 folder with
0x0300-0x036F combining chars
Uses mbtowc and wcwidth to calculate width of rune. These both should be
implemented on c runtime that conforms POSIX-1.2001. Different c
runtimes might have different level of support to combining char
ranges etc...
I think there is no standard way to calculate utf-8 rune width without
converting it first to widechar. And i think conversion to widechar just
to calculate width is silly, since all write calls can be done with utf8
directly (on utf8 locales ofc), but in order to calculate them yourself
without pointless conversion, one would need to write variable byte lookup
array for binary searching weird ranges and make sure it works with big-endian
systems too...
By the way running ./watch ./cat tests/files/utf8/japan.txt does not print the
text for some reason, but other test data does... I was checking how
well original crunch_str works and noticed it.
-Jarno
|
|
Variable initialization to start of blocks
Space after if,for,while: if() -> if ()
Space after comma on function calls:
write(fd,buf,count); -> write(fd, buf, count);
Spaces surrounding variable initialization
Pointer * binding to variable instead of type: int* i -> int *i
Spaces surrounding compare operators
No spaces surrounding arimetic operators
Some aligntment whitespace fixes
Still messy and needs more cleanup, but there is bigger issues to solve
first.
|
|
Removed for(int i = 0;....) style loop initializers to be consistant
with project style.
Removed few unused global variables
Added 2 empty white space lines back to CONFIG comment section.
|
|
Has beginnings of reading file, saving file, hjkl movement, insert, ex
(only w, wq, q!), search with /, some other normal mode actions (dd, w, b,
e), some utf8 support
Everything is still very unfinished and partly behaves wrongly comparing
to original vi. But simple tasks like modifying short config files
should be possible.
Some things like draw_page needs serious refactor since it now writes
whole screen after every keypress. Didint bother to refactor yet if
linked list needs to be replaced with something else...
|
|
|
|
|
|
|