#+TITLE: Editor mode * Introduction If a command is complex, it may be easier to edit it in the *editor mode*. The main difference is that ~Enter~ / ~^M~ no longer executes the program, but it is possible to switch to the main mode in order to execute it. * Ways to get into editor mode There are several ways to get into *editor mode*: * switch to it using keybindings * save the command as a file, which automatically puts into the *editor mode* * open a file (the current command is then lost / appended to history?) * Ways to get out of editor mode By using a special keybinding * Two versions of edit mode: minimal and fullscreen * full screen is automatically activated on entering edit mode, open file, insert text, edit if there is more lines than possible in edit mode (not outside) * Key sequence to enter or exit fullscreen mode: ~^KF~ (can not exit if file too big, but possible exit *edit mode* and enter normal mode) * when in fullscreen mode, additional functionality can be used: - ~^W~: scroll one line up - ~^Z~: scroll one line down * Differences between main mode and the editor mode * ~^M~ / ~Enter~ split lines without executing * ~^N~ acts the same way, except that it leaves the cursor on the previous line (?inconsistency with the main mode?) * No history commands * ~^QF~ and ~^QA~: Search & replace commands: search in text instead of history * In order to tell the difference between two modes, a status bar at the top (? or bottom/end) of file is inserted * Open/Save/Write-block/Insert-from-file dialogs are on seperate screen (?if full screen?) * ?make the editor fullscreen? * ?implement scroll functions/keybindings? * ~^QE~ and ~^QX~: move cursor to the beginning or the end of the screen * Key bindings for editor mode ** main mode key bindings * Switch to *editor mode* and open a file: ~^KE~ * Switch to *editor mode*: ~^KD~ * Switch to *editor mode* saving buffer as file: ~^KS~ * (?) ~^KX~: save buffer contents as file without entering edit mode ** editor mode key bindings * Open a file: ~^KE~ * Save the current file: ~^KS~ * Save a copy of the current file: ~^KO~ * Close the current file and save: ~^KX~ Exit *editor mode*, buffer empty * Close the current file without saving: ~^KQ~ Exit *editor mode*, buffer empty * Exit *editor mode* (do not save), with file contents as buffer: ~^KD~ * WS document screen examples #+BEGIN_SRC I:EXAMPLE.TXT L00001 C01 Insert Mo Layn Dodo Ko lo po? < Somi goa prepuddla. Suso kosho be? UUiipwz koKO? kdie! < Sizieidifi.... < < fkkflj ^ ^ ^ #+END_SRC Properties * TAB/^I inserts TAB (size=8) * Line non-empty: last char='<', line empty or last: last char='^' too long='+' * Header shows file name / location, line, column, insert/overwrite mode * When in overwrite mode, "Insert" disappears. * About the implementation In both fullscreen and normal edit modes there is a header row. There is never a footer row. In both modes the text being edited is in the ~$ws_text~ variable, that must be always up to date with the screen contents. All editing functions work in the first place on the ~$ws_text~ variable. The ~$BUFFER~ variable contains the header and the visible part of the text, as well as some empty lines in order to completely fill the screen when in fullscreen mode. Some points about the editor behaviour regarding the end of line: * Empty lines are ended in ~^~ as opposed to ~<~ or ~+~ when the line contains some text. * Functions that delete not selected text beyond the screen (delete word, line...) have to be rewritten. * The location of end-of-line symbols is on the col 80, when aligning paragraphs, the last character is on col 65. * Lines inside the paragraphs are not marked with an end-of-line symbol: only the last and empty lines are. * In blocks lines, containing ~~ and ~~ are marked with ~B~ and ~K~ respectively. * In column mode, empty lines are marked with ~B~ and non-empty the lines are marked only with ~K~. * ~B~ and ~K~ have priority over other end-of-line characters and ~K~ has priority over ~B~. * ~B~ and ~K~ appear only when trere is a selected text, when there is only ~~ and / or ~~, the default characters are displayes in the last column.