aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/vi.c
AgeCommit message (Collapse)Author
2019-10-04vi: Scroll unmodified lines using escape codesJarno Mäkipää
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
2019-09-22vi: Added yankJarno Mäkipää
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.
2019-09-19vi: changes to buffer drawingJarno Mäkipää
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.
2019-09-09vi: added support for tabsJarno Mäkipää
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.
2019-09-07vi: small fixes.Elliott Hughes
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.
2019-04-22vi.c changes to vi cmd executionJarno Mäkipää
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
2019-04-16Add argument to xflush() so it can test for stdout err without flushing.Rob Landley
2019-04-03VI rewrote char delete and hjkl movementsJarno Mäkipää
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
2019-03-29vi: bug fixesJarno Mäkipää
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
2019-03-28vi.c improved utf-8 supportJarno Mäkipää
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
2019-03-24vi: Code style cleanupJarno Mäkipää
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.
2019-03-23vi: Removed C99/GNU99 style for loop initializersJarno Mäkipää
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.
2019-03-23vi.c double_list based implementation.Jarno Mäkipää
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...
2015-12-23Factor out draw_str() and friends.Rob Landley
2015-12-19Redo linestack to handle embedded NULs.Rob Landley
2015-12-19Start of vi.Rob Landley