Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch trunk Excluding Merge-Ins
This is equivalent to a diff from 2433dfa895 to 2f954c5448
|
2025-10-01
| ||
| 09:28 | _ Leaf check-in: 2f954c5448 user: sergey6661313 tags: trunk | |
|
2025-09-30
| ||
| 16:36 | fixed drawing again ^_^ check-in: 55153b6a1d user: sergey6661313 tags: trunk | |
|
2022-08-15
| ||
| 19:07 | copy from workinkg version check-in: 7c7c110589 user: user tags: trunk | |
|
2022-08-06
| ||
| 20:55 | ipd Closed-Leaf check-in: 2433dfa895 user: user tags: hm.. | |
|
2022-08-02
| ||
| 10:30 | upd check-in: 40f050ccdd user: user tags: hm.. | |
Changes to README.md.
|
| > > > > > > > > > > | | > | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | > > > | > > > > | | > > | > > > | > > | > > > > > | > > > > > | | > > > > | > > > | > > > | > > > > | > > | > > > | > > | > > > | > > > > > | > | > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > | > > > > > > > | > > > | > > > > > > > | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
## licenze:
This code and its derivatives can be used under the following conditions:
- Do not attack other countries.
- Jerk off on public at least 1 time per day.
- maintain hygiene.
- check my other projects https://chiselapp.com/user/sergey6661313
## about:
# ScalpiEditor - ansi-only text editor
killer features: no. its just editor.
writed from zig language for linux terminals.
Initially I wrote the editor exclusively in zig, but then I wanted to rewrite it to just C in future.
error system:
zig: The error system in zig is good, but it does not help with segfaults.
I still have to look for the error with binary search, stupidly placing debugging in the program.
C: no error system - less asm output code.
unwraping:
zig: I need stupid explicit casting or unwraping for "[*c]" and "?"
c: i can write "*ptr" or ptr[0] and its just work.
No matter to real pointer value - null or not.
and i can write "if (ptr) {...}" for just check it.
Moreover, in some libraries "-1" is sometimes returned as an error value instead of a pointer,
which completely breaks the innovation of mandatory null checks.
tagged unions:
zig: Types like Tagged union are generally confusing. zig hust hided tag.
c: It is much easier to use structures with a EXPLICIT tag and data.
## Editor Functionality:
Handles input/output operations, including reading from and writing to the terminal.
Supports text manipulation features such as inserting, deleting, and navigating through text.
Includes clipboard operations, marking lines, and easy motion for quick navigation.
Provides functionality to fold and unfold sections of the text based on indentation.
Supports saving and loading files, including external copying using a temporary file.
Implements a macro recording and playback system for repetitive tasks.
Provides support for commentary highlighting and setting various font styles for text. (in src)
## Noteworthy Features
Easy Motion: A mode for quick navigation within the text using key shortcuts.
Macro Recording: Allows recording sequences of key presses to be replayed later.
Text Folding: Automatically folds sections of text based on indentation levels.
Clipboard Integration: Supports external clipboard operations via a temporary file.
## videos (not tutorials. deprecated. many keys remaped. But idea of navigating is showed...):
https://www.youtube.com/watch?v=8sJJOQeyOTE
https://www.youtube.com/watch?v=8qQlMbE8Zmw
https://www.youtube.com/watch?v=51ao2416ioE&t=60s
## main dev page:
https://chiselapp.com/user/sergey6661313/repository/ScalpiEditor/
## Download src:
select version:
https://chiselapp.com/user/sergey6661313/repository/ScalpiEditor/
just open file main.c/main.zig in repo and press download.
## FAQ:
* pasta from system clipboard makes the text move apart
try change new_line mode: [alt] + [b]
try paste multiline text only in folded mode: [ctrl] + [e]
* copy to file not work
copy to file copyid only cutted lines...
first clear "cut" buffer with [Alt] + [z]
then copy blocks with ctrl + c to "cut" buffer
and then use [Alt]+[c]
* Why did I refuse to parse the colon in the file name?
In the linux operating system, files with a colon in the name are often created.
* Nothing work or crash on start
try download earleer version by timeline in repo. i mark not work version as red.
Use terminal only with monospaced fonts. crazy fonts giving crazy resaults.
* Does not offer to save the file on exit.
Idiot protection does not work, if the fool is used to pressing "y" on every programm.
* Why i not support UTF? why display only ansi symbols?
just help me write this :))
I search in network how to determine - terminal work with unicode or not.
And i not find how to check this.
Some times terminal work with unicode partially - how to check this?
* no history
partialy undo work - only for current line.
the editor doesn't have to keep the whole history, it's a job for csv.
like fossil, git or any you want (jj is simpliest for this).
do not make many changes to the code at once. It's unhealthy.
* how to open and close multiple files?
just use multiple tabs in your terminal. (if terminal can this)
or use multiple terminals (if you use graphical mode)
or use any terminal multiplexer.
and use [Alt]+[c] and [Alt]+[v] for copy paste
* Mouse not work
I use scroling for view terminal history.
I don not ability to catch only buttons without catch scrolling.
## to support me
with boosty:
https://boosty.to/cutloosedev
with monero:
87T7 qGbA TrM3 a6Br
DyeC jQQf NWtU u3iZ
bHVB MC6W mEbN NE13
Qrrt KhBb e4vF 58NR
8PTF dYk2 Sozc HexX
4Q69 jbdQ Asrs P7B
## additional tips for linux:
i use "sakura" terminal. There no work "ctrl+shift+left" key-sequence but other thing work norm.
previously i try terminals: zutty, kitty, alacritty, Terminology - all good (not perfect) work.
## you may rename and copy binary to "~/bin/se" like this:
cp ./main ~/bin/se
## and add this lines to config (".bashrc" file for bash) for easy use:
export EDITOR="~/bin/se"
export PATH="~/bin:$PATH"
## additional tips for windows:
in windows i recommend use alacritty.
it does not overload the system.
but sometimes you have to use shift+ins instead of the usual ctrl+shift+v.
it can just freeze if change keyboar layout many times. Or just disable keys like "{".
## you can try add folder with bin file to system path like this:
## temporaly:
$env:path += ";$($pwd.Path)"
## temporally for your custom folder
$env:path += ";C:\TopSecret\Bin"
## or
$addPath = 'C:\TopSecret\Bin'
## or for not temporally:
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$($pwd.Path)", "User")
## list of bindings:
warning! the operation of certain key combinations depends on the terminal and not on me.
if key combination not work try another terminal.
(for reference: in some programs all key combinations work,
not because their code is correct, but because they use dirty hacks.
For example, they intercept the keyboard through root access.
Such programs need to be installed into the system, instead of just copying.
I don't like installers - that won't happen in my text editor.)
basic keys:
help [F1]
save [Ctrl] + [s]
exit [Ctrl] + [q]
navigation:
use arrows for navigation
enter block [Tab]
leave block [Esc]
go to start of line [Home] or [Ctrl] + [Shift] + [Left]
go to end of line [End] or [Ctrl] + [Shift] + [Right]
go to line from number [Ctrl] + [g]
go to left word [Ctrl] + [Left]
go to right word [Ctrl] + [Right]
go to prev block [Ctrl] + [up]
go to next block [Ctrl] + [Down]
symbol interacting:
insert as prev [any symbol]
delete prev [BackSpace]
delete next [Del]
lines/blocks interacting:
split line [Enter]
join lines [Ctrl] + [j] // also sometimes [Ctrl] + [enter] work. and you can try [num_enter]
move up [Alt] + [Up] // not work on some terminals...
move down [Alt] + [Down]
clear line [Shift] + [Del]
duplicate [Ctrl] + [d]
word interactig:
delete current word: [ctrl] + [w]
copy current word to find buffer: [Alt] + [1]
mark:
mark [Alt] + [m]
jump to mark [Alt] + [g]
move out current block [Alt] + [8]
move block outside mark [Alt] + [0] (only in folded mode)
move block inside mark [Alt] + [9] (only in folded mode)
move block before mark [Alt] + [0]
macroses:
start record macro [F1]
stop record macro [F2]
play latest recorded macro [F3]
also there are many buffers:
1) buffer for blocks/lines:
cut [Ctrl] + [x]
copy [Ctrl] + [c]
paste [Ctrl] + [v]
discard cutted/coppied [Alt] + [z]
2) external buffer (file "clipboard.txt")
copy [Alt] + [c]
paste [Alt] + [v]
3) using buffer for finding text:
copy current word [Alt] + [1]
find prev: [Alt] + [2]
find next: [Alt] + [3]
paste [Alt] + [4]
replace finded: [Alt] + [6] // for replace need cursor placed on start of finding text
change mode:
fold/unfold [Ctrl] + [e]
edit finding buffer [Ctrl] + [f]
edit replace buffer: [Alt] + [5]
auto space [alt] + [b]
easy motion:
horizontal: [Alt] + [q]
vertical: [Alt] + [e]
|
Deleted README.md.bak.
Deleted build.zig.
|
| < < < < < < < < < < < |
Added main.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 |
// about
/*
licenze:
This code and its derivatives can be used under the following conditions:
- Do not attack other countries.
- Jerk off on public at least 1 time per day.
- Observe hygiene.
- check my other projects https://chiselapp.com/user/sergey6661313
about:
ScalpiEditor - ansi-only text editor for terminals.
killer features: no. its just editor.
Compile:
this file is just part of zig version (for now)
current version used zig compiller for compile zig file. (unstructions inside zig file)
in future you can use any C compiller, but not now.
nevest C compillers is DUMB!
they insert thousands of checks of what I did not ask them to insert. Here is how you can avoid it:
-fno-stack-protector -fno-sanitize=undefined
also for debug use:
-Og -g
todo. alse try next keys for optimize size
-ffunction-sections -fdata-sections -Wl,--gc-sections
-nostdlib -Oz -Qn -m32 -static -s -N -Wl,--build-id=none -fno-asynchronous-unwind-tables
to support me
with boosty:
https://boosty.to/cutloosedev
with monero:
87T7 qGbA TrM3 a6Br
DyeC jQQf NWtU u3iZ
bHVB MC6W mEbN NE13
Qrrt KhBb e4vF 58NR
8PTF dYk2 Sozc HexX
4Q69 jbdQ Asrs P7B
why i cancel use zig:
gabarages in output code.
zig perfecly crash without printing stack trace in non standart situations. (main feature of zig)
Zig does not try fix console flags before print stack trace.
zig can crash to segfault like c.
tagged enum does not sense.
c: tagged_enum.tag = ANOTHER_TAG;
zig: tagged_enum = .{.ANOTHER_TAG = tagged_enum.LAST_USED_TAG.data};
operator ".?" does not sense:
c: while(link) { i++; link = link->next; }
zig: while(link) |_| { i += 1; link = link.?.next; }
zig idiomatic: while(link) |unwrapped_link|{ i += 1; link = unwrapped_link.next; }
nullable types are inconvenient.
c: if (link) i++;
zig idiomatic: if (link) |_| i += 1;
zig but C pointer: if (@intFromPtr(link) != @intFromPtr(c.NULL)) i += 1;
*/
// TODO
/*
remove name buffer_len. use buffer_max_size and buffer_used instead.
*/
// desctiptions
// # __AlignedPtr__
/* its a virtual struct becouse C not have "anytype" type.
struct __AlignedPtr__ {
char gap[gap_size] // padding for aligning data. gap_size can be 0.
anytype your_data // <- the pointer that the alloc function returns will be pointed here.
uint8_t gap_size
}
*/
// AP - its hex like but use from 'a' to 'p' values for symbols
// __NetworkTcpHttpWebSocketHeader__
// real struct of web socket header:
// fin_flag: u1 = 1,
// rsv: [3]u1 = .{0,0,0},
// opcode: Opcode = .binary, // may be text
// mask_flag: u1 = 0,
// payload_len: u7 = 0,
// extended_payload_len: u16 or u64 or void (optional)
// masking_key: u64 or void (optional)
// 2 bytes (__NetworkTcpHttpWebSocketHeaderSmall__) header for sizes 1 ... 125
// 4 bytes (__NetworkTcpHttpWebSocketHeaderMedium__) header for sizes 126 ... 65535
// 10 bytes (__NetworkTcpHttpWebSocketHeaderLong__) header for sizes more than 65535
// enums
// # __LoggerWriter__
#define __LoggerWriter_toFallback__ 0
#define __LoggerWriter_toFile__ 1
#define __LoggerWriter_toConsole__ 2
#define __LoggerWriter_toTerminal__ 3
// # __MemTree_fix_counts_Action__
#define __MemTree_fix_counts_Action_plus__ 'p'
#define __MemTree_fix_counts_Action_minus__ 'm'
// # __MemTree_fix_nested_Action__
#define __MemTree_fix_nested_Action_plus__ 'p'
#define __MemTree_fix_nested_Action_minus__ 'm'
// # __OsNetworkTcpSocketConnectResult__ (char)
#define __OsNetworkTcpSocketConnectResult_error__ -1
#define __OsNetworkTcpSocketConnectResult_inProgress__ 0
#define __OsNetworkTcpSocketConnectResult_success__ 1
// # __TargetMemoryType__
#define __TargetMemoryType_endiansLittle__ 1
#define __TargetMemoryType_endiansBig__ 2
// # __TargetOs__
#define __TargetOs_windows__ 1
#define __TargetOs_linux__ 2
// settings
// # __AppEditorLineLen_max__
#define __AppEditorLineLen_max__ (1024 * 8)
// # __AppEditorTheme_arrows__
#define __AppEditorTheme_arrows__ \
__ConsoleAnsiOutputFontStyle_start__ \
__ConsoleAnsiOutputFontStyle_unbold__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_bg_color_zero__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_color_yellow__ \
__ConsoleAnsiOutputFontStyle_end__
// # __AppEditorTheme_commentary__
#define __AppEditorTheme_commentary__ \
__ConsoleAnsiOutputFontStyle_start__ \
__ConsoleAnsiOutputFontStyle_bg_color_zero__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_color_yellow__ \
__ConsoleAnsiOutputFontStyle_end__
// # __AppEditorTheme_current__
#define __AppEditorTheme_current__ \
__ConsoleAnsiOutputFontStyle_start__ \
__ConsoleAnsiOutputFontStyle_bg_color_zero__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_color_light_green__ \
__ConsoleAnsiOutputFontStyle_end__
// # __AppEditorTheme_current_commentary__
#define __AppEditorTheme_current_commentary__ \
__ConsoleAnsiOutputFontStyle_start__ \
__ConsoleAnsiOutputFontStyle_bg_color_zero__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_color_yellow__ \
__ConsoleAnsiOutputFontStyle_end__
// # __AppEditorTheme_current_disabled__
#define __AppEditorTheme_current_disabled__ \
__ConsoleAnsiOutputFontStyle_start__ \
__ConsoleAnsiOutputFontStyle_bg_color_zero__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_color_light_green__ \
__ConsoleAnsiOutputFontStyle_end__
// # __AppEditorTheme_current_folded__
#define __AppEditorTheme_current_folded__ \
__ConsoleAnsiOutputFontStyle_start__ \
__ConsoleAnsiOutputFontStyle_bold__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_bg_color_zero__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_color_light_green__ \
__ConsoleAnsiOutputFontStyle_end__
// # __AppEditorTheme_current_rune__
#define __AppEditorTheme_current_rune__ \
__ConsoleAnsiOutputFontStyle_start__ \
__ConsoleAnsiOutputFontStyle_bg_color_zero__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_color_magenta__ \
__ConsoleAnsiOutputFontStyle_end__
// # __AppEditorTheme_disabled__
#define __AppEditorTheme_disabled__ \
__ConsoleAnsiOutputFontStyle_start__ \
__ConsoleAnsiOutputFontStyle_bg_color_zero__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_color_magenta__ \
__ConsoleAnsiOutputFontStyle_end__
// # __AppEditorTheme_easy_motion__
#define __AppEditorTheme_easy_motion__ \
__ConsoleAnsiOutputFontStyle_start__ \
__ConsoleAnsiOutputFontStyle_bg_color_zero__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_color_yellow__ \
__ConsoleAnsiOutputFontStyle_end__
// # __AppEditorTheme_folded__
#define __AppEditorTheme_folded__ \
__ConsoleAnsiOutputFontStyle_start__ \
__ConsoleAnsiOutputFontStyle_bold__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_bg_color_zero__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_color_zero__ \
__ConsoleAnsiOutputFontStyle_end__
// # __AppEditorTheme_folded_arrows__
#define __AppEditorTheme_folded_arrows__ \
__ConsoleAnsiOutputFontStyle_start__ \
__ConsoleAnsiOutputFontStyle_bold__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_bg_color_gray__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_color_yellow__ \
__ConsoleAnsiOutputFontStyle_end__
// # __AppEditorTheme_headers__
#define __AppEditorTheme_headers__ \
__ConsoleAnsiOutputFontStyle_start__ \
__ConsoleAnsiOutputFontStyle_bold__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_bg_color_zero__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_color_cyan__ \
__ConsoleAnsiOutputFontStyle_end__
// # __AppEditorTheme_notification__
#define __AppEditorTheme_notification__ \
__ConsoleAnsiOutputFontStyle_start__ \
__ConsoleAnsiOutputFontStyle_bg_color_zero__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_color_red__ \
__ConsoleAnsiOutputFontStyle_end__
// # __AppEditorTheme_reset__
#define __AppEditorTheme_reset__ \
__ConsoleAnsiOutputFontStyle_start__ \
__ConsoleAnsiOutputFontStyle_reset__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_bg_color_zero__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_color_zero__ \
__ConsoleAnsiOutputFontStyle_end__
// # __AppEditorViewsEasyMotionHorizontal_step__
#define __AppEditorViewsEasyMotionHorizontal_step__ 3
// # __AppEditorViewsEasyMotionVertical_step__
#define __AppEditorViewsEasyMotionVertical_step__ 2
// # __App_expectedFps__
#define __App_expectedFps__ 30
// # __OsFilePathLen_max__
#define __OsFilePathLen_max__ 1024
// # __OsNetworkTcpHttp_maxHeaders__
#define __OsNetworkTcpHttp_maxHeaders__ 48
// # __OsNetworkTcp_maxClientCount__
#define __OsNetworkTcp_maxClientCount__ 8
// # __TerminalInput_size__
#define __TerminalInput_size__ 32
// # __target_memoryType__
#define __target_memoryType__ __TargetMemoryType_endiansLittle__
// # __target_os__
//#define __target_os__ __TargetOs_linux__
#ifndef __target_os__
#ifdef _WIN32
#define __target_os__ __TargetOs_windows__
#elif defined(__linux__)
#define __target_os__ __TargetOs_linux__
#endif
#endif
// # __with_network__
#define __with_network__ 0
// macro
// types and structs
// # __Size__
#define __Size__ __Type_getSize__(size_t)
// # __Ptr__
#define __Ptr__ __Type_getSize__(uintptr_t)
// # __Slice__
// # __Slice_ptr__
#define __SlicePtr__ __Ptr__
#define __Slice_ptr__ 0
// # __Slice_len__
#define __SliceLen__ __Size__
#define __Slice_len__ __Align_up__(__Slice_ptr__ + __SlicePtr__, __Size__)
// c
// # __Addr_fromPtr__
#define __Addr_fromPtr__(ptr) ((uintptr_t)(ptr))
// # __Align_up__
#define __Align_up__(offset, align) (((offset) + (align) - 1) & ~((align) - 1))
// # __CText_len__
#define __CText_len__(str) (__arrayLen__(str) - 1)
// # __CText_write__
#define __CText_write__(buffer, text) (__Mem_copy__(buffer, text, __CText_len__(text)), __CText_len__(text))
// # __Instance_fromPtr__
#define __Instance_fromPtr__(ptr) (*(ptr))
// # __Struct_getFieldOffset__
#define __Struct_getFieldOffset__(type, field) (__Addr_fromPtr__(__TypedPtr_getFieldPtr__(__TypedPtr_virtual__(type), field)))
// # __Type_getAlign__
#define __Type_getAlign__(type) (__Struct_getFieldOffset__(struct {char c; type t;}, t))
// # __Type_getSize__
#define __Type_getSize__(type) (__Struct_getFieldOffset__(struct {type t; char c;}, c))
// # __TypedPtr_fromAddr__
#define __TypedPtr_fromAddr__(type, addr) ((type*)(addr))
// # __TypedPtr_getFieldPtr__
#define __TypedPtr_getFieldPtr__( ptr, field_name) (&(ptr)->field_name)
// # __TypedPtr_getParentPtrFromFieldPtr__
#define __TypedPtr_getParentPtrFromFieldPtr__( type, field_name, field_ptr) (__TypedPtr_fromAddr__(type, __Addr_fromPtr__((field_ptr)) - __Struct_getFieldOffset__(type, field_name)))
// # __TypedPtr_virtual__
#define __TypedPtr_virtual__( type) (__TypedPtr_fromAddr__(type, 0))
// # __arrayLen__
#define __arrayLen__( array) (sizeof((array)) / sizeof((array[0])))
// # __len_and_text__
#define __len_and_text__( str) __CText_len__(str), str
// # __text_and_len__
#define __text_and_len__( str) str, __CText_len__(str)
// # and
#define and &&
// # or
#define or ||
// os
// # __OsConsoleOutput_writeCText__
#define __OsConsoleOutput_writeCText__( ctx, text) \
__OsConsoleOutput_write__( ctx, text, __CText_len__(text))
// # __OsFile_readToAny__
#define __OsFile_readToAny__( file, buffer, buffer_len, offset ) \
__OsFile_readToBuffer__( file, (char*) (buffer), buffer_len, offset )
// # __OsMem_allocAny__
#define __OsMem_allocAny__( ret_data_addr, size) \
__OsMem_alloc__( (uintptr_t*) (ret_data_addr), size)
// # __OsMem_freeAny__
#define __OsMem_freeAny__( ret_data_addr) \
__OsMem_free__( (uintptr_t) (ret_data_addr))
// # __OsNetworkTcp_maxAllowedListenPort__
#define __OsNetworkTcp_maxAllowedListenPort__ 49151
// Os specific
#if __target_os__ == __TargetOs_windows__
#define WSA_SUCCESS 0
#elif __target_os__ == __TargetOs_linux__
#else
#error "__target_os__ not implemented"
#endif
// # breakpoint
#if __target_os__ == __TargetOs_windows__
#define breakpoint() DebugBreak()
#elif __target_os__ == __TargetOs_linux__
#define breakpoint() raise(SIGTRAP)
#else
#error "__target_os__ not implemented"
#endif
// lib
// # Sha1_digest_length
#define Sha1_digest_length 20
// # __AlignedPtr_allocAny__
#define __AlignedPtr_allocAny__( ret_data_addr, mem_align, size) \
__AlignedPtr_alloc__( (uintptr_t*) (ret_data_addr), mem_align, size)
// # __AlignedPtr_freeAny__
#define __AlignedPtr_freeAny__( ret_data_addr, size) \
__AlignedPtr_free__( (uintptr_t) (ret_data_addr), size)
// # __ConsoleAnsiInputKey_alt_0__
#define __ConsoleAnsiInputKey_alt_0__ ('0' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_1__
#define __ConsoleAnsiInputKey_alt_1__ ('1' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_2__
#define __ConsoleAnsiInputKey_alt_2__ ('2' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_3__
#define __ConsoleAnsiInputKey_alt_3__ ('3' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_4__
#define __ConsoleAnsiInputKey_alt_4__ ('4' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_5__
#define __ConsoleAnsiInputKey_alt_5__ ('5' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_6__
#define __ConsoleAnsiInputKey_alt_6__ ('6' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_7__
#define __ConsoleAnsiInputKey_alt_7__ ('7' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_8__
#define __ConsoleAnsiInputKey_alt_8__ ('8' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_9__
#define __ConsoleAnsiInputKey_alt_9__ ('9' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_M__
#define __ConsoleAnsiInputKey_alt_M__ ('M' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_N__
#define __ConsoleAnsiInputKey_alt_N__ ('N' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt__
#define __ConsoleAnsiInputKey_alt__ (1 << 11)
// # __ConsoleAnsiInputKey_alt_a__
#define __ConsoleAnsiInputKey_alt_a__ ('a' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_apostrophe__
#define __ConsoleAnsiInputKey_alt_apostrophe__ ('`' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_b__
#define __ConsoleAnsiInputKey_alt_b__ ('b' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_c__
#define __ConsoleAnsiInputKey_alt_c__ ('c' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_close_bracket__
#define __ConsoleAnsiInputKey_alt_close_bracket__ (']' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_comma__
#define __ConsoleAnsiInputKey_alt_comma__ (',' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_d__
#define __ConsoleAnsiInputKey_alt_d__ ('d' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_dot__
#define __ConsoleAnsiInputKey_alt_dot__ ('.' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_down__
#define __ConsoleAnsiInputKey_alt_down__ (__ConsoleAnsiInputKey_down__ + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_e__
#define __ConsoleAnsiInputKey_alt_e__ ('e' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_f__
#define __ConsoleAnsiInputKey_alt_f__ ('f' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_g__
#define __ConsoleAnsiInputKey_alt_g__ ('g' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_h__
#define __ConsoleAnsiInputKey_alt_h__ ('h' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_i__
#define __ConsoleAnsiInputKey_alt_i__ ('i' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_j__
#define __ConsoleAnsiInputKey_alt_j__ ('j' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_k__
#define __ConsoleAnsiInputKey_alt_k__ ('k' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_l__
#define __ConsoleAnsiInputKey_alt_l__ ('l' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_left__
#define __ConsoleAnsiInputKey_alt_left__ (__ConsoleAnsiInputKey_left__ + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_m__
#define __ConsoleAnsiInputKey_alt_m__ ('m' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_n__
#define __ConsoleAnsiInputKey_alt_n__ ('n' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_o__
#define __ConsoleAnsiInputKey_alt_o__ ('o' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_open_bracket__
#define __ConsoleAnsiInputKey_alt_open_bracket__ ('[' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_p__
#define __ConsoleAnsiInputKey_alt_p__ ('p' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_q__
#define __ConsoleAnsiInputKey_alt_q__ ('q' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_r__
#define __ConsoleAnsiInputKey_alt_r__ ('r' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_right__
#define __ConsoleAnsiInputKey_alt_right__ (__ConsoleAnsiInputKey_right__ + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_s__
#define __ConsoleAnsiInputKey_alt_s__ ('s' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_semicolon__
#define __ConsoleAnsiInputKey_alt_semicolon__ (';' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_t__
#define __ConsoleAnsiInputKey_alt_t__ ('t' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_u__
#define __ConsoleAnsiInputKey_alt_u__ ('u' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_up__
#define __ConsoleAnsiInputKey_alt_up__ (__ConsoleAnsiInputKey_up__ + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_v__
#define __ConsoleAnsiInputKey_alt_v__ ('v' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_w__
#define __ConsoleAnsiInputKey_alt_w__ ('w' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_x__
#define __ConsoleAnsiInputKey_alt_x__ ('x' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_y__
#define __ConsoleAnsiInputKey_alt_y__ ('y' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_alt_z__
#define __ConsoleAnsiInputKey_alt_z__ ('z' + __ConsoleAnsiInputKey_alt__)
// # __ConsoleAnsiInputKey_ascii_ctrl__
#define __ConsoleAnsiInputKey_ascii_ctrl__ (-'a' + 1) /* do not use externally */
// # __ConsoleAnsiInputKey_back_space__
#define __ConsoleAnsiInputKey_back_space__ 127 /* sometime delete */
// # __ConsoleAnsiInputKey_ctrl__
#define __ConsoleAnsiInputKey_ctrl__ (1 << 10)
// # __ConsoleAnsiInputKey_ctrl_a__ start_of_heading __ConsoleAnsiInputKey_ctrl_a__
#define __ConsoleAnsiInputKey_ctrl_a__ ('a' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_alt_v__
#define __ConsoleAnsiInputKey_ctrl_alt_v__ ('v' + __ConsoleAnsiInputKey_alt__ + __ConsoleAnsiInputKey_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_b__
#define __ConsoleAnsiInputKey_ctrl_b__ ('b' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_bs__ also ctrl_h
#define __ConsoleAnsiInputKey_ctrl_bs__ 8
// # __ConsoleAnsiInputKey_ctrl_c__
#define __ConsoleAnsiInputKey_ctrl_c__ ('c' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_d__
#define __ConsoleAnsiInputKey_ctrl_d__ ('d' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_down__
#define __ConsoleAnsiInputKey_ctrl_down__ (__ConsoleAnsiInputKey_down__ + __ConsoleAnsiInputKey_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_e__
#define __ConsoleAnsiInputKey_ctrl_e__ ('e' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_enter__
#define __ConsoleAnsiInputKey_ctrl_enter__ (__ConsoleAnsiInputKey_enter__ + __ConsoleAnsiInputKey_special__ + __ConsoleAnsiInputKey_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_f__
#define __ConsoleAnsiInputKey_ctrl_f__ ('f' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_g__
#define __ConsoleAnsiInputKey_ctrl_g__ ('g' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_h__ also ctrl_bs
#define __ConsoleAnsiInputKey_ctrl_bs__ 8
#define __ConsoleAnsiInputKey_ctrl_h__ ('h' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_i__ also # __ConsoleAnsiInputKey_tab__
#define __ConsoleAnsiInputKey_tab__ 9
#define __ConsoleAnsiInputKey_ctrl_i__ ('i' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_j__
#define __ConsoleAnsiInputKey_ctrl_j__ ('j' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_k__ vertical_tab
#define __ConsoleAnsiInputKey_ctrl_k__ ('k' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_l__ formFeed
#define __ConsoleAnsiInputKey_ctrl_l__ ('l' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_left__
#define __ConsoleAnsiInputKey_ctrl_left__ (__ConsoleAnsiInputKey_left__ + __ConsoleAnsiInputKey_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_m__ also # __ConsoleAnsiInputKey_enter__
#define __ConsoleAnsiInputKey_enter__ 13
#define __ConsoleAnsiInputKey_ctrl_m__ ('m' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_n__
#define __ConsoleAnsiInputKey_ctrl_n__ ('n' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_o__
#define __ConsoleAnsiInputKey_ctrl_o__ ('o' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_p__
#define __ConsoleAnsiInputKey_ctrl_p__ ('p' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_q__
#define __ConsoleAnsiInputKey_ctrl_q__ ('q' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_r__
#define __ConsoleAnsiInputKey_ctrl_r__ ('r' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_right__
#define __ConsoleAnsiInputKey_ctrl_right__ (__ConsoleAnsiInputKey_right__ + __ConsoleAnsiInputKey_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_s__
#define __ConsoleAnsiInputKey_ctrl_s__ ('s' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_shift_left__
#define __ConsoleAnsiInputKey_ctrl_shift_left__ (__ConsoleAnsiInputKey_left__ + __ConsoleAnsiInputKey_ctrl__ + __ConsoleAnsiInputKey_shift__)
// # __ConsoleAnsiInputKey_ctrl_shift_right__
#define __ConsoleAnsiInputKey_ctrl_shift_right__ (__ConsoleAnsiInputKey_right__ + __ConsoleAnsiInputKey_ctrl__ + __ConsoleAnsiInputKey_shift__)
// # __ConsoleAnsiInputKey_ctrl_t__
#define __ConsoleAnsiInputKey_ctrl_t__ ('t' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_triangular_close_quotation_mark__
#define __ConsoleAnsiInputKey_ctrl_triangular_close_quotation_mark__ ('>' + __ConsoleAnsiInputKey_special__ + __ConsoleAnsiInputKey_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_triangular_open_quotation_mark__
#define __ConsoleAnsiInputKey_ctrl_triangular_open_quotation_mark__ ('<' + __ConsoleAnsiInputKey_special__ + __ConsoleAnsiInputKey_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_u__
#define __ConsoleAnsiInputKey_ctrl_u__ ('u' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_up__
#define __ConsoleAnsiInputKey_ctrl_up__ (__ConsoleAnsiInputKey_up__ + __ConsoleAnsiInputKey_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_v__
#define __ConsoleAnsiInputKey_ctrl_v__ ('v' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_w__
#define __ConsoleAnsiInputKey_ctrl_w__ ('w' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_x__
#define __ConsoleAnsiInputKey_ctrl_x__ ('x' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_y__
#define __ConsoleAnsiInputKey_ctrl_y__ ('y' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_ctrl_z__
#define __ConsoleAnsiInputKey_ctrl_z__ ('z' + __ConsoleAnsiInputKey_ascii_ctrl__)
// # __ConsoleAnsiInputKey_delete__
#define __ConsoleAnsiInputKey_delete__ (5 + __ConsoleAnsiInputKey_special__)
// # __ConsoleAnsiInputKey_down__
#define __ConsoleAnsiInputKey_down__ (4 + __ConsoleAnsiInputKey_special__)
// # __ConsoleAnsiInputKey_end__
#define __ConsoleAnsiInputKey_end__ (8 + __ConsoleAnsiInputKey_special__)
// # __ConsoleAnsiInputKey_escape__
#define __ConsoleAnsiInputKey_escape__ 27
// # __ConsoleAnsiInputKey_f10__
#define __ConsoleAnsiInputKey_f10__ (10 + __ConsoleAnsiInputKey_functional__)
// # __ConsoleAnsiInputKey_f11__
#define __ConsoleAnsiInputKey_f11__ (11 + __ConsoleAnsiInputKey_functional__)
// # __ConsoleAnsiInputKey_f12__
#define __ConsoleAnsiInputKey_f12__ (12 + __ConsoleAnsiInputKey_functional__)
// # __ConsoleAnsiInputKey_f1__
#define __ConsoleAnsiInputKey_f1__ (1 + __ConsoleAnsiInputKey_functional__)
// # __ConsoleAnsiInputKey_f2__
#define __ConsoleAnsiInputKey_f2__ (2 + __ConsoleAnsiInputKey_functional__)
// # __ConsoleAnsiInputKey_f3__
#define __ConsoleAnsiInputKey_f3__ (3 + __ConsoleAnsiInputKey_functional__)
// # __ConsoleAnsiInputKey_f4__
#define __ConsoleAnsiInputKey_f4__ (4 + __ConsoleAnsiInputKey_functional__)
// # __ConsoleAnsiInputKey_f5__
#define __ConsoleAnsiInputKey_f5__ (5 + __ConsoleAnsiInputKey_functional__)
// # __ConsoleAnsiInputKey_f6__
#define __ConsoleAnsiInputKey_f6__ (6 + __ConsoleAnsiInputKey_functional__)
// # __ConsoleAnsiInputKey_f7__
#define __ConsoleAnsiInputKey_f7__ (7 + __ConsoleAnsiInputKey_functional__)
// # __ConsoleAnsiInputKey_f8__
#define __ConsoleAnsiInputKey_f8__ (8 + __ConsoleAnsiInputKey_functional__)
// # __ConsoleAnsiInputKey_f9__
#define __ConsoleAnsiInputKey_f9__ (9 + __ConsoleAnsiInputKey_functional__)
// # __ConsoleAnsiInputKey_functional__
#define __ConsoleAnsiInputKey_functional__ (1 << 9)
// # __ConsoleAnsiInputKey_home__
#define __ConsoleAnsiInputKey_home__ (9 + __ConsoleAnsiInputKey_special__)
// # __ConsoleAnsiInputKey_left__
#define __ConsoleAnsiInputKey_left__ (1 + __ConsoleAnsiInputKey_special__)
// # __ConsoleAnsiInputKey_mouse__
#define __ConsoleAnsiInputKey_mouse__ (1 << 13)
// # __ConsoleAnsiInputKey_page_down__
#define __ConsoleAnsiInputKey_page_down__ (7 + __ConsoleAnsiInputKey_special__)
// # __ConsoleAnsiInputKey_page_up__
#define __ConsoleAnsiInputKey_page_up__ (6 + __ConsoleAnsiInputKey_special__)
// # __ConsoleAnsiInputKey_right__
#define __ConsoleAnsiInputKey_right__ (2 + __ConsoleAnsiInputKey_special__)
// # __ConsoleAnsiInputKey_shift__
#define __ConsoleAnsiInputKey_shift__ (1 << 12)
// # __ConsoleAnsiInputKey_shift_delete__
#define __ConsoleAnsiInputKey_shift_delete__ (__ConsoleAnsiInputKey_delete__ + __ConsoleAnsiInputKey_shift__)
// # __ConsoleAnsiInputKey_shift_down__
#define __ConsoleAnsiInputKey_shift_down__ (__ConsoleAnsiInputKey_down__ + __ConsoleAnsiInputKey_shift__)
// # __ConsoleAnsiInputKey_shift_left__
#define __ConsoleAnsiInputKey_shift_left__ (__ConsoleAnsiInputKey_left__ + __ConsoleAnsiInputKey_shift__)
// # __ConsoleAnsiInputKey_shift_right__
#define __ConsoleAnsiInputKey_shift_right__ (__ConsoleAnsiInputKey_right__ + __ConsoleAnsiInputKey_shift__)
// # __ConsoleAnsiInputKey_shift_up__
#define __ConsoleAnsiInputKey_shift_up__ (__ConsoleAnsiInputKey_up__ + __ConsoleAnsiInputKey_shift__)
// # __ConsoleAnsiInputKey_special__
#define __ConsoleAnsiInputKey_special__ (1 << 8)
// # __ConsoleAnsiInputKey_up__
#define __ConsoleAnsiInputKey_up__ (3 + __ConsoleAnsiInputKey_special__)
// # __CryptoScalpiHash_doAny__
#define __CryptoScalpiHash_doAny__( hasher, data_ptr, data_len, dest, dest_size) \
__CryptoScalpiHash_do__( hasher, (char*)data_ptr, data_len, dest, dest_size)
// # __FileComplete_readToAny__
#define __FileComplete_readToAny__( ret_data_ptr, ret_file_data_size, file_name, file_name_len, align ) \
__FileComplete_read__( (uintptr_t*)ret_data_ptr, ret_file_data_size, file_name, file_name_len, align )
// # __Hex_bytesLenFromHex__
#define __Hex_bytesLenFromHex__(len) (len >> 1)
// # __Hex_lenFromBytesLen__
#define __Hex_lenFromBytesLen__(len) (len * 2)
// # __MemSize_gb__
#define __MemSize_gb__ (1024 * __MemSize_mb__)
// # __MemSize_kb__
#define __MemSize_kb__ 1024
// # __MemSize_mb__
#define __MemSize_mb__ (1024 * __MemSize_kb__)
// # __Mem_fillAny__
#define __Mem_fillAny__( dest, symbol, len) \
__Mem_fill__( (char*)dest, symbol, len)
// # __Mem_nativeToBig__
#if __target_memoryType__ == __TargetMemoryType_endiansBig__
#define __Mem_nativeToBig__(dest, src, size) __Mem_copy__(dest, src, size)
#elif __target_memoryType__ == __TargetMemoryType_endiansLittle__
#define __Mem_nativeToBig__(dest, src, size) __Mem_reverse__(dest, src, size)
#else
#error "please define __target_memoryType__ with __TargetMemoryType_ (you can test endings with cpu_checkNumberFormat function)"
#endif
// # __Mem_nativeToLittle__
#if __target_memoryType__ == __TargetMemoryType_endiansBig__
#define __Mem_nativeToLittle__(dest, src, size) __Mem_reverse__(dest, src, size)
#elif __target_memoryType__ == __TargetMemoryType_endiansLittle__
#define __Mem_nativeToLittle__(dest, src, size) __Mem_copy__(dest, src, size)
#else
#error "please define __target_memoryType__ with __TargetMemoryType_ (you can test endings with cpu_checkNumberFormat function)"
#endif
// # __NetworkTcpHttpWebSocketHandShake_encoded_len__
#define __NetworkTcpHttpWebSocketHandShake_encoded_len__ 28
// # __NetworkTcpHttpWebSocketHeaderLongExtendedPayloadLen_size__
#define __NetworkTcpHttpWebSocketHeaderLongExtendedPayloadLen_size__ 8
// # __NetworkTcpHttpWebSocketHeaderLong__
#define __NetworkTcpHttpWebSocketHeaderLong__ 2
// # __NetworkTcpHttpWebSocketHeaderLong_flag__
#define __NetworkTcpHttpWebSocketHeaderLong_flag__ 127
// # __NetworkTcpHttpWebSocketHeaderLong_size__
#define __NetworkTcpHttpWebSocketHeaderLong_size__ (__NetworkTcpHttpWebSocketHeaderSmall_size__ + __NetworkTcpHttpWebSocketHeaderLongExtendedPayloadLen_size__)
// # __NetworkTcpHttpWebSocketHeaderMask_size__
#define __NetworkTcpHttpWebSocketHeaderMask_size__ 4
// # __NetworkTcpHttpWebSocketHeaderMediumExtendedPayloadLen_size__
#define __NetworkTcpHttpWebSocketHeaderMediumExtendedPayloadLen_size__ 2
// # __NetworkTcpHttpWebSocketHeaderMedium__
#define __NetworkTcpHttpWebSocketHeaderMedium__ 1
// # __NetworkTcpHttpWebSocketHeaderMedium_flag__
#define __NetworkTcpHttpWebSocketHeaderMedium_flag__ 126
// # __NetworkTcpHttpWebSocketHeaderMedium_size__
#define __NetworkTcpHttpWebSocketHeaderMedium_size__ (__NetworkTcpHttpWebSocketHeaderSmall_size__ + __NetworkTcpHttpWebSocketHeaderMediumExtendedPayloadLen_size__)
// # __NetworkTcpHttpWebSocketHeaderOpcode_binary__
#define __NetworkTcpHttpWebSocketHeaderOpcode_binary__ 2
// # __NetworkTcpHttpWebSocketHeaderOpcode_close__
#define __NetworkTcpHttpWebSocketHeaderOpcode_close__ 8
// # __NetworkTcpHttpWebSocketHeaderOpcode_continuation__
#define __NetworkTcpHttpWebSocketHeaderOpcode_continuation__ 0
// # __NetworkTcpHttpWebSocketHeaderOpcode_ping__
#define __NetworkTcpHttpWebSocketHeaderOpcode_ping__ 9
// # __NetworkTcpHttpWebSocketHeaderOpcode_pong__
#define __NetworkTcpHttpWebSocketHeaderOpcode_pong__ 10
// # __NetworkTcpHttpWebSocketHeaderOpcode_text__
#define __NetworkTcpHttpWebSocketHeaderOpcode_text__ 1
// # __NetworkTcpHttpWebSocketHeaderSmallExtendedPayloadLen_size__
#define __NetworkTcpHttpWebSocketHeaderSmallExtendedPayloadLen_size__ 0
// # __NetworkTcpHttpWebSocketHeaderSmall__
#define __NetworkTcpHttpWebSocketHeaderSmall__ 0
// # __NetworkTcpHttpWebSocketHeaderSmall_size__
#define __NetworkTcpHttpWebSocketHeaderSmall_size__ 2
// # __Sha1Block_size__
#define __Sha1Block_size__ 64
// # __Terminal_setFontStyleCText__
#define __Terminal_setFontStyleCText__( ctx, text) \
__Terminal_setFontStyle__( ctx, text, __CText_len__(text))
// # __TextCharsDecFromU64_lenMax__
//#define __TextCharsDecFromU64_lenMax__ __CText_len__("18446744073709551615")
#define __TextCharsDecFromU64_lenMax__ 20
// # __TimeStamp_len__
// for write time stamp like "00:00:00" as "HH:MM:SS" where HH - hours, MM - minuts, SS - seconds
#define __TimeStamp_len__ 8
// # __Time_daysPerWeek__
#define __Time_daysPerWeek__ 7
// # __Time_hourPerDay__
#define __Time_hourPerDay__ 24
// # __Time_minPerHour__
#define __Time_minPerHour__ 60
// # __Time_msPerFsec__
#define __Time_msPerFsec__ 0.001
// # __Time_msPerS__
#define __Time_msPerS__ 1000
// # __Time_msPerSec__
#define __Time_msPerSec__ 1000
// # __Time_nsPerFsec__
#define __Time_nsPerFsec__ 0.000_000_001
// # __Time_secPerMin__
#define __Time_secPerMin__ 60
// # __Time_usPerFsec__
#define __Time_usPerFsec__ 0.000_001
// # __u64FromTextDec_maxLen__
//#define __u64FromTextDec_maxLen__ __CText_len__("18446744073709551615")
#define __u64FromTextDec_maxLen__ 20
// app
#define __AppEditor_changeStatusCText__(text) __AppEditor_changeStatus__(text, __CText_len__(text))
// imports
// libC
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <fenv.h>
#include <float.h>
#include <inttypes.h>
#include <iso646.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <string.h>
#include <tgmath.h>
#include <time.h>
#include <uchar.h>
#include <wchar.h>
#include <wctype.h>
#if __target_os__ == __TargetOs_windows__
// posix
#include <fcntl.h>
// Windows
#if __with_network__
#include <ws2tcpip.h> // include before windows.h
//#include <winsock.h>
#include <winsock2.h>
#endif
#include <windef.h>
#include <windows.h>
#include <winuser.h>
#include <commctrl.h>
#include <io.h>
#include <conio.h>
#ifdef __COMPILED_FROM_ZIG_FILE__
#define INVALID_HANDLE_VALUE (HANDLE)0xFFFFFFFF
#endif
#elif __target_os__ == __TargetOs_linux__
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <termios.h>
#include <unistd.h>
#include <time.h>
#if __with_network__
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <sys/socket.h>
#endif
#endif
// strings
// # __Base64StandardAlphabet_chars__
#define __Base64StandardAlphabet_chars__ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
// # __ConsoleAnsiOutputCursorStyle_reset__
#define __ConsoleAnsiOutputCursorStyle_reset__ __ConsoleAnsi_control__ "0 q"
// # __ConsoleAnsiOutputFontStyle_bg_color_black__
#define __ConsoleAnsiOutputFontStyle_bg_color_black__ "40"
// # __ConsoleAnsiOutputFontStyle_bg_color_blue__
#define __ConsoleAnsiOutputFontStyle_bg_color_blue__ "44"
// # __ConsoleAnsiOutputFontStyle_bg_color_cyan__
#define __ConsoleAnsiOutputFontStyle_bg_color_cyan__ "46"
// # __ConsoleAnsiOutputFontStyle_bg_color_gold__
#define __ConsoleAnsiOutputFontStyle_bg_color_gold__ "43"
// # __ConsoleAnsiOutputFontStyle_bg_color_gray__
#define __ConsoleAnsiOutputFontStyle_bg_color_gray__ "100"
// # __ConsoleAnsiOutputFontStyle_bg_color_green__
#define __ConsoleAnsiOutputFontStyle_bg_color_green__ "42"
// # __ConsoleAnsiOutputFontStyle_bg_color_light_blue__
#define __ConsoleAnsiOutputFontStyle_bg_color_light_blue__ "104"
// # __ConsoleAnsiOutputFontStyle_bg_color_light_cyan__
#define __ConsoleAnsiOutputFontStyle_bg_color_light_cyan__ "106"
// # __ConsoleAnsiOutputFontStyle_bg_color_light_gray__
#define __ConsoleAnsiOutputFontStyle_bg_color_light_gray__ "47"
// # __ConsoleAnsiOutputFontStyle_bg_color_light_green__
#define __ConsoleAnsiOutputFontStyle_bg_color_light_green__ "102"
// # __ConsoleAnsiOutputFontStyle_bg_color_light_magenta__
#define __ConsoleAnsiOutputFontStyle_bg_color_light_magenta__ "105"
// # __ConsoleAnsiOutputFontStyle_bg_color_magenta__
#define __ConsoleAnsiOutputFontStyle_bg_color_magenta__ "45"
// # __ConsoleAnsiOutputFontStyle_bg_color_pink__
#define __ConsoleAnsiOutputFontStyle_bg_color_pink__ "101"
// # __ConsoleAnsiOutputFontStyle_bg_color_red__
#define __ConsoleAnsiOutputFontStyle_bg_color_red__ "41"
// # __ConsoleAnsiOutputFontStyle_bg_color_white__
#define __ConsoleAnsiOutputFontStyle_bg_color_white__ "107"
// # __ConsoleAnsiOutputFontStyle_bg_color_yellow__
#define __ConsoleAnsiOutputFontStyle_bg_color_yellow__ "103"
// # __ConsoleAnsiOutputFontStyle_bg_color_zero__
#define __ConsoleAnsiOutputFontStyle_bg_color_zero__ "49"
// # __ConsoleAnsiOutputFontStyle_bold__
#define __ConsoleAnsiOutputFontStyle_bold__ "1"
// # __ConsoleAnsiOutputFontStyle_color_black__
#define __ConsoleAnsiOutputFontStyle_color_black__ "30"
// # __ConsoleAnsiOutputFontStyle_color_blue__
#define __ConsoleAnsiOutputFontStyle_color_blue__ "34"
// # __ConsoleAnsiOutputFontStyle_color_cyan__
#define __ConsoleAnsiOutputFontStyle_color_cyan__ "36"
// # __ConsoleAnsiOutputFontStyle_color_gold__
#define __ConsoleAnsiOutputFontStyle_color_gold__ "33"
// # __ConsoleAnsiOutputFontStyle_color_gray__
#define __ConsoleAnsiOutputFontStyle_color_gray__ "90"
// # __ConsoleAnsiOutputFontStyle_color_green__
#define __ConsoleAnsiOutputFontStyle_color_green__ "32"
// # __ConsoleAnsiOutputFontStyle_color_light_blue__
#define __ConsoleAnsiOutputFontStyle_color_light_blue__ "94"
// # __ConsoleAnsiOutputFontStyle_color_light_cyan__
#define __ConsoleAnsiOutputFontStyle_color_light_cyan__ "96"
// # __ConsoleAnsiOutputFontStyle_color_light_gray__
#define __ConsoleAnsiOutputFontStyle_color_light_gray__ "37"
// # __ConsoleAnsiOutputFontStyle_color_light_green__
#define __ConsoleAnsiOutputFontStyle_color_light_green__ "92"
// # __ConsoleAnsiOutputFontStyle_color_light_magenta__
#define __ConsoleAnsiOutputFontStyle_color_light_magenta__ "95"
// # __ConsoleAnsiOutputFontStyle_color_magenta__
#define __ConsoleAnsiOutputFontStyle_color_magenta__ "35"
// # __ConsoleAnsiOutputFontStyle_color_pink__
#define __ConsoleAnsiOutputFontStyle_color_pink__ "91"
// # __ConsoleAnsiOutputFontStyle_color_red__
#define __ConsoleAnsiOutputFontStyle_color_red__ "31"
// # __ConsoleAnsiOutputFontStyle_color_white__
#define __ConsoleAnsiOutputFontStyle_color_white__ "97"
// # __ConsoleAnsiOutputFontStyle_color_yellow__
#define __ConsoleAnsiOutputFontStyle_color_yellow__ "93"
// # __ConsoleAnsiOutputFontStyle_color_zero__
#define __ConsoleAnsiOutputFontStyle_color_zero__ "39"
// # __ConsoleAnsiOutputFontStyle_command_reset__
#define __ConsoleAnsiOutputFontStyle_command_reset__ \
__ConsoleAnsiOutputFontStyle_start__ \
__ConsoleAnsiOutputFontStyle_reset__ \
__ConsoleAnsiOutputFontStyle_end__
// # __ConsoleAnsiOutputFontStyle_conceal__
#define __ConsoleAnsiOutputFontStyle_conceal__ "8"
// # __ConsoleAnsiOutputFontStyle_dim__
#define __ConsoleAnsiOutputFontStyle_dim__ "2"
// # __ConsoleAnsiOutputFontStyle_end__
#define __ConsoleAnsiOutputFontStyle_end__ "m"
// # __ConsoleAnsiOutputFontStyle_fraktur__
#define __ConsoleAnsiOutputFontStyle_fraktur__ "20"
// # __ConsoleAnsiOutputFontStyle_italic__
#define __ConsoleAnsiOutputFontStyle_italic__ "3"
// # __ConsoleAnsiOutputFontStyle_reset__
#define __ConsoleAnsiOutputFontStyle_reset__ "0"
// # __ConsoleAnsiOutputFontStyle_sep__
#define __ConsoleAnsiOutputFontStyle_sep__ ";"
// # __ConsoleAnsiOutputFontStyle_set_bg_color__
#define __ConsoleAnsiOutputFontStyle_set_bg_color__ "48"
// # __ConsoleAnsiOutputFontStyle_set_color__
#define __ConsoleAnsiOutputFontStyle_set_color__ "38"
// # __ConsoleAnsiOutputFontStyle_start__
#define __ConsoleAnsiOutputFontStyle_start__ __ConsoleAnsi_control__
// # __ConsoleAnsiOutputFontStyle_unbold__
#define __ConsoleAnsiOutputFontStyle_unbold__ "21;24"
// # __ConsoleAnsiOutputFontStyle_underline__
#define __ConsoleAnsiOutputFontStyle_underline__ "4"
// # __ConsoleAnsiOutputSettings_disableLineWrap__
#define __ConsoleAnsiOutputSettings_disableLineWrap__ __ConsoleAnsi_control__ "?7l"
// # __ConsoleAnsiOutputSettings_enableLineWrap__
#define __ConsoleAnsiOutputSettings_enableLineWrap__ __ConsoleAnsi_control__ "?7h"
// # __ConsoleAnsi_control__
#define __ConsoleAnsi_control__ __ConsoleAnsi_esc__ "["
// # __ConsoleAnsi_esc__
#define __ConsoleAnsi_esc__ "\x1B"
// # __ConsoleAnsi_output_clear_line__
#define __ConsoleAnsi_output_clear_line__ __ConsoleAnsi_control__ "2K"
// # __ConsoleAnsi_output_clear_to_end_line__
#define __ConsoleAnsi_output_clear_to_end_line__ __ConsoleAnsi_control__ "0K"
// # __ConsoleAnsi_output_clear_to_start_line__
#define __ConsoleAnsi_output_clear_to_start_line__ __ConsoleAnsi_control__ "1K"
// # __ConsoleAnsi_output_cursor_hide__
#define __ConsoleAnsi_output_cursor_hide__ __ConsoleAnsi_control__ "?25l"
// # __ConsoleAnsi_output_cursor_show__
#define __ConsoleAnsi_output_cursor_show__ __ConsoleAnsi_control__ "?25h"
// # __ConsoleAnsi_output_cursor_style_blinking_I_beam__
#define __ConsoleAnsi_output_cursor_style_blinking_I_beam__ __ConsoleAnsi_control__ "5 q"
// # __ConsoleAnsi_output_cursor_style_blinking_block__
#define __ConsoleAnsi_output_cursor_style_blinking_block__ __ConsoleAnsi_control__ "1 q"
// # __ConsoleAnsi_output_cursor_style_blinking_underline__
#define __ConsoleAnsi_output_cursor_style_blinking_underline__ __ConsoleAnsi_control__ "3 q"
// # __ConsoleAnsi_output_cursor_style_steady_I_beam__
#define __ConsoleAnsi_output_cursor_style_steady_I_beam__ __ConsoleAnsi_control__ "6 q"
// # __ConsoleAnsi_output_cursor_style_steady_block__
#define __ConsoleAnsi_output_cursor_style_steady_block__ __ConsoleAnsi_control__ "2 q"
// # __ConsoleAnsi_output_cursor_style_steady_underline__
#define __ConsoleAnsi_output_cursor_style_steady_underline__ __ConsoleAnsi_control__ "4 q"
// # __OsFilePath_separator__
#if __target_os__ == __TargetOs_windows__
#define __OsFilePath_separator__ "\\"
#elif __target_os__ == __TargetOs_linux__
#define __OsFilePath_separator__ "/"
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
// # ansi_input_mouse_grab
#define ansi_input_mouse_grab __ConsoleAnsi_control__ "?1000h"
// # ansi_input_mouse_release
#define ansi_input_mouse_release __ConsoleAnsi_control__ "?1000l"
// basic types
// C
// # __Float32__
typedef float __Float32__;
// # __Float64__
typedef double __Float64__;
// # __FloatExtraSize__
typedef long double __FloatExtraSize__;
// # __ConsoleAnsiInputKey__
typedef
uint64_t
__ConsoleAnsiInputKey__
;
// # __FSec__
typedef __Float64__ __FSec__;
// # __OsConsoleInputHandle__
#if __target_os__ == __TargetOs_windows__
typedef void* __OsConsoleInputHandle__;
#elif __target_os__ == __TargetOs_linux__
typedef FILE* __OsConsoleInputHandle__;
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
// # __OsConsoleOutputHandle__
#if __target_os__ == __TargetOs_windows__
typedef HANDLE __OsConsoleOutputHandle__;
#elif __target_os__ == __TargetOs_linux__
typedef int __OsConsoleOutputHandle__;
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
// # __OsFileHandle__
#if __target_os__ == __TargetOs_windows__
typedef HANDLE __OsFileHandle__;
#elif __target_os__ == __TargetOs_linux__
typedef int __OsFileHandle__;
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
// # __OsNetworkTcpHandle__
#if __target_os__ == __TargetOs_windows__
typedef SOCKET __OsNetworkTcpHandle__;
#elif __target_os__ == __TargetOs_linux__
typedef int __OsNetworkTcpHandle__;
#else
typedef void* __OsNetworkTcpHandle__;
#warning "__target_os__ not implemented"
#endif
// # __WriteFnPtrVoid__
typedef
void
(*__WriteFnPtrVoid__)
(void* context, const char* bytes, size_t bytes_len)
;
// # __WriteFnPtr__
typedef
size_t
(*__WriteFnPtr__)
(void* context, const char* bytes, size_t bytes_len)
;
// struct prototypes
struct __ConsoleAnsi_input_Key_SequenceParser_fromBytes_parser__;
struct __Console__;
// structs
// universal
// # Slice
struct Slice {
char* ptr;
size_t len;
};
// # __Math2dPosU__
struct __Math2dPosU__ {
size_t x;
size_t y;
};
// # __Writer__
struct __Writer__ {
void* context;
__WriteFnPtr__ write;
};
// # network_tcp_Ip
struct network_tcp_Ip {
uint16_t port;
uint8_t address[4];
};
// Os
// system specifics
#if __target_os__ == __TargetOs_windows__
#elif __target_os__ == __TargetOs_linux__
// # __OsLinux_timespec__
struct __OsLinux_timespec__ {
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
#else
#error "__target_os__ not implemented"
#endif
// # __OsConsoleFlags__
struct __OsConsoleFlags__ {
bool inited;
#if __target_os__ == __TargetOs_windows__
DWORD input_mode;
DWORD output_mode;
#elif __target_os__ == __TargetOs_linux__
struct termios termios;
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
};
// # __OsConsoleInput__
struct __OsConsoleInput__ {
__OsConsoleInputHandle__ handle;
#if __target_os__ == __TargetOs_windows__
#elif __target_os__ == __TargetOs_linux__
int fileno;
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
};
// # __OsConsoleOutput__
struct __OsConsoleOutput__ {
__OsConsoleOutputHandle__ __OsConsoleOutput_handle__;
#if __target_os__ == __TargetOs_windows__
#elif __target_os__ == __TargetOs_linux__
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
};
// # __OsHelper__
struct __OsHelper__ {
#if __target_os__ == __TargetOs_windows__
HINSTANCE instance;
void* console_input_handle;
__OsConsoleOutputHandle__ console_output_handle;
#if __with_network__
bool network_inited;
WSADATA wsdata;
#endif
#elif __target_os__ == __TargetOs_linux__
FILE* console_input_handle;
__OsConsoleOutputHandle__ console_output_handle;
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
};
// lib
// # Finder
struct Finder {
struct Slice text;
struct Slice desired;
size_t pos;
};
// # RoundParam (SHA1)
struct RoundParam {uint32_t a; uint32_t b; uint32_t c; uint32_t d; uint32_t e; uint32_t i;};
// # Sha1_Streaming
struct Sha1_Streaming {
uint32_t state[5];
char block[__Sha1Block_size__];
size_t buf_len; // current? filling level of block
uint64_t total_len;
};
// # __ConsoleAnsiInputKey_SequenceParser__
struct __ConsoleAnsiInputKey_SequenceParser__ {
__ConsoleAnsiInputKey__ sequence;
size_t used;
};
// # __ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo__
struct __ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo__ {
const char* __ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__;
__ConsoleAnsiInputKey__ key;
};
// # __ConsoleAnsi_input_Key_SequenceParser_fromBytes_parser__
struct __ConsoleAnsi_input_Key_SequenceParser_fromBytes_parser__ {
size_t text_len;
size_t len;
const struct __ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo__ *ptr;
};
// # __Console__
struct __Console__ {
struct __OsConsoleInput__ input;
struct __OsConsoleOutput__ output;
};
// # __CryptoRandom__
struct __CryptoRandom__ {
size_t seed;
};
// # __CryptoScalpiHash__
struct __CryptoScalpiHash__ {
uint8_t mask; // value with 4 ones and 4 zeros like: 0b00001111
uint8_t a;
uint8_t b;
};
// # __Logger__
struct __Logger__ {
// write to terminal, console, file or to all together, but no real check "bytes is writen"
struct __Writer__ writers[4]; // __LoggerWriters__
};
// # __Math2dAreaU__
struct __Math2dAreaU__ {
struct __Math2dPosU__ from;
struct __Math2dPosU__ to;
};
// # __MemListLink__
struct __MemListLink__ {
struct __MemListLink__* prev;
struct __MemListLink__* next;
struct __MemList__* list;
};
// # __MemList__
struct __MemList__ {
struct __MemListLink__* first;
struct __MemListLink__* last;
size_t count;
};
// # __MemTree__
struct __MemTree__ {
struct __MemList__ childs;
struct __MemListLink__ link;
size_t count; // recurse. for get non recurse use childs.count
size_t nested;
};
// # __NetworkTcpIpToText__
struct __NetworkTcpIpToText__ {
/// 255.255.255.255:65535
/// 127. 0. 0. 1:27015
/// 0. 0. 0. 1: 0
char buffer[25];
size_t len;
};
// # __NetworkTcpServer__
#if __with_network__
struct __NetworkTcpServer__ {
bool __NetworkTcpServer_ready__;
__OsNetworkTcpHandle__ __NetworkTcpServer_socketHandle__;
size_t __NetworkTcpServer_maxWaitingClients__;
uint16_t port;
};
#endif
// # __NetworkTcpVisitor__
#if __with_network__
struct __NetworkTcpVisitor__ {
__OsNetworkTcpHandle__ socket_handle;
struct network_tcp_Ip ip;
struct sockaddr_in addr;
};
#endif
// # __TerminalInput__
struct __TerminalInput__ {
// usage:
// call __TerminalInput_updateBuffer__ for update unreaded
// use __TerminalInput_grab__ in loop for get keys
size_t ungrabed;
char buffer[__TerminalInput_size__];
};
// # __TerminalOutput__
struct __TerminalOutput__ {
struct __Math2dPosU__ cursor_pos;
const char* font_style;
size_t __TerminalOutput_fontStyleLen__;
struct __Math2dPosU__ size;
bool convert_n_to_rn;
bool apply_r;
bool apply_n;
};
// # __Terminal__
struct __Terminal__ {
struct __Console__ *console;
struct __OsConsoleFlags__ system_flags;
struct __TerminalInput__ input;
struct __TerminalOutput__ output;
};
// # __TextFormatU64__
struct __TextFormatU64__ {
char buffer [__TextCharsDecFromU64_lenMax__];
char *ptr;
size_t len;
};
// # __Text_Splitter__
struct __Text_Splitter__ {
struct Finder finder;
bool stop;
size_t last_pos;
};
// # __TimeClock__
struct __TimeClock__ {
uint64_t ms;
uint64_t sec;
uint64_t min;
uint64_t hour;
};
// # __TimeTotal__
struct __TimeTotal__ {
int64_t ms;
int64_t sec;
int64_t min;
int64_t hour;
int64_t day;
};
// # __Trace__
struct __Trace__ {
struct __Trace__ *__Trace_prevTrace__;
size_t __Trace_line__;
};
// # network_tcp_http_WebSocket_Parser
struct network_tcp_http_WebSocket_Parser {
char* message; // no null
size_t frame_len;
size_t header_len;
size_t message_len;
};
// App
// # __AppEditorHistoryNote__
struct __AppEditorHistoryNote__ {
__ConsoleAnsiInputKey__ key;
struct __MemListLink__ link;
};
// # __AppEditorLine__
struct __AppEditorLine__ {
struct __MemListLink__ link; // used in Views.Flat.lines for iterating
struct __MemTree__ tree; // used in Views.Fold.lines
char text[__AppEditorLineLen_max__]; // todo use ptr to allocated data
size_t text_len;
};
// # __AppEditorViewsFind__
struct __AppEditorViewsFind__ {
struct __Math2dPosU__ offset;
struct __AppEditorLine__ line;
const struct __AppEditorViewsVTable__ *context_vtable;
void *context;
size_t symbol;
bool need_redraw;
};
// # __AppEditorViewsFlat__
struct __AppEditorViewsFlat__ {
struct __AppEditorLine__ *line; // current working line - is setted by outside.
struct __AppEditorLine__ *marked_line; // can be null
struct __MemList__ lines;
struct __MemList__ cutted;
struct __AppEditorLine__ bakup_line;
struct __Math2dPosU__ offset;
size_t symbol;
bool __AppEditorViewsFlat_autoSpace__;
bool need_redraw;
bool need_draw_line_num;
};
// # __AppEditorViewsFolded__
struct __AppEditorViewsFolded__ {
struct __AppEditorLine__ *line;
struct __AppEditorLine__ *marked_line;
struct __MemTree__ lines;
struct __MemTree__ cutted;
struct __AppEditorLine__ bakup_line;
struct __Math2dPosU__ offset;
size_t symbol; // pos of cursor on current line.
bool need_redraw;
bool need_draw_line_num;
};
// # __AppEditorViewsGoToLine__
struct __AppEditorViewsGoToLine__ {
struct __AppEditorLine__ line;
const struct __AppEditorViewsVTable__ *context_vtable;
void *context;
size_t symbol;
struct __Math2dPosU__ offset;
bool need_redraw;
};
// # __AppEditorViewsReplace__
struct __AppEditorViewsReplace__ {
struct __AppEditorLine__ line;
struct __Math2dPosU__ offset;
const struct __AppEditorViewsVTable__ *context_vtable;
void *context;
size_t symbol;
bool need_redraw;
};
// # __AppEditorViewsVTable__
struct __AppEditorViewsVTable__ {
size_t (*getOffsetX) (void *t);
size_t (*getOffsetY) (void *t);
size_t (*getSymbolPosX) (void *t);
size_t (*countLineNum) (void *t);
void (*setAsView) (void *t);
void (*goToPrevLine) (void *t);
void (*goToNextLine) (void *t);
void (*goToSymbolPosX) (void *t, size_t pos);
void (*goToLineFromNumber) (void *t, size_t num);
};
// # __AppEditorViews__
struct __AppEditorViews__ {
struct __AppEditorViewsReplace__ replace;
struct __AppEditorViewsFind__ find;
struct __AppEditorViewsGoToLine__ go_to_line;
struct __AppEditorViewsFlat__ flat;
struct __AppEditorViewsFolded__ folded;
};
// # __AppEditor__
struct __AppEditor__ {
struct __MemList__ history;
struct __AppEditorViews__ views;
const char *__AppEditor_endLine__;
struct __MemListLink__ *stop_record_link;
struct __MemListLink__ *start_record_link;
void (*do_ptr) (void *ctx); // can be null
void (*onKey_ptr) (void *ctx, __ConsoleAnsiInputKey__ key); // can be null
void *current_ctx; // can be null
const struct __AppEditorViewsVTable__ *current_vtable; // can be null
size_t __AppEditor_fileName_len__;
size_t __AppEditor_pathToClipboard_len__;
size_t __AppEditor_endLine_len__;
size_t lines_drawing;
char __AppEditor_fileName__ [__OsFilePathLen_max__];
char __AppEditor_pathToClipboard__ [__OsFilePathLen_max__];
bool working;
bool recording_macro;
bool inited;
};
// # __App__
struct __App__ {
struct __OsHelper__ __App_osHelper__;
struct __Logger__ __App_logger__;
struct __Console__ console;
struct __Terminal__ terminal;
struct __AppEditor__ editor;
int64_t tick; // time ms
bool working;
};
// typedef to fn_ptrs
// function prototypes
// @ __Ap_fromNibble__
uint8_t __Ap_fromNibble__ (char data);
// @ __Buffer_push__
void __Buffer_push__ ( char *buffer, size_t *buffer_used, size_t pos, char item);
// @ __Buffer_setIndent__
bool __Buffer_setIndent__ ( char *buffer, size_t *buffer_used, size_t buffer_max, size_t new_indent);
// @ __ConsoleOutput_cursorHide__
void __ConsoleOutput_cursorHide__ ( struct __OsConsoleOutput__* console_output);
// @ __Console_showCursor__
void __Console_showCursor__ ( struct __Console__ *console);
// @ __CryptoScalpiHash_do__
void __CryptoScalpiHash_do__ ( struct __CryptoScalpiHash__ *t, const char *src, size_t src_size, char *dest, size_t dest_size);
// @ __CryptoScalpiHash_reset__
void __CryptoScalpiHash_reset__ ( struct __CryptoScalpiHash__ *t);
// @ __CryptoScalpiHash_swapTwoBit__
void __CryptoScalpiHash_swapTwoBit__ ( struct __CryptoScalpiHash__ *t);
// @ __Crypto_sumBytes__
uint8_t __Crypto_sumBytes__ ( const char *data, size_t data_len);
// @ __Crypto_xorBytes__
uint8_t __Crypto_xorBytes__ ( const char *data, size_t data_len);
// @ __Crypto_xorCyclic__
void __Crypto_xorCyclic__ ( char *dest, const char *a, size_t dest_len, const char *b, size_t b_len);
// @ __FileComplete_clear__
bool __FileComplete_clear__(
const char* file_name,
size_t file_name_len
);
// @ __FileComplete_write__
bool __FileComplete_write__(
const char* file_name,
size_t file_name_len,
const char* bytes,
size_t bytes_len
);
// @ __HexCapital_fromNibble__
char __HexCapital_fromNibble__ ( char data);
// @ __Hex_fromByte__
void __Hex_fromByte__ ( char *buffer, uint8_t data);
// @ __Hex_fromNibble__
char __Hex_fromNibble__ ( uint8_t data);
// @ __Logger_init__
void __Logger_init__ (struct __Logger__* t);
// @ __Math_ceilDiv32__
uint32_t __Math_ceilDiv32__ ( uint32_t a, uint32_t b);
// @ __MemListLink_init__
void __MemListLink_init__ ( struct __MemListLink__* link);
// @ __MemListLink_resetLinks__
void __MemListLink_resetLinks__ ( struct __MemListLink__* link);
// @ __MemList_init__
void __MemList_init__ ( struct __MemList__* list);
// @ __MemList_pushLast__
void __MemList_pushLast__ ( struct __MemList__ *list, struct __MemListLink__ *item);
// @ __MemTree_fix_counts__
void __MemTree_fix_counts__ ( struct __MemTree__ *t, size_t delta_count, char action);
// @ __MemTree_fix_nested__
void __MemTree_fix_nested__ ( struct __MemTree__ *t, size_t nested_delta, char action);
// @ __MemTree_getParentOrNull__
struct __MemTree__* __MemTree_getParentOrNull__ ( struct __MemTree__ *tree);
// @ __MemTree_getParent__
void __MemTree_getParent__ ( struct __MemTree__ **ret, struct __MemTree__ *tree);
// @ __MemTree_init__
void __MemTree_init__ ( struct __MemTree__ *t);
// @ __MemTree_popFirstChild__
struct __MemTree__* __MemTree_popFirstChild__ ( struct __MemTree__ *tree);
// @ __MemTree_pushNext__
void __MemTree_pushNext__ ( struct __MemTree__ *t, struct __MemTree__ *item);
// @ __MemTree_traverse__
struct __MemTree__* __MemTree_traverse__ ( struct __MemTree__ *tree);
// @ __Mem_copyBackward__
void __Mem_copyBackward__ ( char* dest, const char* src, size_t size);
// @ __Mem_copy__
void __Mem_copy__ ( char *dest, const char *src, size_t size);
// @ __Mem_find__
bool __Mem_find__ ( size_t *ret_pos, const char *data, size_t data_len, const char *desired, size_t desired_len);
// @ __Mem_isEql__
bool __Mem_isEql__ ( const char a[], const char b[], size_t len);
// @ __Nibble_fromAp__
uint8_t __Nibble_fromAp__ (char data);
// @ __Nibble_fromHexNibble__
char __Nibble_fromHexNibble__ ( char nibble);
// @ __OsConsoleInput_init__
void __OsConsoleInput_init__ ( struct __OsConsoleInput__* t, __OsConsoleInputHandle__ input_hanle);
// @ __OsConsoleOutput_init__
void __OsConsoleOutput_init__ ( struct __OsConsoleOutput__* output, __OsConsoleOutputHandle__ handle);
// @ __OsConsoleOutput_write__
bool __OsConsoleOutput_write__ ( struct __OsConsoleOutput__* os_console_output, const char* data, size_t _len);
// @ __OsFallbackConsole_write__
size_t __OsFallbackConsole_write__ ( void* unused_ctx, char* data, size_t len);
// @ __OsFile_clear__
void __OsFile_clear__ ( __OsFileHandle__ file);
// @ __OsFile_close__
void __OsFile_close__ ( __OsFileHandle__ file);
// @ __OsFile_create__
bool __OsFile_create__ ( __OsFileHandle__ *ret, const char file_name[], size_t file_name_len);
// @ __OsFile_exist__
bool __OsFile_exist__ ( const char* file_name, size_t file_name_len);
// @ __OsFile_getSize__
size_t __OsFile_getSize__ ( __OsFileHandle__ file);
// @ __OsFile_open__
bool __OsFile_open__ (__OsFileHandle__ *ret, const char file_name[], size_t file_name_len);
// @ __OsFile_readToBuffer__
bool __OsFile_readToBuffer__ ( __OsFileHandle__ file, char *buffer, size_t buffer_len, size_t offset);
// @ __OsFile_setPos__
void __OsFile_setPos__ ( __OsFileHandle__ file, size_t pos);
// @ __OsFile_truncate__
void __OsFile_truncate__ ( __OsFileHandle__ file);
// @ __OsFile_write__
bool __OsFile_write__ ( __OsFileHandle__ file, const char* data, size_t data_len, size_t offset);
// @ __OsHelper_deinit__
void __OsHelper_deinit__ ( struct __OsHelper__*t);
// @ __OsHelper_init__
bool __OsHelper_init__ ( struct __OsHelper__* t);
// @ __OsHelper_process__
void __OsHelper_process__ ( struct __OsHelper__* t);
// @ __OsMem_alloc__
bool __OsMem_alloc__ ( uintptr_t *ret_data_addr, size_t size);
// @ __OsMem_free__
void __OsMem_free__ ( uintptr_t ret_data_addr);
// @ __Os_getTick__
uint64_t __Os_getTick__ ();
// @ __Os_sleep__
void __Os_sleep__( uint64_t ms);
// @ __TerminalInput_shift__
void __TerminalInput_shift__ ( struct __TerminalInput__ *t, size_t val);
// @ __Terminal_Output_Cursor_shiftDown__
void __Terminal_Output_Cursor_shiftDown__(struct __Terminal__ *terminal, size_t delta);
// @ __Terminal_Output_Cursor_shiftLeft__
void __Terminal_Output_Cursor_shiftLeft__(struct __Terminal__ *terminal, size_t delta);
// @ __Terminal_Output_Cursor_shiftRight__
void __Terminal_Output_Cursor_shiftRight__(struct __Terminal__ *terminal, size_t delta);
// @ __Terminal_Output_Cursor_shiftUp__
void __Terminal_Output_Cursor_shiftUp__(struct __Terminal__ *terminal, size_t delta);
// @ __Terminal_cursorMove__
void __Terminal_cursorMove__ ( struct __Terminal__ *terminal, size_t pos_x, size_t pos_y);
// @ __Terminal_moveCursorToStartOfLine__
void __Terminal_moveCursorToStartOfLine__ ( struct __Terminal__ *terminal);
// @ __Terminal_resetColors__
void __Terminal_resetColors__ ( struct __Terminal__ *terminal);
// @ __Terminal_setFontStyle__
void __Terminal_setFontStyle__ ( struct __Terminal__ *terminal, const char* font_style, size_t font_style_len);
// @ __Terminal_updateOutputSize__
void __Terminal_updateOutputSize__ ( struct __Terminal__ *terminal);
// @ __Terminal_writeToOutput__
void __Terminal_writeToOutput__ ( struct __Terminal__ *terminal, const char *bytes, size_t bytes_len);
// @ __Terminal_writeToOutput__
void __Terminal_writeToOutput__ ( struct __Terminal__ *terminal, const char *bytes, size_t bytes_len);
// @ __TextAsciiSymbol_isBreakWord__
bool __TextAsciiSymbol_isBreakWord__ ( char symbol);
// @ __TextAsciiSymbol_isWord__
bool __TextAsciiSymbol_isWord__ ( char symbol);
// @ __TextAscii_countIndent__
size_t __TextAscii_countIndent__ ( const char *text, size_t text_len, size_t tabsize);
// @ __TextAscii_isVisible__
bool __TextAscii_isVisible__ ( char byte);
// @ __Text_countIndent__
size_t __Text_countIndent__ ( char* text, size_t text_len, size_t tab_size);
// @ __Text_formatU64ToBuffer__
size_t __Text_formatU64ToBuffer__ ( char *buffer, uint64_t number, size_t min_width);
// @ __ZText_countLen__
size_t __ZText_countLen__ ( const char text[]);
// @ print_trace_example
void print_trace_example ( int anyarg, struct __Trace__* prev_trace);
// @ real_main
bool real_main(int args_len, char** args_ptr);
// @ tests
bool tests ();
// globals
// # __AppEditorViewsEasyMotionHorizontalContext_vtable__
const struct __AppEditorViewsVTable__* __AppEditorViewsEasyMotionHorizontalContext_vtable__;
// # __AppEditorViewsEasyMotionHorizontal_context__
void* __AppEditorViewsEasyMotionHorizontal_context__;
// # __AppEditorViewsEasyMotionVertical_context__
void* __AppEditorViewsEasyMotionVertical_context__;
// # __AppEditorViewsEasyMotionVertical_context_vtable__
const struct __AppEditorViewsVTable__* __AppEditorViewsEasyMotionVertical_context_vtable__;
// # __AppEditorViewsVtable_flat__
struct __AppEditorViewsVTable__ __AppEditorViewsVtable_flat__;
// # __AppEditorViewsVtable_folded__
struct __AppEditorViewsVTable__ __AppEditorViewsVtable_folded__;
// # __ConsoleAnsi_input_Key_SequenceParser_sequences_1__
struct __ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo__ __ConsoleAnsi_input_Key_SequenceParser_sequences_1__[] = {
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x16", .key = __ConsoleAnsiInputKey_ctrl_alt_v__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x27", .key = __ConsoleAnsiInputKey_alt_apostrophe__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x2C", .key = __ConsoleAnsiInputKey_alt_comma__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x2E", .key = __ConsoleAnsiInputKey_alt_dot__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x30", .key = __ConsoleAnsiInputKey_alt_0__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x31", .key = __ConsoleAnsiInputKey_alt_1__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x32", .key = __ConsoleAnsiInputKey_alt_2__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x33", .key = __ConsoleAnsiInputKey_alt_3__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x34", .key = __ConsoleAnsiInputKey_alt_4__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x35", .key = __ConsoleAnsiInputKey_alt_5__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x36", .key = __ConsoleAnsiInputKey_alt_6__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x37", .key = __ConsoleAnsiInputKey_alt_7__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x38", .key = __ConsoleAnsiInputKey_alt_8__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x39", .key = __ConsoleAnsiInputKey_alt_9__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x3B", .key = __ConsoleAnsiInputKey_alt_semicolon__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x4D", .key = __ConsoleAnsiInputKey_alt_M__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x61", .key = __ConsoleAnsiInputKey_alt_a__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x62", .key = __ConsoleAnsiInputKey_alt_b__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x63", .key = __ConsoleAnsiInputKey_alt_c__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x64", .key = __ConsoleAnsiInputKey_alt_d__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x65", .key = __ConsoleAnsiInputKey_alt_e__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x66", .key = __ConsoleAnsiInputKey_alt_f__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x67", .key = __ConsoleAnsiInputKey_alt_g__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x68", .key = __ConsoleAnsiInputKey_alt_h__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x69", .key = __ConsoleAnsiInputKey_alt_i__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x6A", .key = __ConsoleAnsiInputKey_alt_j__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x6B", .key = __ConsoleAnsiInputKey_alt_k__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x6C", .key = __ConsoleAnsiInputKey_alt_l__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x6E", .key = __ConsoleAnsiInputKey_alt_n__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x6F", .key = __ConsoleAnsiInputKey_alt_o__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x6D", .key = __ConsoleAnsiInputKey_alt_m__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x70", .key = __ConsoleAnsiInputKey_alt_p__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x71", .key = __ConsoleAnsiInputKey_alt_q__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x72", .key = __ConsoleAnsiInputKey_alt_r__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x73", .key = __ConsoleAnsiInputKey_alt_s__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x74", .key = __ConsoleAnsiInputKey_alt_t__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x75", .key = __ConsoleAnsiInputKey_alt_u__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x76", .key = __ConsoleAnsiInputKey_alt_v__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x77", .key = __ConsoleAnsiInputKey_alt_w__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x78", .key = __ConsoleAnsiInputKey_alt_x__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x79", .key = __ConsoleAnsiInputKey_alt_y__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x7A", .key = __ConsoleAnsiInputKey_alt_z__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B", .key = __ConsoleAnsiInputKey_alt_open_bracket__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5D", .key = __ConsoleAnsiInputKey_alt_close_bracket__ },
};
// # __ConsoleAnsi_input_Key_SequenceParser_sequences_2__
struct __ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo__ __ConsoleAnsi_input_Key_SequenceParser_sequences_2__[] = {
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x4F\x50", .key = __ConsoleAnsiInputKey_f1__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x4F\x51", .key = __ConsoleAnsiInputKey_f2__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x4F\x52", .key = __ConsoleAnsiInputKey_f3__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x4F\x53", .key = __ConsoleAnsiInputKey_f4__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x4F\x64", .key = __ConsoleAnsiInputKey_ctrl_left__ }, // rxvt
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x4F\x63", .key = __ConsoleAnsiInputKey_ctrl_right__ }, // rxvt
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x41", .key = __ConsoleAnsiInputKey_up__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x42", .key = __ConsoleAnsiInputKey_down__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x43", .key = __ConsoleAnsiInputKey_right__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x44", .key = __ConsoleAnsiInputKey_left__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x46", .key = __ConsoleAnsiInputKey_end__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x48", .key = __ConsoleAnsiInputKey_home__ },
};
// # __ConsoleAnsi_input_Key_SequenceParser_sequences_3__
struct __ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo__ __ConsoleAnsi_input_Key_SequenceParser_sequences_3__[] = {
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x5B\x41", .key = __ConsoleAnsiInputKey_f1__ }, // tty
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x5B\x42", .key = __ConsoleAnsiInputKey_f2__ }, // tty
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x5B\x43", .key = __ConsoleAnsiInputKey_f3__ }, // tty
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x5B\x44", .key = __ConsoleAnsiInputKey_f4__ }, // tty
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x33\x7E", .key = __ConsoleAnsiInputKey_delete__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x35\x7E", .key = __ConsoleAnsiInputKey_page_up__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x36\x7E", .key = __ConsoleAnsiInputKey_page_down__ },
};
// # __ConsoleAnsi_input_Key_SequenceParser_sequences_4__
struct __ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo__ __ConsoleAnsi_input_Key_SequenceParser_sequences_4__[] = {
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x31\x7E", .key = __ConsoleAnsiInputKey_f1__ }, // rxvt
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x32\x7E", .key = __ConsoleAnsiInputKey_f2__ }, // rxvt
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x35\x7E", .key = __ConsoleAnsiInputKey_f5__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x37\x7E", .key = __ConsoleAnsiInputKey_f6__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x38\x7E", .key = __ConsoleAnsiInputKey_f7__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x39\x7E", .key = __ConsoleAnsiInputKey_f8__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x32\x30\x7E", .key = __ConsoleAnsiInputKey_f9__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x32\x31\x7E", .key = __ConsoleAnsiInputKey_f10__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x32\x33\x7E", .key = __ConsoleAnsiInputKey_f11__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x32\x34\x7E", .key = __ConsoleAnsiInputKey_f12__ },
};
// # __ConsoleAnsi_input_Key_SequenceParser_sequences_5__
struct __ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo__ __ConsoleAnsi_input_Key_SequenceParser_sequences_5__[] = {
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x3B\x32\x41", .key = __ConsoleAnsiInputKey_shift_up__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x3B\x33\x41", .key = __ConsoleAnsiInputKey_alt_up__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x3B\x35\x41", .key = __ConsoleAnsiInputKey_ctrl_up__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x3B\x32\x42", .key = __ConsoleAnsiInputKey_shift_down__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x3B\x33\x42", .key = __ConsoleAnsiInputKey_alt_down__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x3B\x35\x42", .key = __ConsoleAnsiInputKey_ctrl_down__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x3B\x32\x43", .key = __ConsoleAnsiInputKey_shift_right__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x3B\x33\x43", .key = __ConsoleAnsiInputKey_alt_right__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x3B\x35\x43", .key = __ConsoleAnsiInputKey_ctrl_right__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x3B\x36\x43", .key = __ConsoleAnsiInputKey_ctrl_shift_right__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x3B\x35\x44", .key = __ConsoleAnsiInputKey_ctrl_left__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x3B\x36\x44", .key = __ConsoleAnsiInputKey_ctrl_shift_left__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x3B\x32\x44", .key = __ConsoleAnsiInputKey_shift_left__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x31\x3B\x33\x44", .key = __ConsoleAnsiInputKey_alt_left__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x33\x3B\x32\x7E", .key = __ConsoleAnsiInputKey_shift_delete__ },
};
// # __ConsoleAnsi_input_Key_SequenceParser_sequences_9__
struct __ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo__ __ConsoleAnsi_input_Key_SequenceParser_sequences_9__[] = {
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "\x5B\x32\x37\x3B\x35\x3B\x31\x33\x7E", .key = __ConsoleAnsiInputKey_ctrl_enter__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "[27;5;44~", .key = __ConsoleAnsiInputKey_ctrl_triangular_open_quotation_mark__ },
{ .__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__ = "[27;5;46~", .key = __ConsoleAnsiInputKey_ctrl_triangular_close_quotation_mark__ },
};
// # __ConsoleAnsi_input_Key_SequenceParser_fromBytes_parsers__
struct __ConsoleAnsi_input_Key_SequenceParser_fromBytes_parser__ __ConsoleAnsi_input_Key_SequenceParser_fromBytes_parsers__[] = {
{ .text_len = 9, .len = __arrayLen__(__ConsoleAnsi_input_Key_SequenceParser_sequences_9__), .ptr = &__ConsoleAnsi_input_Key_SequenceParser_sequences_9__[0] },
{ .text_len = 5, .len = __arrayLen__(__ConsoleAnsi_input_Key_SequenceParser_sequences_5__), .ptr = &__ConsoleAnsi_input_Key_SequenceParser_sequences_5__[0] },
{ .text_len = 4, .len = __arrayLen__(__ConsoleAnsi_input_Key_SequenceParser_sequences_4__), .ptr = &__ConsoleAnsi_input_Key_SequenceParser_sequences_4__[0] },
{ .text_len = 3, .len = __arrayLen__(__ConsoleAnsi_input_Key_SequenceParser_sequences_3__), .ptr = &__ConsoleAnsi_input_Key_SequenceParser_sequences_3__[0] },
{ .text_len = 2, .len = __arrayLen__(__ConsoleAnsi_input_Key_SequenceParser_sequences_2__), .ptr = &__ConsoleAnsi_input_Key_SequenceParser_sequences_2__[0] },
{ .text_len = 1, .len = __arrayLen__(__ConsoleAnsi_input_Key_SequenceParser_sequences_1__), .ptr = &__ConsoleAnsi_input_Key_SequenceParser_sequences_1__[0] },
};
// # __ConsoleAnsi_input_Key_SequenceParser_fromBytes__
bool __ConsoleAnsi_input_Key_SequenceParser_fromBytes__(
struct __ConsoleAnsiInputKey_SequenceParser__ *out,
const char *data,
size_t data_len
) {
if (data[0] == '\x1B') {
const char* user_sequence = &data[1];
size_t user_sequence_len = data_len - 1;
if (user_sequence_len >= 5 and __Mem_isEql__(user_sequence, "\x5B\x4D", 2)) { // mouse
out->sequence = __ConsoleAnsiInputKey_mouse__;
out->used = 6;
return true;
}
// reverse iterating about __ConsoleAnsi_input_Key_SequenceParser_fromBytes_parsers__
for (size_t parser_id = 0; parser_id < __arrayLen__(__ConsoleAnsi_input_Key_SequenceParser_fromBytes_parsers__); parser_id++) {
struct __ConsoleAnsi_input_Key_SequenceParser_fromBytes_parser__ *parser = &__ConsoleAnsi_input_Key_SequenceParser_fromBytes_parsers__[parser_id];
size_t check_len = parser->text_len;
if (user_sequence_len >= check_len) {
size_t seq_count = parser->len;
const struct __ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo__ *seq_list = parser->ptr;
for (size_t seq_id = 0; seq_id < seq_count; seq_id++) {
const struct __ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo__* seq = &seq_list[seq_id];
if (__Mem_isEql__(user_sequence, &seq->__ConsoleAnsi_input_Key_SequenceParser_fromBytes_SequenceInfo_text__[0], check_len)) {
out->sequence = seq->key;
out->used = check_len + 1;
return true;
}
}
}
}
}
return false;
}
// # __app__
struct __App__ __app__;
// functions
// # Base64_getEncodeSize
uint32_t Base64_getEncodeSize(uint32_t src_len) {
int blocks = __Math_ceilDiv32__(src_len, 3);
return blocks * 4;
}
// # Slice_debug
void Slice_debug(struct Slice* slice, char* name, size_t line) {
if (slice->len == 0) {
printf("%zu: %s is NULL. \r\n", line, name);
} else {
printf("%zu: %s (%zu): \"%.*s", line, name, slice->len, (int)slice->len, slice->ptr);
}
}
// # __AlignedPtr_alloc__
bool __AlignedPtr_alloc__(
uintptr_t *ret_data_addr,
uint8_t data_align, // expected >= 1
size_t data_size // expected >= 1
) {
bool ok = true;
uint8_t gap_size = 0;
size_t allocated_size = data_size + (data_align - 1) + sizeof(gap_size);
uintptr_t allocated_addr;
if (__OsMem_allocAny__(&allocated_addr, allocated_size)) {
// calc size of gap
uint8_t nodled = allocated_addr % data_align;
if (nodled) {
gap_size = data_align - nodled;
}
// write ret_data_addr
uintptr_t data_addr = allocated_addr + gap_size;
*ret_data_addr = data_addr;
// save gap size
* (uint8_t*) (data_addr + data_size) = gap_size;
if (!ok) __OsMem_freeAny__(allocated_addr);
} else {
ok = false;
}
return ok;
}
// # __AlignedPtr_free__
void __AlignedPtr_free__(
uintptr_t data_addr,
size_t data_size
) {
uint8_t gap_size = * (uint8_t*) (data_addr + data_size);
__OsMem_freeAny__(data_addr - gap_size);
}
// # __Ap_fromByte__
void __Ap_fromByte__(
char *buffer, // expected len >= 2
char byte
) {
buffer[0] = __Ap_fromNibble__((byte & 0xF0) >> 4);
buffer[1] = __Ap_fromNibble__(byte & 0x0F);
}
// # __Ap_fromBytesReversed__
void __Ap_fromBytesReversed__(
char *buffer, // expected len >= data_len << 1
const char *data,
size_t data_len
) {
size_t writed = data_len << 1;
for (size_t readed = 0; readed < data_len; readed++) {
writed -= 2;
__Ap_fromByte__(&buffer[writed], data[readed]);
}
}
// # __Ap_fromBytes__
void __Ap_fromBytes__(
char *buffer, // expected len >= data_len << 1
const char *data,
size_t data_len
) {
size_t writed = 0;
for(size_t pos = 0; pos < data_len; pos++) {
__Ap_fromByte__(&buffer[writed], data[pos]);
writed += 2;
}
}
// # __Ap_fromNibble__
uint8_t __Ap_fromNibble__(
char data
) {
if (data <= 16) {
return 'A' + data;
}
return 0;
}
// # __AppEditorHistoryNote_alloc__
bool __AppEditorHistoryNote_alloc__(
struct __AppEditorHistoryNote__ **ptr
) {
return __AlignedPtr_allocAny__( ptr, __Type_getAlign__(struct __AppEditorHistoryNote__), sizeof(struct __AppEditorHistoryNote__) );
}
// # __AppEditorHistoryNote_free__
void __AppEditorHistoryNote_free__(
struct __AppEditorHistoryNote__* ptr
) {
__AlignedPtr_freeAny__(ptr, sizeof(struct __AppEditorHistoryNote__));
}
// # __AppEditorLine_alloc__
bool __AppEditorLine_alloc__(struct __AppEditorLine__ **ptr) {
return __AlignedPtr_allocAny__(ptr, __Type_getAlign__(struct __AppEditorLine__), __Type_getSize__(struct __AppEditorLine__) );
}
// # __AppEditorLine_free__
void __AppEditorLine_free__(struct __AppEditorLine__ *line) {
__AlignedPtr_freeAny__(line, __Type_getSize__(struct __AppEditorLine__));
}
// # __AppEditorLine_init__
void __AppEditorLine_init__(
struct __AppEditorLine__ *t
) {
__MemListLink_init__(&t->link);
__MemTree_init__(&t->tree);
t->text_len = 0;
}
// # __AppEditorLine_setIndent__
bool __AppEditorLine_setIndent__( // TODO check all uses this fn
struct __AppEditorLine__ *line,
size_t new_indent // expected < __AppEditorLineLen_max__ - line->text_len
) {
return __Buffer_setIndent__(&line->text[0], &line->text_len, __AppEditorLineLen_max__, new_indent);
}
// # __AppEditorLine_setText__
void __AppEditorLine_setText__ (
struct __AppEditorLine__ *line,
char *text_ptr,
size_t text_len // expected < __AppEditorLineLen_max__
) {
line->text_len = text_len;
__Mem_copy__(&line->text[0], text_ptr, text_len);
}
// # __AppEditorListOfLine_writeToFile__
bool
__AppEditorListOfLine_writeToFile__(
struct __MemList__ *lines,
const char* file_name,
size_t file_name_len
) {
bool ok = true;
if (lines->count == 0) {
ok = __FileComplete_clear__(file_name, file_name_len);
} else if (lines->count == 1) {
struct __MemListLink__* link = lines->first;
struct __AppEditorLine__* line = __TypedPtr_getParentPtrFromFieldPtr__(struct __AppEditorLine__, link, link);
if (line->text_len > 0) {
ok = __FileComplete_write__(file_name, file_name_len, &line->text[0], line->text_len);
} else {
ok = __FileComplete_clear__(file_name, file_name_len);
}
} else { // lines > 1
const char* end_line = __app__.editor.__AppEditor_endLine__;
size_t end_line_len = __app__.editor.__AppEditor_endLine_len__;
size_t full_len = 0; // garanty > 0 becouse lines > 1
{ // count fill len
struct __MemListLink__* link = lines->first;
struct __AppEditorLine__* line = __TypedPtr_getParentPtrFromFieldPtr__(struct __AppEditorLine__, link, link);
full_len += line->text_len;
link = link->next;
while (link) {
struct __AppEditorLine__* line = __TypedPtr_getParentPtrFromFieldPtr__(struct __AppEditorLine__, link, link);
full_len += end_line_len + line->text_len;
link = link->next;
}
}
char* buffer;
if (__AlignedPtr_allocAny__(&buffer, 4, full_len)) { // use aligned just for speed
// save to buffer
size_t writed = 0;
{ // convert lines to one buffer
struct __MemListLink__* link = lines->first; // garanty not null by lines > 1
// write first line
struct __AppEditorLine__* first_line = __TypedPtr_getParentPtrFromFieldPtr__(struct __AppEditorLine__, link, link);
if (first_line->text_len > 0) {
__Mem_copy__(&buffer[writed], &first_line->text[0], first_line->text_len);
writed += first_line->text_len;
}
link = link->next;
// write other lines
while (link) {
__Mem_copy__(&buffer[writed], end_line, end_line_len);
writed += end_line_len;
struct __AppEditorLine__* line = __TypedPtr_getParentPtrFromFieldPtr__(struct __AppEditorLine__, link, link);
if (line->text_len > 0) {
__Mem_copy__(&buffer[writed], &line->text[0], line->text_len);
writed += line->text_len;
}
link = link->next;
}
}
// write to file
if (__FileComplete_write__(file_name, file_name_len, buffer, writed)) {
} else { // file not rewrited
ok = false;
}
__AlignedPtr_freeAny__(buffer, full_len);
} else { // memory not allocated
ok = false;
}
}
return ok;
}
// # __AppEditorViewsEasyMotionHorizontal_draw__
void __AppEditorViewsEasyMotionHorizontal_draw__() {
struct __Terminal__* terminal = &__app__.terminal;
__Terminal_setFontStyle__(&__app__.terminal, __AppEditorTheme_easy_motion__, __CText_len__(__AppEditorTheme_easy_motion__));
size_t voy = __AppEditorViewsEasyMotionHorizontalContext_vtable__->getOffsetY(__AppEditorViewsEasyMotionHorizontal_context__);
size_t pos = 0;
char rune = 'a';
while (true) {
if (pos >= terminal->output.size.x - 1 - __AppEditorViewsEasyMotionHorizontal_step__) break;
__Terminal_cursorMove__(terminal, pos, voy);
__Terminal_writeToOutput__(terminal, &rune, 1);
if (rune == '9') {
break;
} else if (rune == 'z') {
rune = '0';
} else {
rune += 1;
}
pos += __AppEditorViewsEasyMotionHorizontal_step__;
}
}
// # __AppEditorViewsEasyMotionHorizontal_moveTo__
void __AppEditorViewsEasyMotionHorizontal_moveTo__(
size_t pos
) {
size_t spx = __AppEditorViewsEasyMotionHorizontalContext_vtable__->getSymbolPosX(__AppEditorViewsEasyMotionHorizontal_context__);
size_t vox = __AppEditorViewsEasyMotionHorizontalContext_vtable__->getOffsetX(__AppEditorViewsEasyMotionHorizontal_context__);
__AppEditorViewsEasyMotionHorizontalContext_vtable__->goToSymbolPosX(__AppEditorViewsEasyMotionHorizontal_context__, spx - vox + pos);
__AppEditorViewsEasyMotionHorizontalContext_vtable__->setAsView(__AppEditorViewsEasyMotionHorizontal_context__);
}
// # __AppEditor_addKeyToHistory__
bool __AppEditor_addKeyToHistory__(
struct __AppEditor__ *editor,
__ConsoleAnsiInputKey__ key
) {
bool ok = true;
struct __AppEditorHistoryNote__ *hn;
if ( __AppEditorHistoryNote_alloc__(&hn)) {
hn->key = key;
struct __MemListLink__ *link = &hn->link;
__MemListLink_init__(link);
__MemList_pushLast__(&editor->history, link);
if (!ok) __AppEditorHistoryNote_free__(hn);
} else {
ok = false;
}
return ok;
}
// # __AppEditor_changeStatus__
void __AppEditor_changeStatus__(
const char *text,
size_t text_len
) {
__ConsoleOutput_cursorHide__(&__app__.console.output);
__Terminal_cursorMove__(&__app__.terminal, 0, __app__.terminal.output.size.y - 1);
__Terminal_setFontStyleCText__(&__app__.terminal, __AppEditorTheme_notification__);
__Terminal_writeToOutput__(&__app__.terminal, text, text_len);
__OsConsoleOutput_write__(&__app__.console.output, __ConsoleAnsi_output_clear_to_end_line__, 0);
__Terminal_resetColors__(&__app__.terminal);
__Console_showCursor__(&__app__.console);
}
// # __AppEditor_playMacro__
/* // use me after port fn __AppEditor_onKey__
bool __AppEditor_playMacro__(struct __AppEditor__ *t) {
bool ok = true;
if (t->recording_macro != true) {
struct __MemListLink__ *start = t->start_record_link;
struct __MemListLink__ *end = t->stop_record_link;
if ( start and end ) {
struct __MemListLink__ *next_link = start->next; // skipped start recording itself
while ( next_link and (next_link != stop)) {
struct __AppEditorHistoryNote__ *history_note = __TypedPtr_getParentPtrFromFieldPtr__(struct __AppEditorHistoryNote__, link, next_link));
struct __ConsoleAnsiInputKey__ key = history_note->key;
__AppEditor_onKey__(t, key);
next_link = next_link->next;
}
} else {
ok = false;
__AppEditor_changeStatusCText__("macro not recorded.");
}
} else {
ok = false;
__AppEditor_changeStatusCText__("not aviable while recording");
}
return ok;
}
*/
// # __AppEditor_startRecordMacro__
bool __AppEditor_startRecordMacro__(
struct __AppEditor__ *t
) {
bool ok = true;
if (t->recording_macro != true) {
if (__AppEditor_addKeyToHistory__(t, 0)) {
t->recording_macro = true;
t->start_record_link = t->history.last;
t->stop_record_link = NULL;
__AppEditor_changeStatusCText__("start recording macro.");
} else {
ok = false;
__AppEditor_changeStatusCText__("Unexpected error"); // todo add line
}
} else {
ok = false;
__AppEditor_changeStatusCText__("macro is recording right now"); // todo add line
}
return ok;
}
// # __AppEditor_stopRecordMacro__
bool __AppEditor_stopRecordMacro__(struct __AppEditor__ *t) {
bool ok = true;
if (t->recording_macro == true) {
if (__AppEditor_addKeyToHistory__(t, 0)) {
t->stop_record_link = t->history.last;
t->recording_macro = false;
__AppEditor_changeStatusCText__("stop recording macro.");
} else {
ok = false;
}
} else {
ok = false;
__AppEditor_changeStatusCText__("macro not recording right now.");
}
return ok;
}
// # __AppEditor_stop__
void __AppEditor_stop__(struct __AppEditor__ *t) {
__Terminal_cursorMove__(&__app__.terminal, 0, t->lines_drawing);
__OsConsoleOutput_write__(&__app__.console.output, "\n", 0);
printf("file: {%.*s}", t->__AppEditor_fileName_len__ , &t->__AppEditor_fileName__[0]);
{ // draw_line_num
void *ctx = t->current_ctx; if (ctx) {
const struct __AppEditorViewsVTable__ *vt = t->current_vtable; if (vt) {
size_t (*cln) (void *t) = vt->countLineNum; if (cln) {
size_t current_line = cln(ctx);
printf(" {%d}", current_line);
}
}
}
}
__OsConsoleOutput_write__(&__app__.console.output, "\r\n", 0);
t->working = false;
}
// # __App_deinit__
void __App_deinit__(struct __App__* app) {
__OsHelper_deinit__(&app->__App_osHelper__);
}
// # __App_init__
bool __App_init__(struct __App__* t) {
bool ok = true;
__Logger_init__(&t->__App_logger__); // preinit console output for debug
if (__OsHelper_init__(&t->__App_osHelper__)) {
t->tick = __Os_getTick__();
if (!ok) __OsHelper_deinit__(&t->__App_osHelper__);
} else {
ok = false;
printf("%d app.__App_osHelper__ not inited\r\n", __LINE__);
}
return ok;
}
// # __App_process__
bool __App_process__(struct __App__* t) {
bool ok = true;
__OsHelper_process__(&t->__App_osHelper__);
return ok;
}
// # __App_waitToNextFrame__
void __App_waitToNextFrame__(struct __App__* t) {
uint64_t expected_frame_end_time = t->tick + __Time_msPerS__ / __App_expectedFps__;
uint64_t resulting_frame_end_time = __Os_getTick__();
if (resulting_frame_end_time > expected_frame_end_time + 120) {
uint64_t delta = resulting_frame_end_time - expected_frame_end_time;
printf("%d \t hitch detection: %zu delta: %zu ms \r\n", __LINE__, t->tick, delta);
}
uint64_t delay_sleep = 1;
if (resulting_frame_end_time < expected_frame_end_time) {
delay_sleep = expected_frame_end_time - resulting_frame_end_time;
}
__Os_sleep__(delay_sleep);
t->tick = resulting_frame_end_time + delay_sleep;
}
// # __Ascii_getFirstVisibleCharOrEnd__
size_t __Ascii_getFirstVisibleCharOrEnd__(
const char *ptr,
size_t len // expected > 0
) {
size_t pos = 0;
for (;pos < len; pos++) {
char byte = ptr[pos];
if (__TextAscii_isVisible__(byte)) break;
}
return pos;
}
// # __Ascii_isEmpty__
bool __Ascii_isEmpty__(
const char *ptr,
size_t len // expected > 0
) {
return __Ascii_getFirstVisibleCharOrEnd__(ptr, len) < len;
}
// # __Base64_encode3Bytes__
void __Base64_encode3Bytes__(unsigned char in[3], char out[4]) {
out[0] = __Base64StandardAlphabet_chars__[(in[0] & 0b11111100) >> 2];
out[1] = __Base64StandardAlphabet_chars__[((in[0] & 0b00000011) << 4) | ((in[1] & 0b11110000) >> 4)];
out[2] = __Base64StandardAlphabet_chars__[((in[1] & 0b00001111) << 2) | ((in[2] & 0b11000000) >> 6)];
out[3] = __Base64StandardAlphabet_chars__[(in[2] & 0b00111111)];
}
// # __Base64_encode__
void __Base64_encode__(char* src, size_t src_len, char* out) {
// EXAMPLE
// Source ASCII text: "Ma"
// Character M a
// Octets 77 (0x4d) 97 (0x61)
// Bits 0 1 0 0 1 1 0 1|0 1 1 0 0 0 0 1|0 0 _ _ _ _ _ _|
// Base64 0 1 0 0 1 1|0 1 0 1 1 0|0 0 0 1 0 0|_ _ _ _ _ _|
// Sextets 19 22 4 Padding
// Character T W E =
// Octets 84 (0x54) 87 (0x57) 69 (0x45) 61 (0x3D)
// parse normal octets
char* end_of_src = src + src_len;
while(true) {
if (src + 3 > end_of_src) break;
__Base64_encode3Bytes__((void*) src, out);
src += 3;
out += 4;
}
// parse extra_bytes
size_t extra_bytes = end_of_src - src;
if (extra_bytes > 0 ) {
char b[3] = {0};
__Mem_copy__(b, src, extra_bytes);
__Base64_encode3Bytes__((void*)b, out);
out += 4;
// add padding
size_t pads = 3 - extra_bytes;
for (char* pad = out - pads ;pad < out; pad++) {*pad = '=';}
}
}
// # __BitsU32_disable__
uint32_t __BitsU32_disable__(uint32_t value, uint32_t mask) {
return value & (~mask);
}
// # __BitsU32_enable__
uint32_t __BitsU32_enable__(uint32_t value, uint32_t mask) {
return value | mask;
}
// # __BitsU32_toggle__
uint32_t __BitsU32_toggle__(uint32_t value, uint32_t mask, bool new_state) {
if (new_state) {
return __BitsU32_enable__(value, mask);
} else {
return __BitsU32_disable__(value, mask);
}
}
// # __Buffer_addIndent__
void __Buffer_addIndent__(
char *buffer,
size_t *buffer_used,
size_t count // expected < (buffer_max - *buffer_used)
) {
size_t pos = 0;
while (pos < count) {
__Buffer_push__(buffer, buffer_used, 0, ' ');
pos = pos + 1;
}
}
// # __Buffer_addIndent_check__
bool
__Buffer_addIndent_check__(
char *buffer,
size_t *buffer_used,
size_t buffer_max,
size_t count
) {
size_t space = buffer_max - *buffer_used;
return space > count;
}
// # __Buffer_pop__
char __Buffer_pop__(
char *buffer,
size_t *buffer_used, // expected (*) > 0
size_t pos // expected <= buffer_used
) {
char ret = buffer[pos];
(*buffer_used)--;
if (pos < *buffer_used) {
__Mem_copy__(&buffer[pos], &buffer[pos + 1], *buffer_used - pos);
}
return ret;
}
// # __Buffer_pop_check__
bool __Buffer_pop_check__(
size_t buffer_used,
size_t pos
) {
return ((buffer_used > 0) and (pos < buffer_used));
}
// # __Buffer_push__
void __Buffer_push__(
char *buffer,
size_t *buffer_used, // expected < allocated
size_t pos, // expected < allocated
char item
) {
if (pos < *buffer_used) { // shiftSymbolsToRight
__Mem_copyBackward__(&buffer[pos + 1], &buffer[pos], *buffer_used - pos);
}
buffer[pos] = item;
(*buffer_used)++;
}
// # __Buffer_removeIndent__
void
__Buffer_removeIndent__(
char *buffer,
size_t *buffer_used, // expected >= count
size_t count // expected <= buffer_used
) {
size_t pos = 0;
while (pos < count) {
__Buffer_pop__(
buffer,
buffer_used, // (*) > 0 becouse expected *buffer_used >= loop_count
0
);
pos += 1;
}
}
// # __Buffer_setIndent__
bool
__Buffer_setIndent__(
char *buffer,
size_t *buffer_used,
size_t buffer_max,
size_t new_indent // expected < buffer_max
) {
bool ok = true;
size_t indent = __Text_countIndent__(buffer, *buffer_used, 1);
if (new_indent != indent) {
if (new_indent > indent) {
size_t delta = new_indent - indent;
if (__Buffer_addIndent_check__(buffer, buffer_used, buffer_max, delta)) {
__Buffer_addIndent__(buffer, buffer_used, delta);
} else {
ok = false;
}
} else { // new_indent < indent
size_t delta = indent - new_indent;
__Buffer_removeIndent__(buffer, buffer_used, delta);
}
}
return ok;
}
// # __Byte_fromAp__
uint8_t __Byte_fromAp__(
const char* data // expected len >= 2
) {
char fo = __Nibble_fromAp__(data[0]);
char of = __Nibble_fromAp__(data[1]);
return (fo << 4) | of;
}
// # __Byte_fromHex__
char __Byte_fromHex__(char* hex_byte) {
char b_F0 = __Nibble_fromHexNibble__(hex_byte[0]);
char b_0F = __Nibble_fromHexNibble__(hex_byte[1]);
return (b_F0 << 4) | b_0F;
}
// # __Bytes_fromApReversed__
void __Bytes_fromApReversed__(
char *buffer, // expected len >= ap_len >> 1
const char *ap,
size_t ap_len // expected >= 2, expected odd
) {
size_t ap_pos = ap_len;
size_t writed = 0;
while (ap_pos > 0) {
ap_pos -= 2; // garanty ap_pos < ap_len
buffer[writed] = __Byte_fromAp__(&ap[ap_pos]);
writed += 1;
}
}
// # __Bytes_fromAp__
void __Bytes_fromAp__(
char *buffer, // expected len >= ap_len >> 1
const char *ap,
size_t ap_len
) {
size_t readed = 0;
size_t writed = 0;
while(readed < ap_len) {
buffer[writed] = __Byte_fromAp__(&ap[readed]);
writed += 1;
readed += 2;
}
}
// # __Bytes_fromHex__ // REPLACED ARG ORDER!
void __Bytes_fromHex__(
char* buffer_ptr, // expected len >= hex_len >> 2
char* hex,
size_t hex_len
) {
size_t end_pos = hex_len >> 1;
for(size_t pos = 0; pos < end_pos; pos++) {
buffer_ptr[pos] = __Byte_fromHex__(&hex[pos*2]);
}
}
// # __ConsoleOutput_cursorHide__
void __ConsoleOutput_cursorHide__(struct __OsConsoleOutput__* console_output) {
__OsConsoleOutput_write__(console_output, __ConsoleAnsi_output_cursor_hide__, 0);
}
// # __Console_clearLine__
void __Console_clearLine__(struct __Console__ *console) {
__OsConsoleOutput_writeCText__(&console->output, __ConsoleAnsi_output_clear_line__);
}
// # __Console_init__
void __Console_init__(
struct __Console__ *t,
__OsConsoleInputHandle__ input_handle,
__OsConsoleOutputHandle__ output_handle
) {
__OsConsoleInput_init__(&t->input, input_handle);
__OsConsoleOutput_init__(&t->output, output_handle);
}
// # __Console_showCursor__
void __Console_showCursor__(struct __Console__ *console) {
__OsConsoleOutput_writeCText__(&console->output, __ConsoleAnsi_output_cursor_show__);
}
// # __CryptoRandom_do__
void __CryptoRandom_do__(
struct __CryptoRandom__ *t,
char *out_buffer,
size_t buffer_len
) {
struct __CryptoScalpiHash__ hasher;
__CryptoScalpiHash_reset__(&hasher);
__CryptoScalpiHash_doAny__(&hasher, &t->seed, sizeof(t->seed), out_buffer, buffer_len);
t->seed += 1;
}
// # __CryptoScalpiHash_doBit__
void __CryptoScalpiHash_doBit__(
struct __CryptoScalpiHash__* t,
uint8_t bit,
char *dest, // canbe not zeroed
size_t dest_len
) {
uint8_t bb = 2 - bit;
for (int i = 0; i < dest_len; i++) {
uint8_t *output_byte = (uint8_t*) &dest[i];
t->a += *output_byte;
t->b += bb;
__CryptoScalpiHash_swapTwoBit__(t);
*output_byte += t->mask;
}
}
// # __CryptoScalpiHash_doByte__
void __CryptoScalpiHash_doByte__(
struct __CryptoScalpiHash__ *t,
uint8_t byte,
char *dest,
size_t size
) {
uint8_t pos = 0;
while (true) {
uint8_t bit = (byte >> pos) & 1;
__CryptoScalpiHash_doBit__(t, bit, dest, size);
if (pos == 7) break;
pos += 1;
}
}
// # __CryptoScalpiHash_do__
void __CryptoScalpiHash_do__(
struct __CryptoScalpiHash__ *t,
const char *src,
size_t src_size,
char *dest,
size_t dest_size
) {
for (int i = 0; i < src_size; i++) {
__CryptoScalpiHash_doByte__(t, src[i], dest, dest_size);
}
}
// # __CryptoScalpiHash_reset__
void __CryptoScalpiHash_reset__(
struct __CryptoScalpiHash__ *t
) {
t->mask = 0b00001111;
t->a = 0;
t->b = 0;
}
// # __CryptoScalpiHash_swapTwoBit__
void __CryptoScalpiHash_swapTwoBit__(struct __CryptoScalpiHash__ *t) {
// truncate a and b to 3 bit.
uint8_t a = t->a & 0b111;
uint8_t b = t->b & 0b111;
// save bits with swap
uint8_t tmp_a = (t->mask & 1 << a) >> a << b;
uint8_t tmp_b = (t->mask & 1 << b) >> b << a;
uint8_t tmp = tmp_a | tmp_b;
// clear bits
t->mask &= 255 - (1 << a);
t->mask &= 255 - (1 << b);
// set last bits
t->mask |= tmp;
}
// # __Crypto_sumBytes__
uint8_t __Crypto_sumBytes__(
const char *data,
size_t data_len
) {
char ret = 0;
for (size_t pos = 0; pos < data_len; pos++) {
ret += data[pos];
}
return ret;
}
// # __Crypto_xorBytes__
uint8_t __Crypto_xorBytes__(
const char *data,
size_t data_len
) {
char ret = 0;
for (size_t pos = 0; pos < data_len; pos++) {
ret ^= data[pos];
}
return ret;
}
// # __Crypto_xorCyclic__
void __Crypto_xorCyclic__(
char *dest,
const char *a,
size_t dest_len,
const char *b,
size_t b_len
) {
// expected dest_len == a.len
size_t ci = 0; // cyclical iterator
for (size_t pos = 0; pos < dest_len; pos++) {
dest[pos] = a[pos] ^ b[ci];
ci += 1;
if (ci == b_len) ci = 0;
}
}
// # __FileComplete_clear__
bool __FileComplete_clear__(
const char* file_name,
size_t file_name_len
) {
bool ok = true;
__OsFileHandle__ file;
if (__OsFile_open__(&file, file_name, file_name_len)) {
__OsFile_clear__(file);
__OsFile_close__(file);
} else {
ok = false;
}
return ok;
}
// # __FileComplete_read__
bool __FileComplete_read__(
uintptr_t *ret_data_ptr,
size_t *ret_file_data_size, // not zeroed by this func. increment instead.
const char* file_name,
size_t file_name_len,
uint8_t align
) {
bool ok = true;
__OsFileHandle__ file;
if(__OsFile_exist__(file_name, file_name_len)) {
ok = __OsFile_open__(&file, file_name, file_name_len);
} else {
ok = __OsFile_create__(&file, file_name, file_name_len);
}
if (ok) {
size_t file_size = __OsFile_getSize__(file);
*ret_file_data_size += file_size;
char* file_data;
if (__AlignedPtr_allocAny__(ret_data_ptr, align, file_size)) {
if ( __OsFile_readToAny__( file, ret_data_ptr, file_size, 0 )) {
} else {
ok = false;
}
} else {
ok = false;
}
__OsFile_close__(file);
}
return ok;
}
// # __FileComplete_write__
bool __FileComplete_write__(
const char* file_name,
size_t file_name_len,
const char* bytes,
size_t bytes_len
) {
bool ok = true;
__OsFileHandle__ file;
if(__OsFile_exist__(file_name, file_name_len)) {
ok = __OsFile_open__(&file, file_name, file_name_len);
} else {
ok = __OsFile_create__(&file, file_name, file_name_len);
}
if (ok) {
if (__OsFile_write__(file, bytes, bytes_len, 0)) {
__OsFile_truncate__(file);
} else {
ok = false;
}
__OsFile_close__(file);
}
return ok;
}
// # __File_clear__
void __File_clear__(
__OsFileHandle__ file
) {
__OsFile_setPos__(file, 0);
__OsFile_truncate__(file);
}
// # __Finder_init__
void __Finder_init__(
struct Finder* t,
char* text,
size_t text_len,
char* desired,
size_t desired_len
) {
t->pos = 0;
t->text.ptr = text;
t->text.len = text_len;
t->desired.ptr = desired;
t->desired.len = desired_len;
}
// # __Finder_next__
bool __Finder_next__(
struct Finder* t,
size_t* out_pos
) {
if (t->pos != t->text.len) {
char *data = &t->text.ptr[t->pos];
size_t data_len = t->text.len - t->pos;
size_t finded = 0;
if ( true
and t->desired.len > 0
and data_len >= t->desired.len
and __Mem_find__(
&finded,
data,
data_len,
t->desired.ptr,
t->desired.len
)
) {
size_t new_pos = t->pos + finded;
t->pos = new_pos + t->desired.len;
*out_pos = new_pos;
return true;
}
}
return false;
}
// # __FormatsHex_packBytesReverse__
void __FormatsHex_packBytesReverse__(
char *hex, // expected len >= __Hex_lenFromBytesLen__(data_len)
char *data,
size_t data_len // expected >= 1
) {
size_t hex_pos = data_len << 1;
for (size_t data_pos = 0; data_pos < data_len; data_pos++) {
hex_pos -= 2;
__Hex_fromByte__(&hex[hex_pos], data[data_pos]);
}
}
// # __HexCapital_fromByte__
void Hex_packByte_H(char data, char* hex_byte) {
hex_byte[0] = __HexCapital_fromNibble__((data & 0xF0) >> 4);
hex_byte[1] = __HexCapital_fromNibble__(data & 0x0F);
}
// # __HexCapital_fromBytes__
void Hex_pack_H(char* hex, char* data, size_t data_len) {
// expected hex.len is __Hex_lenFromBytesLen__(len)
for(size_t pos = 0; pos < data_len; pos++) {
Hex_packByte_H(data[pos], &hex[pos * 2]);
}
}
// # __HexCapital_fromNibble__
char __HexCapital_fromNibble__(char data) {
if (data <= 9) return '0' + data;
if (data <= 15) return 'A' + data - 10;
return 0;
}
// # __Hex_fromByte__
void __Hex_fromByte__(
char *buffer,
uint8_t data
) {
buffer[0] = __Hex_fromNibble__((data & 0xF0) >> 4);
buffer[1] = __Hex_fromNibble__(data & 0x0F);
}
// # __Hex_fromBytes__
void __Hex_fromBytes__(
char *hex, // expected len >= __Hex_lenFromBytesLen__(data_len)
char *data,
size_t data_len
) {
for(size_t pos = 0; pos < data_len; pos++) {
__Hex_fromByte__(&hex[pos << 1], data[pos]);
}
}
// # __Hex_fromNibble__
char __Hex_fromNibble__(uint8_t data) {
if (data <= 9) return (uint8_t)'0' + data;
if (data <= 15) return (uint8_t)'a' + data - 10;
return 0;
}
// # __Logger_init__
void __Logger_init__ (struct __Logger__* t) {
for (int i = 0; i < __arrayLen__(t->writers); i++) {
struct __Writer__* w = &t->writers[i];
w->context = 0;
w->write = 0;
}
}
// # __Logger_writeToSelf__
void __Logger_writeToSelf__(struct __Logger__* t, const char bytes[], size_t len) {
for (size_t i = 0; i < __arrayLen__(t->writers); i++) {
struct __Writer__* w = &t->writers[i];
if (w->write) {
size_t writed = w->write(w->context, bytes, len);
}
}
}
// # __Math_ceilDiv32__
uint32_t __Math_ceilDiv32__(uint32_t a, uint32_t b) {
return (a + b - 1) / b;
}
// # __Math_linearInterpolationWithCoef__
__Float32__ __Math_linearInterpolationWithCoef__(
__Float32__ r1,
__Float32__ r2,
__Float32__ coef
) {
return r1 + coef * (r2 - r1);
}
// # __Math_linearInterpolation__
__Float32__ __Math_linearInterpolation__(
__Float32__ v1,
__Float32__ v2,
__Float32__ r1,
__Float32__ r2,
__Float32__ vx
) {
return r1 + (vx - v1) / (v2 - v1) * (r2 - r1);
}
// # __MemListLink_init__
void __MemListLink_init__(
struct __MemListLink__* link
) {
__MemListLink_resetLinks__(link);
}
// # __MemListLink_isFirst__
bool
__MemListLink_isFirst__(
struct __MemListLink__* link
) {
struct __MemListLink__* prev = link->prev;
bool prev_is_null = (link->prev) == NULL;
return prev_is_null;
}
// # __MemListLink_resetLinks__
void __MemListLink_resetLinks__(struct __MemListLink__* link) {
link->prev = NULL;
link->next = NULL;
link->list = NULL;
}
// # __MemList_init__
void __MemList_init__(
struct __MemList__* list
) {
list->first = NULL;
list->last = NULL;
list->count = 0;
}
// # __MemList_pop__
void __MemList_pop__(
struct __MemList__ *list,
struct __MemListLink__ *item // expected item linked to list
) {
if (list->count == 1) {
list->first = NULL;
list->last = NULL;
__MemListLink_resetLinks__(item);
} else { // count > 1 becouse != 1 and item is linked to list
if (item == list->first) {
struct __MemListLink__ *next = item->next; // not null becouse item is first and count > 1
list->first = next;
next->prev = NULL;
if (list->count == 2) {
list->last = next;
}
} else if (item == list->last) {
struct __MemListLink__ *prev = item->prev; // cannot be null becouse item is last and count > 1
list->last = prev;
prev->next = NULL;
if (list->count == 2) {
list->first = prev;
}
} else { // non first or last
// flatten prev and next
struct __MemListLink__ *next = item->next; // item is not last
struct __MemListLink__ *prev = item->prev; // item is not first
next->prev = prev;
prev->next = next;
}
__MemListLink_resetLinks__(item);
}
list->count -= 1;
}
// # __MemList_pushAfter__
void __MemList_pushAfter__(
struct __MemList__* list,
struct __MemListLink__* after,
struct __MemListLink__* item
) {
struct __MemListLink__* next = after->next;
if (next) {
next->prev = item;
} else { // after is last
list->last = item;
}
item->next = next;
after->next = item;
item->prev = after;
item->list = list;
list->count += 1;
}
// # __MemList_pushBefore__
void __MemList_pushBefore__(
struct __MemList__* list,
struct __MemListLink__* before,
struct __MemListLink__* item
) {
struct __MemListLink__* prev = before->prev;
if (prev) { // non firts
prev->next = item;
} else { // is first
list->first = item;
}
item->prev = prev;
before->prev = item;
item->next = before;
item->list = list;
list->count += 1;
}
// # __MemList_pushFirst__
void __MemList_pushFirst__(
struct __MemList__ *list,
struct __MemListLink__ *item // expected freed item
) {
struct __MemListLink__* first = list->first;
if (first) { // list not empty
first->prev = item;
item->next = first;
} else { // list is empty
list->last = item;
}
list->first = item;
item->list = list;
list->count += 1;
}
// # __MemList_pushLast__
void __MemList_pushLast__(
struct __MemList__ *list,
struct __MemListLink__ *item
) {
struct __MemListLink__* last = list->last;
if (last) {
last->next = item;
item->prev = last;
} else { // list empty
list->first = item;
}
list->last = item;
item->list = list;
list->count += 1;
}
// # __MemTree_fix_counts__
void __MemTree_fix_counts__(
struct __MemTree__ *t,
size_t delta_count,
char action // __MemTree_fix_counts_Action__
) {
struct __MemTree__ *tree = t;
if (action == __MemTree_fix_counts_Action_plus__) {
while (tree) {
tree->count += delta_count;
tree = __MemTree_getParentOrNull__(tree);
}
} else { // minus
while (tree) {
tree->count -= delta_count;
tree = __MemTree_getParentOrNull__(tree);
}
}
}
// # __MemTree_getParentOrNull__
struct __MemTree__* // can be null
__MemTree_getParentOrNull__ (
struct __MemTree__ *tree
) {
struct __MemList__ *list = tree->link.list;
if (list) {
struct __MemTree__ *parent = __TypedPtr_getParentPtrFromFieldPtr__(struct __MemTree__, childs, list);
return parent;
}
return NULL;
};
// # __MemTree_getParent__
void __MemTree_getParent__ (
struct __MemTree__ **ret,
struct __MemTree__ *tree // expected child
) {
struct __MemList__ *list = tree->link.list;
*ret = __TypedPtr_getParentPtrFromFieldPtr__(struct __MemTree__, childs, list);
};
// # __MemTree_getPrev__
struct __MemTree__*
__MemTree_getPrev__(
struct __MemTree__ *tree // expected __MemTree_isFirst__(tree) = false;
) {
struct __MemListLink__ *prev_link = tree->link.prev;
return __TypedPtr_getParentPtrFromFieldPtr__(struct __MemTree__, link, prev_link);
}
// # __MemTree_growChilds__
// convert childs to siblings
void __MemTree_growChilds__(
struct __MemTree__ *tree // expected tree with tree.childs.count > 0 and __MemTree_isChild__(tree) == true
) {
struct __MemList__ *childs = &tree->childs;
size_t *childs_count = &childs->count;
while(*childs_count > 0) {
struct __MemTree__ *child = __MemTree_popFirstChild__(tree);
__MemTree_pushNext__(tree, child);
}
}
// # __MemTree_init__
void __MemTree_init__(
struct __MemTree__ *t
) {
t->count = 0;
t->nested = 0;
__MemList_init__ (&t->childs);
__MemListLink_init__ (&t->link);
}
// # __MemTree_isChild__
bool __MemTree_isChild__ (
struct __MemTree__ *tree
) {
return tree->link.list != NULL;
};
// # __MemTree_isFirst__
bool __MemTree_isFirst__(
struct __MemTree__ *tree
) {
return tree->link.prev == NULL;
}
// # __MemTree_popFirstChild__
struct __MemTree__*
__MemTree_popFirstChild__(
struct __MemTree__ *tree // expected tree.childs.count > 0
) {
struct __MemListLink__ *child_link = tree->childs.first;
__MemList_pop__(&tree->childs, child_link);
return __TypedPtr_getParentPtrFromFieldPtr__(struct __MemTree__, link, child_link);
}
// # __MemTree_pop__
// pop self from parent
void __MemTree_pop__(
struct __MemTree__ *t // expected __MemTree_isChild__(tree) == true
) {
struct __MemTree__ *parent;
__MemTree_getParent__(&parent, t);
__MemList_pop__(&parent->childs, &t->link);
__MemTree_fix_counts__(parent, t->count + 1, __MemTree_fix_counts_Action_minus__);
__MemTree_fix_nested__(t, t->nested, __MemTree_fix_nested_Action_minus__);
}
// # __MemTree_pushChild__
void __MemTree_pushChild__(
struct __MemTree__ *t,
struct __MemTree__ *item
) {
__MemTree_fix_nested__(item, t->nested + 1, __MemTree_fix_nested_Action_plus__);
__MemList_pushLast__(&t->childs, &item->link);
__MemTree_fix_counts__(t, item->count + 1, __MemTree_fix_counts_Action_plus__);
}
// # __MemTree_fix_nested__
void __MemTree_fix_nested__(
struct __MemTree__ *t,
size_t nested_delta,
char action // __MemTree_fix_nested_Action__
) {
struct __MemTree__ *tree = t;
if (action == __MemTree_fix_nested_Action_plus__) {
while (tree) {
tree->nested += nested_delta;
tree = __MemTree_traverse__(tree);
}
} else { // minus
while (tree) {
tree->nested -= nested_delta;
tree = __MemTree_traverse__(tree);
}
}
}
// # __MemTree_pushNext__
void __MemTree_pushNext__(
struct __MemTree__ *t, // expected as child of another tree
struct __MemTree__ *item
) {
struct __MemTree__ *parent;
__MemTree_getParent__(&parent, t);
__MemTree_fix_nested__(item, t->nested, __MemTree_fix_nested_Action_plus__);
__MemList_pushAfter__(&parent->childs, &t->link, &item->link);
__MemTree_fix_counts__(parent, item->count + 1, __MemTree_fix_counts_Action_plus__);
}
// # __MemTree_pushPrev__
void __MemTree_pushPrev__(
struct __MemTree__ *t, // expected t is child
struct __MemTree__ *item
) {
struct __MemTree__ *parent;
__MemTree_getParent__(&parent, t); // expected true by right argument
__MemTree_fix_nested__(item, t->nested, __MemTree_fix_nested_Action_plus__);
__MemList_pushBefore__(&parent->childs, &t->link, &item->link);
__MemTree_fix_counts__(parent, item->count + 1, __MemTree_fix_counts_Action_plus__);
}
// # __MemTree_traverse__
struct __MemTree__* // return first_child or next or find next_parental or null
__MemTree_traverse__(
struct __MemTree__ *tree
) {
if (tree->childs.first) {
struct __MemListLink__ *first = tree->childs.first;
return __TypedPtr_getParentPtrFromFieldPtr__(struct __MemTree__, link, first);
} else {
struct __MemListLink__ *next = tree->link.next;
if (next) {
return __TypedPtr_getParentPtrFromFieldPtr__(struct __MemTree__, link, next);
} else {
struct __MemTree__ *parent = __MemTree_getParentOrNull__(tree);
while (parent) {
struct __MemListLink__ *next_of_parent = parent->link.next;
if (next_of_parent) {
return __TypedPtr_getParentPtrFromFieldPtr__(struct __MemTree__, link, next_of_parent);
}
parent = __MemTree_getParentOrNull__(parent);
}
}
}
return NULL;
}
// # __Mem_copyBackward__
void __Mem_copyBackward__(char* dest, const char* src, size_t size) {
size_t pos = size;
while(pos > 0) {
pos-=1;
dest[pos] = src[pos];
}
}
// # __Mem_copy__
void __Mem_copy__( // todo create macros __Mem_copyAny__
char *dest,
const char *src,
size_t size
) {
// i use this instead memcpy becouse clang-in-zig just replace memcpy to crash-zig-bloated-version code
size_t pos = 0;
while(pos < size) {
dest[pos] = src[pos];
pos++;
}
}
// # __Mem_fill__
void __Mem_fill__(
char *dest,
char symbol,
size_t len
) {
for (size_t pos = 0; pos < len; pos++) {
dest[pos] = symbol;
}
}
// # __Mem_findDiffOrLen__
size_t __Mem_findDiffOrLen__(const char a[], const char b[], size_t len) {
size_t pos = 0;
while(pos < len) {
if (a[pos] != b[pos]) break;
pos++;
}
return pos;
}
// # __Mem_findFast__
bool __Mem_findFast__(
size_t *ret_pos, // expected value 0
const char *data,
size_t data_len, // expected > 0
const char *desired,
size_t desired_len // expected > 0 // expected <= data_len // optimal > 4
) {
bool finded = false;
if (desired_len <= 4) {
if (data_len >= desired_len and __Mem_find__(ret_pos, data, data_len, desired, desired_len)) {
finded = true;
}
} else {
size_t final_check_pos = data_len - desired_len;
uint8_t target_sum = __Crypto_sumBytes__(desired, desired_len);
uint8_t target_xor = __Crypto_xorBytes__(desired, desired_len);
uint8_t hash_sum = __Crypto_sumBytes__(data, desired_len);
uint8_t hash_xor = __Crypto_xorBytes__(data, desired_len);
for (size_t pos = 0; pos <= final_check_pos; pos++) {
if (true
and hash_xor == target_xor
and hash_sum == target_sum
) {
if (__Mem_isEql__(&data[pos], desired, desired_len)) {
finded = true;
*ret_pos += pos;
break;
}
}
uint8_t last_start_byte = data[pos];
hash_xor ^= last_start_byte;
hash_sum -= last_start_byte;
uint8_t new_byte_end = data[pos + desired_len];
hash_xor ^= new_byte_end;
hash_sum += new_byte_end;
}
}
return finded;
}
// # __Mem_find__
bool __Mem_find__(
size_t *ret_pos, // this value increment by this func
const char *data,
size_t data_len, // expected >= desired_len
const char *desired,
size_t desired_len // expected >= 1
) {
bool finded = false;
size_t last_pos = data_len - desired_len;
for (uintptr_t pos = 0; pos <= last_pos; pos++) {
size_t slice_len = data_len - pos;
if (slice_len >= desired_len) {
if (__Mem_isEql__(&data[pos], desired, desired_len)) {
*ret_pos = pos;
finded = true;
break;
}
} else {
break;
}
}
return finded;
}
// # __Mem_isEql__
bool __Mem_isEql__(
const char* a,
const char* b,
size_t len
) {
return __Mem_findDiffOrLen__(a, b, len) == len;
}
// # __Mem_isEql_test__
bool __Mem_isEql_test__() {
return true
and (__Mem_isEql__("abcd", "abcd", 4))
and (__Mem_isEql__("abcd", "abce", 4) == false)
and (__Mem_isEql__("abcdasdasd", "asd", 3) == false)
;
}
// # __Mem_reverse__
void __Mem_reverse__(
char *dest,
const char *src,
size_t len
) {
src = &src[len - 1];
size_t iter = 0;
for(; iter < len; iter++, dest++, src--) {
*dest = *src;
}
}
// # __Nibble_fromAp__
uint8_t __Nibble_fromAp__(char data) {
if (data >= 'A' && data <= 'P') {
return data - 'A';
} else if (data >= 'a' && data <= 'p') {
return data - 'a';
}
return 0;
}
// # __Nibble_fromHexNibble__
char __Nibble_fromHexNibble__(char nibble) {
if (nibble >= 'a') return 10 + nibble - 'a';
if (nibble >= 'A') return 10 + nibble - 'A';
return nibble - '0';
}
// # __OsConsoleFlags_apply__
bool __OsConsoleFlags_apply__(
struct __OsConsoleFlags__ *t,
struct __OsConsoleInput__ *input,
struct __OsConsoleOutput__ *output
) {
// expected inited
bool ok = true;
#if __target_os__ == __TargetOs_windows__
int result1 = SetConsoleMode(input->handle, t->input_mode);
if (result1 == 0) {
ok = false;
// todo GetLastError();
}
int result2 = SetConsoleMode(output->__OsConsoleOutput_handle__, t->output_mode);
if (result2 == 0) {
ok = false;
// todo GetLastError();
}
#elif __target_os__ == __TargetOs_linux__
tcsetattr(input->fileno, TCSANOW, &t->termios);
tcsetattr(output->__OsConsoleOutput_handle__, TCSANOW, &t->termios);
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
return ok;
}
// # __OsConsoleFlags_init__
bool __OsConsoleFlags_init__(struct __OsConsoleFlags__ *t, struct __OsConsoleInput__* input, struct __OsConsoleOutput__ *output) {
bool ok = true;
#if __target_os__ == __TargetOs_windows__
bool result1 = GetConsoleMode(input->handle, &t->input_mode);
if (result1 != 0) {
bool result2 = GetConsoleMode(output->__OsConsoleOutput_handle__, &t->output_mode);
if (result2 != 0) {
t->inited = true;
} else {
ok = false;
}
} else {
ok = false;
}
#elif __target_os__ == __TargetOs_linux__
int result = tcgetattr(input->fileno, &t->termios);
if (result == 0) {
t->inited = true;
} else {
ok = false;
}
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
return ok;
}
// # __OsConsoleFlags_setNonCanonicalMode__
bool __OsConsoleFlags_setNonCanonicalMode__(struct __OsConsoleFlags__ *t) {
bool ok = true;
#if __target_os__ == __TargetOs_windows__
uint32_t input = t->input_mode;
input = __BitsU32_toggle__(input, ENABLE_EXTENDED_FLAGS, true);
input = __BitsU32_toggle__(input, ENABLE_ECHO_INPUT, false); // print pressed keys
input = __BitsU32_toggle__(input, ENABLE_LINE_INPUT, false); // wait '\n' (buffering on enter)
input = __BitsU32_toggle__(input, ENABLE_VIRTUAL_TERMINAL_INPUT, true);
input = __BitsU32_toggle__(input, ENABLE_PROCESSED_INPUT, false); // CTRL+C
input = __BitsU32_toggle__(input, ENABLE_MOUSE_INPUT, false);
input = __BitsU32_toggle__(input, ENABLE_QUICK_EDIT_MODE, true); // enable mouse select and copy
input = __BitsU32_toggle__(input, ENABLE_WINDOW_INPUT, false); // reported of change size of the console screen buffer
input = __BitsU32_toggle__(input, ENABLE_INSERT_MODE, true); // When enabled, text entered in a console window will be inserted at the current cursor location and all text following that location will not be overwritten. When disabled, all following text will be overwritten.
t->input_mode = input;
uint32_t output = t->output_mode;
output = __BitsU32_toggle__(output, ENABLE_LVB_GRID_WORLDWIDE, true); // enable colors
output = __BitsU32_toggle__(output, ENABLE_VIRTUAL_TERMINAL_PROCESSING, true); // emulate VT100
output = __BitsU32_toggle__(output, ENABLE_PROCESSED_OUTPUT, true); // Backspace, tab, bell, carriage return, and line feed characters are processed
output = __BitsU32_toggle__(output, ENABLE_WRAP_AT_EOL_OUTPUT, false); // disable line wrap
output = __BitsU32_toggle__(output, DISABLE_NEWLINE_AUTO_RETURN, true);
t->output_mode = output;
#elif __target_os__ == __TargetOs_linux__
// clear c_cc
cc_t* cc = &t->termios.c_cc[0]; // cc_t c_cc[NCCS]
for (int i = 0; i < NCCS ; i++) {
cc[i] = 0;
}
// timers off
cc = &t->termios.c_cc[0];
cc[VTIME] = 0;
cc[VMIN] = 1;
uint32_t cflag = t->termios.c_cflag;
cflag = __BitsU32_toggle__(cflag, CS8, true); // use 8 bit
cflag = __BitsU32_toggle__(cflag, CSTOPB, false); // two stops bits
cflag = __BitsU32_toggle__(cflag, PARENB, false); // parity check
cflag = __BitsU32_toggle__(cflag, PARODD, false); // parity check
t->termios.c_cflag = cflag;
uint32_t lflag = t->termios.c_lflag;
lflag = __BitsU32_toggle__(lflag, ISIG, false); // disable react to Ctrl+C
lflag = __BitsU32_toggle__(lflag, ICANON, false); // no wait '\n'
lflag = __BitsU32_toggle__(lflag, ECHO, false); // print pressed keys
lflag = __BitsU32_toggle__(lflag, ECHOE, false); // mashing
lflag = __BitsU32_toggle__(lflag, ECHONL, false); // print NL
lflag = __BitsU32_toggle__(lflag, ECHOK, false); // nl after clear line
lflag = __BitsU32_toggle__(lflag, ECHOKE, false); // print NL after BS
lflag = __BitsU32_toggle__(lflag, ECHOPRT, false); // print BS (BS SP BS)
lflag = __BitsU32_toggle__(lflag, IEXTEN, false); // special funcs
t->termios.c_lflag = lflag;
uint32_t iflag = t->termios.c_iflag;
iflag = __BitsU32_toggle__(iflag, IGNBRK, true); // ignore break control
iflag = __BitsU32_toggle__(iflag, BRKINT, true); // do not delete all data after break control
iflag = __BitsU32_toggle__(iflag, IXON, false); // disable react to Ctrl+S Ctlr+Q
iflag = __BitsU32_toggle__(iflag, ISTRIP, false); // strip
iflag = __BitsU32_toggle__(iflag, INLCR, false); // convert NL to CR
iflag = __BitsU32_toggle__(iflag, ICRNL, false); // convert CR to NL
iflag = __BitsU32_toggle__(iflag, XCASE, false); // convert register to UP
iflag = __BitsU32_toggle__(iflag, IUCLC, false); // convert register to down
iflag = __BitsU32_toggle__(iflag, IGNPAR, true); // ignore framing or parity errors
iflag = __BitsU32_toggle__(iflag, IMAXBEL, false); // no bell
t->termios.c_iflag = iflag;
uint32_t oflag = t->termios.c_oflag;
oflag = __BitsU32_toggle__(oflag, ONOCR, false); // on start line // Auto CR
oflag = __BitsU32_toggle__(oflag, ONLRET, false); // on end line // Auto CR
oflag = __BitsU32_toggle__(oflag, OPOST, true); // \_(O_o)_/
oflag = __BitsU32_toggle__(oflag, ONLCR, true); // NL to CR
oflag = __BitsU32_toggle__(oflag, OCRNL, false); // CR to NL
oflag = __BitsU32_toggle__(oflag, OLCUC, false); // convert to CAPS
oflag = __BitsU32_toggle__(oflag, XTABS, false); // convert tab
oflag = __BitsU32_toggle__(oflag, TAB3, false); // convert tab
oflag = __BitsU32_toggle__(oflag, OFDEL, false); // use null for deleted symbol
t->termios.c_oflag = oflag;
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
return ok;
}
// # __OsConsoleInput_getCountOfUnreaded__
bool __OsConsoleInput_getCountOfUnreaded__(struct __OsConsoleInput__* t, size_t *ret_unreaded) {
bool ok = true;
#if __target_os__ == __TargetOs_windows__
DWORD unreaded = 0;
if ( GetNumberOfConsoleInputEvents(t->handle, &unreaded) ) {
*ret_unreaded += unreaded;
} else {
ok = false;
}
#elif __target_os__ == __TargetOs_linux__
int unreaded = 0;
int result = ioctl(t->fileno, FIONREAD, &unreaded);
*ret_unreaded += unreaded;
#else
#error "__target_os__ not implemented"
#endif
return ok;
}
// # __OsConsoleInput_init__
void __OsConsoleInput_init__(
struct __OsConsoleInput__* t,
__OsConsoleInputHandle__ input_hanle
) {
#if __target_os__ == __TargetOs_windows__
t->handle = input_hanle;
#elif __target_os__ == __TargetOs_linux__
t->handle = input_hanle;
t->fileno = fileno(t->handle);
#else
#error "__target_os__ not implemented"
#endif
}
// # __OsConsoleInput_readByte__
bool __OsConsoleInput_readByte__(
char *ret_byte,
struct __OsConsoleInput__ *t
) {
bool ok = true;
#if __target_os__ == __TargetOs_windows__
INPUT_RECORD key;
DWORD picked = 0;
if ( ReadConsoleInputA(t->handle, &key, 1, &picked) ) {
if (picked != 0) {
if (key.EventType == KEY_EVENT) {
KEY_EVENT_RECORD *event = &key.Event.KeyEvent;
if (event->bKeyDown != 0) {
if (event->uChar.AsciiChar != 0) {
*ret_byte = event->uChar.AsciiChar;
} else {ok = false;}
} else {ok = false;}
} else {ok = false;}
} else {ok = false;}
} else {ok = false;}
#elif __target_os__ == __TargetOs_linux__
ssize_t result = read(t->fileno, ret_byte, 1);
if (result != 1) {ok = false;}
#else
#error "__target_os__ not implemented"
#endif
return ok;
}
// # __OsConsoleOutput_getSize__
void __OsConsoleOutput_getSize__ (
struct __OsConsoleOutput__ *t,
struct __Math2dPosU__ *ret_pos
) {
#if __target_os__ == __TargetOs_windows__
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(t->__OsConsoleOutput_handle__, &csbi);
int x = csbi.srWindow.Right - csbi.srWindow.Left + 1;
int y = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
ret_pos->x = x;
ret_pos->y = y;
// printf("%d, %d x %d\n", __LINE__, x, y);
#elif __target_os__ == __TargetOs_linux__
struct winsize w;
ioctl(t->__OsConsoleOutput_handle__, TIOCGWINSZ, &w);
ret_pos->x = w.ws_col;
ret_pos->y = w.ws_row;
#else
#error "__target_os__ not implemented"
#endif
}
// # __OsConsoleOutput_init__
void __OsConsoleOutput_init__(struct __OsConsoleOutput__* output, __OsConsoleOutputHandle__ handle) {
output->__OsConsoleOutput_handle__ = handle;
#if __target_os__ == __TargetOs_windows__
#elif __target_os__ == __TargetOs_linux__
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
}
// # __OsConsoleOutput_write__
bool __OsConsoleOutput_write__(
struct __OsConsoleOutput__* os_console_output,
const char* data,
size_t _len
) {
bool ok = true;
// support null-string // todo remove me
size_t len = _len;
if (len == 0) {
while(data[len] != 0) len += 1;
}
#if __target_os__ == __TargetOs_windows__
unsigned long writed = 0;
WriteConsoleA(os_console_output->__OsConsoleOutput_handle__, data, len, &writed, NULL);
len = writed;
#elif __target_os__ == __TargetOs_linux__
// stdin = 0
// stdout = 1
// stderr = 2
if (write(1, data, len) == len) {
} else {
ok = false;
}
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
return ok;
}
// # __OsEnvHome_getLen__
size_t __OsEnvHome_getLen__() {
size_t len = 0;
#if __target_os__ == __TargetOs_windows__
char* home_drive = getenv("HOMEDRIVE");
len += __ZText_countLen__(home_drive);
char* home_path = getenv("HOMEPATH");
len += __ZText_countLen__(home_path);
#elif __target_os__ == __TargetOs_linux__
char* home = getenv("HOME");
len += __ZText_countLen__(home);
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
return len;
}
// # __OsEnvHome_write__
void __OsEnvHome_write__(
char* buffer // expected len >= __OsEnvHome_getLen__()
) {
#if __target_os__ == __TargetOs_windows__
size_t writed = 0;
// write HOMEDRIVE
char* home_drive = getenv("HOMEDRIVE");
size_t home_drive_len = __ZText_countLen__(home_drive);
__Mem_copy__(&buffer[writed], home_drive, home_drive_len);
writed += home_drive_len;
// write HOMEPATH
char* home_path = getenv("HOMEPATH");
size_t home_path_len = __ZText_countLen__(home_path);
__Mem_copy__(&buffer[writed], home_path, home_path_len);
writed += home_path_len;
#elif __target_os__ == __TargetOs_linux__
char* home = getenv("HOME");
size_t len = __ZText_countLen__(home);
__Mem_copy__(buffer, home, len);
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
}
// # __OsFallbackConsole_write__
size_t
__OsFallbackConsole_write__ (
void* unused_ctx,
char* data,
size_t len
) {
#if __target_os__ == __TargetOs_windows__
struct __OsConsoleOutput__ console_output;
__OsConsoleOutput_init__(&console_output, GetStdHandle(STD_OUTPUT_HANDLE));
__OsConsoleOutput_write__(&console_output, data, len);
#elif __target_os__ == __TargetOs_linux__
__OsConsoleOutput_write__ (NULL, data, len);
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
return len;
}
// # __OsFile_clear__
void __OsFile_clear__(
__OsFileHandle__ file
) {
__OsFile_setPos__(file, 0);
__OsFile_truncate__(file);
}
// # __OsFile_close__
void __OsFile_close__(
__OsFileHandle__ file
) {
#if __target_os__ == __TargetOs_windows__
CloseHandle(file);
#elif __target_os__ == __TargetOs_linux__
close(file);
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
}
// # __OsFile_create__
bool __OsFile_create__(
__OsFileHandle__ *ret,
const char file_name[],
size_t file_name_len // expected < __OsFilePathLen_max__
) {
bool ok = true;
#if __target_os__ == __TargetOs_windows__
char file_name_z[__OsFilePathLen_max__ + 1]; // null terminated string
__Mem_copy__(file_name_z, file_name, file_name_len);
file_name_z[file_name_len] = 0;
HANDLE file = CreateFile( // open
file_name_z, // [in] LPCSTR lpFileName,
GENERIC_WRITE | GENERIC_READ, // [in] DWORD dwDesiredAccess,
0, // [in] DWORD dwShareMode, // TODO also try FILE_SHARE_WRITE
NULL, // [in, optional] LPSECURITY_ATTRIBUTES lpSecurityAttributes,
OPEN_ALWAYS, // [in] DWORD dwCreationDisposition,
FILE_ATTRIBUTE_NORMAL, // [in] DWORD dwFlagsAndAttributes,
NULL // [in, optional] HANDLE hTemplateFile
);
if (file != INVALID_HANDLE_VALUE) {
*ret = file;
} else {
ok = false;
}
#elif __target_os__ == __TargetOs_linux__
char file_name_z[__OsFilePathLen_max__ + 1]; // create null terminated string
__Mem_copy__(file_name_z, file_name, file_name_len);
file_name_z[file_name_len] = 0;
int file = creat(file_name_z, 0777);
if (file != -1) {
*ret = file;
} else {
ok = false;
}
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
return ok;
}
// # __OsFile_exist__
bool __OsFile_exist__(
const char* file_name,
size_t file_name_len // expected < __OsFilePathLen_max__
) {
bool ok = true;
#if __target_os__ == __TargetOs_windows__
char file_name_z[__OsFilePathLen_max__ + 1]; // create null terminated string
__Mem_copy__(file_name_z, file_name, file_name_len);
file_name_z[file_name_len] = 0;
DWORD attrs = GetFileAttributesA(file_name_z);
if (true
and (attrs != INVALID_FILE_ATTRIBUTES)
and (!(attrs & FILE_ATTRIBUTE_DIRECTORY))
) {
} else {
ok = false;
}
#elif __target_os__ == __TargetOs_linux__
char file_name_z[__OsFilePathLen_max__ + 1]; // create null terminated string
__Mem_copy__(file_name_z, file_name, file_name_len);
file_name_z[file_name_len] = 0;
struct stat buffer;
if (stat(file_name_z, &buffer) == 0) {
} else {
ok = false;
}
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
return ok;
}
// # __OsFile_getPos__
size_t __OsFile_getPos__(
__OsFileHandle__ file
) {
#if __target_os__ == __TargetOs_windows__
LARGE_INTEGER liPosition = {0};
LARGE_INTEGER liNewPosition = {0};
BOOL sfp_result = SetFilePointerEx (
file,
liPosition,
&liNewPosition,
FILE_CURRENT
);
if (sfp_result == FALSE) {
// unexpected
int err = GetLastError();
printf("%d SetFilePointerEx error: %d", __LINE__, err);
}
return liNewPosition.QuadPart;
#elif __target_os__ == __TargetOs_linux__
return lseek(file, 0, SEEK_CUR);
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
}
// # __OsFile_getSize__
size_t __OsFile_getSize__(
__OsFileHandle__ file
) {
#if __target_os__ == __TargetOs_windows__
LARGE_INTEGER size;
if (GetFileSizeEx(file, &size)) {
return size.QuadPart;
} else {
// unexpected
return 0;
}
#elif __target_os__ == __TargetOs_linux__
struct stat st;
fstat(file, &st);
return st.st_size;
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
}
// # __OsFile_openOrCreate__
bool __OsFile_openOrCreate__(
__OsFileHandle__ *ret,
const char file_name[],
size_t file_name_len // expected < __OsFilePathLen_max__
) {
if (__OsFile_exist__(file_name, file_name_len)) {
return __OsFile_open__(ret, file_name, file_name_len);
} else {
return __OsFile_create__(ret, file_name, file_name_len);
}
}
// # __OsFile_open__
bool __OsFile_open__(
__OsFileHandle__ *ret,
const char file_name[],
size_t file_name_len // expected < __OsFilePathLen_max__
) {
bool ok = true;
#if __target_os__ == __TargetOs_windows__
char file_name_z[__OsFilePathLen_max__ + 1]; // null terminated string
__Mem_copy__(file_name_z, file_name, file_name_len);
file_name_z[file_name_len] = 0;
HANDLE file = CreateFile( // open
file_name_z, // [in] LPCSTR lpFileName,
GENERIC_WRITE | GENERIC_READ, // [in] DWORD dwDesiredAccess,
0, // [in] DWORD dwShareMode, // TODO also try FILE_SHARE_WRITE
NULL, // [in, optional] LPSECURITY_ATTRIBUTES lpSecurityAttributes,
OPEN_EXISTING, // [in] DWORD dwCreationDisposition,
FILE_ATTRIBUTE_NORMAL, // [in] DWORD dwFlagsAndAttributes,
NULL // [in, optional] HANDLE hTemplateFile
);
if (file != INVALID_HANDLE_VALUE) {
*ret = file;
} else {
ok = false;
}
#elif __target_os__ == __TargetOs_linux__
char file_name_z[__OsFilePathLen_max__ + 1]; // null terminated string
__Mem_copy__(file_name_z, file_name, file_name_len);
file_name_z[file_name_len] = 0;
// open
int file = open(file_name_z, O_RDWR);
if (file != -1) {
*ret = file;
} else {
ok = false;
}
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
return ok;
}
// # __OsFile_readToBuffer__
bool __OsFile_readToBuffer__(
__OsFileHandle__ file,
char *buffer,
size_t buffer_len,
size_t offset
) {
bool ok = true;
size_t readed = 0;
while (ok and (readed < buffer_len)) {
__OsFile_setPos__(file, offset + readed);
#if __target_os__ == __TargetOs_windows__
__OsFile_setPos__(file, offset + readed);
LPDWORD readed_atom = 0;
if (ReadFile(file, &buffer[readed], buffer_len - readed, &readed_atom, NULL)) {
readed += (size_t) readed_atom;
} else {
ok = false;
}
#elif __target_os__ == __TargetOs_linux__
__OsFile_setPos__(file, offset + readed);
ssize_t read_result = read(file, &buffer[readed], buffer_len - readed);
if (read_result >= 0) {
readed += read_result;
} else {
ok = false;
}
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
}
return ok;
}
// # __OsFile_setPos__
void __OsFile_setPos__(
__OsFileHandle__ file,
size_t pos
) {
#if __target_os__ == __TargetOs_windows__
LARGE_INTEGER liPosition = {0};
liPosition.QuadPart = pos;
BOOL sfp_result = SetFilePointerEx(file, liPosition, NULL, FILE_BEGIN);
if (sfp_result == FALSE) {
// unexpeced
printf("%d, unexpected SetFilePointer result", __LINE__);
}
#elif __target_os__ == __TargetOs_linux__
lseek(file, pos, SEEK_SET);
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
}
// # __OsFile_truncate__
void __OsFile_truncate__(
__OsFileHandle__ file
) {
#if __target_os__ == __TargetOs_windows__
bool ok = true;
if (FlushFileBuffers(file)) {
if (SetEndOfFile(file)) {
if (FlushFileBuffers(file)) {
} else { // unexpected
ok = false;
printf("%d unexpected retusult of FlushFileBuffers", __LINE__);
}
} else { // unexpected
ok = false;
printf("%d unexpected retusult of SetEndOfFile", __LINE__);
}
} else { // unexpected
ok = false;
printf("%d unexpected retusult of FlushFileBuffers", __LINE__);
}
if (!ok) printf("%d failue", __LINE__);
// return ok; not needed to real return ok state becouse expected posibly truncate any file without errors.
#elif __target_os__ == __TargetOs_linux__
size_t current_pos = __OsFile_getPos__(file);
ftruncate(file, current_pos);
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
}
// # __OsFile_write__
bool __OsFile_write__(
__OsFileHandle__ file,
const char* data,
size_t data_len,
size_t offset
) {
bool ok = true;
size_t writed = 0;
while (ok and (writed < data_len)) {
__OsFile_setPos__(file, offset + writed);
#if __target_os__ == __TargetOs_windows__
DWORD atom_writed = 0;
if ( WriteFile(file, &data[writed], data_len - writed, &atom_writed, NULL) ) {
writed += atom_writed;
ok = FlushFileBuffers(file);
} else {
ok = false;
}
#elif __target_os__ == __TargetOs_linux__
ssize_t atom_write = write(file, &data[writed], data_len - writed);
if (atom_write != -1) {
writed += atom_write;
} else {
ok = false;
}
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
}
return ok;
}
// # __OsHelper_deinit__
void __OsHelper_deinit__(struct __OsHelper__*t) {
#if __target_os__ == __TargetOs_windows__
#if __with_network__
WSACleanup();
#endif
FreeLibrary(t->instance);
#elif __target_os__ == __TargetOs_linux__
// nothing to do
#else
#error "__target_os__ not implemented"
#endif
}
// # __OsHelper_init__
bool __OsHelper_init__(struct __OsHelper__* t) {
bool ok = true;
#if __target_os__ == __TargetOs_windows__
HMODULE instance = GetModuleHandleA(NULL);
if (instance != NULL) {
t->instance = instance;
HANDLE console_input_handle = GetStdHandle(STD_INPUT_HANDLE);
if (console_input_handle != INVALID_HANDLE_VALUE) {
t->console_input_handle = console_input_handle;
HANDLE console_output_handle = GetStdHandle(STD_OUTPUT_HANDLE);
if (console_output_handle != INVALID_HANDLE_VALUE) {
t->console_output_handle = console_output_handle;
#if __with_network__
if (
WSAStartup(
514, // wVersionRequested ver 2.2
&t->wsdata
) == 0
) { } else {
ok = false;
}
#endif
} else {
ok = false;
}
} else {
ok = false;
}
} else {
ok = false;
}
#elif __target_os__ == __TargetOs_linux__
t->console_input_handle = stdin;
t->console_output_handle = 1; // standart output
#else
#error "__target_os__ not implemented"
#endif
return ok;
}
// # __OsHelper_process__
void __OsHelper_process__(struct __OsHelper__* t) {
#if __target_os__ == __TargetOs_windows__
MSG msg;
if (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
#elif __target_os__ == __TargetOs_linux__
// nothing to do
#else
#error "__target_os__ not implemented"
#endif
}
// # __OsMem_alloc__
bool __OsMem_alloc__( // TODO use real system alloc?
uintptr_t *ret,
size_t size
) {
bool ok = true;
char* ptr = malloc(size);
if (ptr) {
*ret = (uintptr_t) ptr;
} else {
ok = false;
// TODO print debug
}
return ok;
}
// # __OsMem_free__
void __OsMem_free__(uintptr_t ptr) {
free((void*) ptr);
}
// # __Os_getTick__
uint64_t __Os_getTick__() {
#if __target_os__ == __TargetOs_windows__
FILETIME ft;
GetSystemTimeAsFileTime(&ft);
uint64_t ft64;
__Mem_copy__((char*) &ft64, (char*) &ft, 8);
return ft64 / 10000; // in ft is intervals * 100 ns. to ms need * 100 / 1000000
#elif __target_os__ == __TargetOs_linux__
// NOT TESTED
struct timespec ts;
clock_gettime(CLOCK_REALTIME, (void*)&ts);
uint64_t ms = ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
return ms;
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
}
// # __Os_sleep__
void __Os_sleep__(uint64_t ms) {
int a = 10;
#if __target_os__ == __TargetOs_windows__
Sleep(ms);
#elif __target_os__ == __TargetOs_linux__
struct timespec delay;
delay.tv_sec = ms / 1000;
delay.tv_nsec = (ms % 1000) * 1000000;
nanosleep(&delay, NULL);
#elif __target_os__ == __TargetOs_linuxOld__
if (milliseconds >= 1000) {
sleep(milliseconds / 1000);
}
usleep((milliseconds % 1000) * 1000);
#else
#error "not implemented current __target_os__ or not defined. (expected __TargetOs_ value)"
#endif
}
// # __TerminalInput_grab__
bool __TerminalInput_grab__(
__ConsoleAnsiInputKey__ *ret_key,
struct __TerminalInput__ *t
) {
if (t->ungrabed > 0) {
char* bytes = &t->buffer[0];
size_t bytes_len = t->ungrabed;
struct __ConsoleAnsiInputKey_SequenceParser__ parsed;
if (__ConsoleAnsi_input_Key_SequenceParser_fromBytes__(&parsed, bytes, bytes_len)) {
__TerminalInput_shift__(t, parsed.used);
*ret_key = parsed.sequence;
return true;
} else {
__ConsoleAnsiInputKey__ key = bytes[0];
__TerminalInput_shift__(t, 1);
*ret_key = key;
return true;
}
}
return false;
}
// # __TerminalInput_init__
void __TerminalInput_init__(
struct __TerminalInput__ *t
) {
t->ungrabed = 0;
}
// # __TerminalInput_shift__
void __TerminalInput_shift__(
struct __TerminalInput__ *t,
size_t val
) {
__Mem_copy__(&t->buffer[0], &t->buffer[val], __TerminalInput_size__ - val);
t->ungrabed -= val;
}
// # __TerminalOutputCursorPos_init__
void __TerminalOutputCursorPos_init__(
struct __Math2dPosU__ *cursor_pos
) {
cursor_pos->x = 0;
cursor_pos->y = 0;
}
// # __TerminalOutputCursorPos_move__
// not use me directly. use __Terminal_cursorMove__ instead
void __TerminalOutputCursorPos_move__(
struct __Terminal__ *terminal,
size_t new_pos_x,
size_t new_pos_y
) {
struct __Math2dPosU__ *cursor_pos = &terminal->output.cursor_pos;
if (new_pos_x != cursor_pos->x) { // move_from_x
// reset x pos
__OsConsoleOutput_write__(&terminal->console->output, "\r", 0);
cursor_pos->x = 0;
if (new_pos_x != 0) {
__Terminal_Output_Cursor_shiftRight__(terminal, new_pos_x - cursor_pos->x);
}
}
if (new_pos_y != cursor_pos->y) { // move_from_y
if (new_pos_y > cursor_pos->y) {
__Terminal_Output_Cursor_shiftDown__(terminal, new_pos_y - cursor_pos->y);
} else {
__Terminal_Output_Cursor_shiftUp__(terminal, cursor_pos->y - new_pos_y);
}
}
}
// # __Terminal_Output_Cursor_shiftDown__
void __Terminal_Output_Cursor_shiftDown__(
struct __Terminal__ *terminal,
size_t delta
) {
struct __Math2dPosU__ *cursor_pos = &terminal->output.cursor_pos;
if (delta != 0){
// print_to_console(__ConsoleAnsi_control__ + delta + "B");
char buffer[1024];
size_t writed = 0;
writed += __CText_write__(&buffer[0], __ConsoleAnsi_control__);
writed += __Text_formatU64ToBuffer__(&buffer[writed], delta, 1);
writed += __CText_write__(&buffer[writed], "B");
__OsConsoleOutput_write__(&terminal->console->output, &buffer[0], writed);
cursor_pos->y += delta;
}
}
// # __Terminal_Output_Cursor_shiftLeft__
void __Terminal_Output_Cursor_shiftLeft__(
struct __Terminal__ *terminal,
size_t delta
) {
struct __Math2dPosU__ *cursor_pos = &terminal->output.cursor_pos;
if (delta != 0) {
// print_to_console(__ConsoleAnsi_control__ + delta + "D");
char buffer[1024];
size_t writed = 0;
writed += __CText_write__(&buffer[0], __ConsoleAnsi_control__);
writed += __Text_formatU64ToBuffer__(&buffer[writed], delta, 1);
writed += __CText_write__(&buffer[writed], "D");
__OsConsoleOutput_write__(&terminal->console->output, &buffer[0], writed);
cursor_pos->x -= delta;
}
}
// # __Terminal_Output_Cursor_shiftRight__
void __Terminal_Output_Cursor_shiftRight__(
struct __Terminal__ *terminal,
size_t delta
) {
struct __Math2dPosU__ *cursor_pos = &terminal->output.cursor_pos;
if (delta != 0) {
// print_to_console(__ConsoleAnsi_control__ + delta + "C");
char buffer[1024];
size_t writed = 0;
writed += __CText_write__(&buffer[0], __ConsoleAnsi_control__);
writed += __Text_formatU64ToBuffer__(&buffer[writed], delta, 1);
writed += __CText_write__(&buffer[writed], "C");
__OsConsoleOutput_write__(&terminal->console->output, &buffer[0], writed);
cursor_pos->x += delta;
}
}
// # __Terminal_Output_Cursor_shiftUp__
void __Terminal_Output_Cursor_shiftUp__(
struct __Terminal__ *terminal,
size_t delta
) {
struct __Math2dPosU__ *cursor_pos = &terminal->output.cursor_pos;
if (delta != 0) {
// print_to_console(__ConsoleAnsi_control__ + delta + "A");
char buffer[1024];
size_t writed = 0;
writed += __CText_write__(&buffer[0], __ConsoleAnsi_control__);
writed += __Text_formatU64ToBuffer__(&buffer[writed], delta, 1);
writed += __CText_write__(&buffer[writed], "A");
__OsConsoleOutput_write__(&terminal->console->output, &buffer[0], writed);
cursor_pos->y -= delta;
}
}
// # __Terminal_clearOutput__
void __Terminal_clearOutput__(struct __Terminal__ *terminal) {
struct __Console__* console = terminal->console;
__ConsoleOutput_cursorHide__(&terminal->console->output);
size_t pos_y = 0;
while (pos_y < terminal->output.size.y) {
__Terminal_cursorMove__(terminal, 0, pos_y);
__OsConsoleOutput_writeCText__(&console->output, __ConsoleAnsi_output_clear_line__);
pos_y += 1;
}
__Console_showCursor__(console);
}
// # __Terminal_cursorMove__
void __Terminal_cursorMove__( // todo rename to cursorMoveOrReset
struct __Terminal__ *terminal,
size_t pos_x,
size_t pos_y
) {
if ((pos_x > terminal->output.size.x) or (pos_y > terminal->output.size.y)) {
terminal->output.cursor_pos.x = terminal->output.size.x - 1;
terminal->output.cursor_pos.y = terminal->output.size.y - 1;
__Terminal_moveCursorToStartOfLine__(terminal);
} else {
__TerminalOutputCursorPos_move__(terminal, pos_x, pos_y);
}
}
// # __Terminal_deinitOutput__
void __Terminal_deinitOutput__(struct __Terminal__ *terminal) {
struct __Console__ *console = terminal->console;
struct __OsConsoleOutput__ *console_output = &console->output;
__OsConsoleOutput_writeCText__(console_output, __ConsoleAnsiOutputSettings_enableLineWrap__);
__Terminal_resetColors__(terminal);
__OsConsoleOutput_writeCText__(console_output, __ConsoleAnsiOutputFontStyle_command_reset__);
__OsConsoleOutput_writeCText__(console_output, "\r\n");
__Console_showCursor__(console);
}
// # __Terminal_deinit__
bool __Terminal_deinit__(struct __Terminal__ *terminal) {
bool ok = true;
struct __Console__* console = terminal->console;
__Terminal_deinitOutput__(terminal);
if (__OsConsoleFlags_apply__(&terminal->system_flags, &console->input, &console->output)) {
} else {
ok = false;
}
return ok;
}
// # __Terminal_initBlankLinesToOutput__
void __Terminal_initBlankLinesToOutput__(struct __Terminal__ *terminal) {
struct __Console__ *console = terminal->console;
__OsConsoleOutput_writeCText__(&console->output, "\r\n");
__Terminal_cursorMove__(terminal, 0, 0);
size_t pos_y = 0;
while (pos_y < terminal->output.size.y - 2) {
__OsConsoleOutput_writeCText__(&console->output, "\r\n");
pos_y += 1;
terminal->output.cursor_pos.y += 1;
}
}
// # __Terminal_initOutput__
void __Terminal_initOutput__(struct __Terminal__ *terminal) {
struct __TerminalOutput__ *output = &terminal->output;
__TerminalOutputCursorPos_init__(&output->cursor_pos);
output->font_style = "";
output->__TerminalOutput_fontStyleLen__ = 0;
output->size.x = 1;
output->size.y = 1;
output->convert_n_to_rn = false;
output->apply_r = false;
output->apply_n = false;
__Terminal_updateOutputSize__(terminal);
__Terminal_resetColors__(terminal);
__Terminal_initBlankLinesToOutput__(terminal);
__Terminal_clearOutput__(terminal);
__Terminal_cursorMove__(terminal, 0, 0);
}
// # __Terminal_init__
bool __Terminal_init__(
struct __Terminal__ *t,
struct __Console__ *console
) {
bool ok = true;
t->console = console;
__TerminalInput_init__(&t->input);
__Terminal_initOutput__(t);
// configure console
// save flags before change
if (__OsConsoleFlags_init__(&t->system_flags, &console->input, &console->output)) {
// go to interactive mode ("non canonical mode" or "raw mode")
struct __OsConsoleFlags__ flags;
if (__OsConsoleFlags_init__(&flags, &console->input, &console->output)) {
__OsConsoleFlags_setNonCanonicalMode__(&flags);
if (__OsConsoleFlags_apply__(&flags, &console->input, &console->output)) {
__OsConsoleOutput_writeCText__(&console->output, __ConsoleAnsiOutputSettings_disableLineWrap__);
} else {
ok = false;
}
} else {
ok = false;
}
} else {
ok = false;
}
return ok;
}
// # __Terminal_moveCursorToNextLine__
void __Terminal_moveCursorToNextLine__(struct __Terminal__ *terminal) {
if (terminal->output.cursor_pos.y < terminal->output.size.y) {
__TerminalOutputCursorPos_move__(terminal, terminal->output.cursor_pos.x, terminal->output.cursor_pos.y + 1);
} else {
__OsConsoleOutput_write__(&terminal->console->output, "\n", 0);
}
}
// # __Terminal_moveCursorToStartOfLine__
void __Terminal_moveCursorToStartOfLine__(struct __Terminal__ *terminal) {
__OsConsoleOutput_write__(&terminal->console->output, "\r", 0);
terminal->output.cursor_pos.x = 0;
}
// # __Terminal_moveCursorToStartOfNextLine__
void __Terminal_moveCursorToStartOfNextLine__(struct __Terminal__ *terminal) { // \r\n
__Terminal_moveCursorToNextLine__(terminal);
__Terminal_moveCursorToStartOfLine__(terminal);
}
// # __Terminal_resetColors__
void __Terminal_resetColors__(struct __Terminal__ *terminal) {
__Terminal_setFontStyleCText__(terminal, __ConsoleAnsiOutputFontStyle_command_reset__);
}
// # __Terminal_setFontStyle__
void __Terminal_setFontStyle__(
struct __Terminal__ *terminal,
const char* font_style,
size_t font_style_len
) {
terminal->output.font_style = font_style;
terminal->output.__TerminalOutput_fontStyleLen__ = font_style_len;
__OsConsoleOutput_write__(&terminal->console->output, font_style, font_style_len);
}
// # __Terminal_updateInputBuffer__
void __Terminal_updateInputBuffer__(
struct __Terminal__ *terminal
) {
struct __Console__ *console = terminal->console;
size_t unreaded = 0;
if (__OsConsoleInput_getCountOfUnreaded__(&console->input, &unreaded)) {
while (terminal->input.ungrabed < __TerminalInput_size__ and unreaded > 0) { // get new byte
char byte;
if (__OsConsoleInput_readByte__(&byte, &console->input)) {
terminal->input.buffer[terminal->input.ungrabed] = byte;
terminal->input.ungrabed += 1;
}
unreaded -= 1;
}
} else {
// ok = false;
}
}
// # __Terminal_updateOutputSize__
void __Terminal_updateOutputSize__(struct __Terminal__ *terminal) {
struct __Math2dPosU__ size;
__OsConsoleOutput_getSize__(&terminal->console->output, &size);
// x
if (size.x >= 6) {
terminal->output.size.x = size.x - 3;
} else {
terminal->output.size.x = size.x;
}
// y
if (size.y >= 6) {
terminal->output.size.y = size.y - 3;
} else {
terminal->output.size.y = size.y;
}
}
// # __Terminal_writeColoredErrorSymbolToOutput__
void __Terminal_writeColoredErrorSymbolToOutput__(
struct __Terminal__ *t
) {
struct __Console__ *console = t->console;
#define __TerminalErrorSymbol_color__ \
__ConsoleAnsiOutputFontStyle_start__ \
__ConsoleAnsiOutputFontStyle_bg_color_yellow__ \
__ConsoleAnsiOutputFontStyle_sep__ \
__ConsoleAnsiOutputFontStyle_color_red__ \
__ConsoleAnsiOutputFontStyle_end__
__OsConsoleOutput_writeCText__(&console->output, __TerminalErrorSymbol_color__);
__OsConsoleOutput_writeCText__(&console->output, "#");
__OsConsoleOutput_write__(&console->output, t->output.font_style, t->output.__TerminalOutput_fontStyleLen__);
t->output.cursor_pos.x += 1;
}
// # __Terminal_writeToOutput__
void __Terminal_writeToOutput__(
struct __Terminal__ *terminal,
const char *bytes,
size_t bytes_len
) {
for (size_t readed = 0; readed < bytes_len; readed += 1) {
char byte = bytes[readed];
if (byte >= ' ' and byte <= '~') {
struct __Console__ * console = terminal->console;
__OsConsoleOutput_write__(&console->output, &bytes[readed], 1);
terminal->output.cursor_pos.x += 1;
} else if (byte == '\r') {
if (terminal->output.apply_r) {
__Terminal_moveCursorToStartOfLine__(terminal);
} else {
__Terminal_writeColoredErrorSymbolToOutput__(terminal);
}
} else if (byte == '\t') {
__Terminal_writeColoredErrorSymbolToOutput__(terminal);
} else if (byte == '\n') {
if (terminal->output.apply_n) {
if (terminal->output.convert_n_to_rn) __Terminal_moveCursorToStartOfLine__(terminal);
__Terminal_moveCursorToNextLine__(terminal);
} else {
__Terminal_writeColoredErrorSymbolToOutput__(terminal);
}
} else {
__Terminal_writeColoredErrorSymbolToOutput__(terminal);
}
}
}
// # __TextAsciiSymbol_isBreakWord__
bool __TextAsciiSymbol_isBreakWord__(char symbol) {
return __TextAsciiSymbol_isWord__(symbol) == false;
}
// # __TextAsciiSymbol_isWordSymbol__
bool __TextAsciiSymbol_isWordSymbol__(char symbol) {
return false
or (symbol >= '0' and symbol <= '9')
or (symbol >= 'a' and symbol <= 'z')
or (symbol >= 'A' and symbol <= 'Z')
;
}
// # __TextAsciiSymbol_isWord__
bool __TextAsciiSymbol_isWord__(char symbol) {
return false
or (symbol == '_')
or __TextAsciiSymbol_isWordSymbol__(symbol)
;
}
// # __TextAscii_compare__
char // return -1, 0 or 1 where -1 mean less, 0 mean eql and 1 is more.
__TextAscii_compare__(
const char* text1,
const char* text2,
size_t text_len
) {
for (size_t pos = 0; pos < text_len; pos++) {
uint8_t t1 = *(uint8_t*) &text1[pos];
uint8_t t2 = *(uint8_t*) &text2[pos];
if (t1 != t2) {
if (t1 < t2) return -1;
return 1;
}
}
return 0;
}
// # __TextAscii_countIndentReverse__
size_t __TextAscii_countIndentReverse__(
const char *text,
size_t text_len,
size_t tabsize
) {
size_t count = 0;
if (text_len > 0) {
size_t pos = text_len - 1;
while(true) {
char r = text[pos];
if (r == 0 ) {
count += 1;
} else if (r == ' ') {
count += 1;
} else if (r == '\t') {
count += tabsize;
} else if (r == '\r') {
count += 1;
} else break;
if (pos == 0) break;
pos -= 1;
}
}
return count;
}
// # __TextAscii_countIndent__
size_t __TextAscii_countIndent__(
const char *text,
size_t text_len,
size_t tabsize
) {
size_t count = 0;
for (size_t pos = 0; pos < text_len; pos++) {
char r = text[pos];
if ( r == 0) { count += 1;
} else if ( r == ' ') { count += 1;
} else if ( r == '\t') { count += tabsize;
} else if ( r == '\r') { count += 1;
} else break;
}
return count;
}
// # __TextAscii_countNonIndent__
size_t __TextAscii_countNonIndent__(
const char *text,
size_t text_len
) {
size_t indent = __TextAscii_countIndent__(text, text_len, 1);
return text_len - indent;
}
// # __TextAscii_cutIndents__
bool __TextAscii_cutIndents__(
size_t *ret_pos, // incremented by fn
size_t *ret_len, // incremented by fn
const char *bytes,
size_t bytes_len
) {
bool ok = true;
if (bytes_len > 0) { // cut from left
size_t start = 0;
while (true) {
if (start < bytes_len) {
if (bytes[start] != ' ') {
break;
}
start += 1;
} else { // TextIsEmpty
ok = false;
break;
}
}
if (ok) { // cut from right
size_t end = bytes_len - 1;
while (true) {
if (bytes[end] != ' ') {
break;
}
end -= 1;
}
*ret_pos += start;
*ret_len += end+1 - start;
}
} else {
ok = false;
}
return ok;
}
// # __TextAscii_findBreakOfWordReverse__
size_t __TextAscii_findBreakOfWordReverse__(
const char *text,
size_t text_len // expected text_len > 0
) {
if (text_len == 1) return 0;
for (size_t pos = text_len - 1; pos > 0; pos--) {
char symbol = text[pos];
if (__TextAsciiSymbol_isBreakWord__(symbol)) return pos;
}
return 0;
}
// # __TextAscii_findBreakOfWord__
size_t __TextAscii_findBreakOfWord__(
const char* text,
size_t text_len
) {
if (text_len == 1) return 1;
for (size_t pos = 1; pos < text_len; pos++) {
char symbol = text[pos];
if (__TextAsciiSymbol_isBreakWord__(symbol)) return pos;
}
return text_len;
}
// # __TextAscii_getNonIndent__
bool
__TextAscii_getNonIndent__(
const char **ret_ptr,
size_t *ret_size,
const char *text,
size_t text_len
) {
size_t indent = __TextAscii_countIndent__(text, text_len, 1);
if (indent == text_len) return false;
*ret_ptr = &text[indent];
*ret_size = text_len - indent;
return true;
}
// # __TextAscii_getStartOfText__
bool __TextAscii_getStartOfText__(
size_t *ret_pos, // increment by fn
const char *text,
size_t text_len
) {
bool ok = true;
bool finded = false;
size_t pos = 0;
for (; pos < text_len; pos++) {
char symbol = text[pos];
if (true
and symbol != ' '
and symbol != '\t'
) {
finded = true;
break;
}
}
*ret_pos += pos;
ok = ok and finded;
return ok;
}
// # __TextAscii_isLetter__
bool __TextAscii_isLetter__(char rune) {
return false
or rune < ' '
or __TextAsciiSymbol_isWord__(rune)
or rune >= 127
;
}
// # __TextAscii_isVisible__
bool __TextAscii_isVisible__(char byte) {
return (byte >= 33) and (byte <= 126);
}
// # __TextFormatU64_do__
void __TextFormatU64_do__(
struct __TextFormatU64__ *t,
uint64_t number,
size_t min_width
) {
size_t len = 0;
uintptr_t buffer_start = (uintptr_t) &t->buffer[0];
uintptr_t buffer_end = buffer_start + __TextCharsDecFromU64_lenMax__;
// write utoa
uintptr_t addr = buffer_end;
for (uint64_t num = number; num > 0; num = num / 10) {
uint8_t remainder = num % 10;
addr = addr - 1;
*(char*) addr = '0' + (char) remainder;
}
len = buffer_end - addr;
// fill zeroes to min_width
if (min_width > len) {
size_t fill_len = min_width - len;
addr = addr - fill_len;
__Mem_fillAny__(addr, '0', fill_len);
len = len + fill_len;
}
t->ptr = (char*) addr;
t->len = len;
}
// # __TextSplitter_init__
void __TextSplitter_init__(struct __Text_Splitter__* t, char* text, size_t text_len, char* delim, size_t delim_len) {
t->stop = false;
t->last_pos = 0;
__Finder_init__(&t->finder, text, text_len, delim, delim_len);
}
// # __TextSplitter_next__
bool __TextSplitter_next__(struct __Text_Splitter__* t, struct Slice* out_slice) {
if (t->stop == false) {
size_t finded;
if (__Finder_next__(&t->finder, &finded)) {
out_slice->ptr = &t->finder.text.ptr[t->last_pos]; // slice = t->finder.text[t->last_pos..finded];
out_slice->len = finded - t->last_pos;
t->last_pos = t->finder.pos;
return true;
} else {
t->stop = true;
out_slice->ptr = &t->finder.text.ptr[t->last_pos]; // slice = t->finder.text[t->last_pos..];
out_slice->len = t->finder.text.len - t->last_pos;
t->last_pos = t->finder.pos;
return true;
}
}
return false;
}
// # __Text_countIndent__
size_t
__Text_countIndent__(
char* text,
size_t text_len, // can be 0
size_t tab_size
) {
size_t counted = 0;
size_t pos = 0;
while (pos < text_len) {
char symbol = text[pos];
if (symbol == ' ') {
counted = counted + 1;
} else if (symbol == '\t') {
counted = counted + tab_size;
} else {
break;
}
pos = pos + 1;
}
return counted;
}
// # __Text_formatU64ToBuffer__
size_t __Text_formatU64ToBuffer__(
char *buffer, // expected len >= __TextCharsDecFromU64_lenMax__
uint64_t number,
size_t min_width
) {
struct __TextFormatU64__ format;
__TextFormatU64_do__(&format, number, min_width);
if (format.len > 0) {
__Mem_copy__(buffer, format.ptr, format.len);
}
return format.len;
}
// # __Text_formatU64__
size_t __Text_formatU64__(__WriteFnPtrVoid__ fn_write, void* context, uint64_t number, size_t min_width) {
struct __TextFormatU64__ format;
__TextFormatU64_do__(&format, number, min_width);
fn_write(context, format.ptr, format.len);
return format.len;
}
// # __Trace_init__
void __Trace_init__(
struct __Trace__ *trace,
struct __Trace__ *prev_trace, // can be null
size_t line
) {
trace->__Trace_prevTrace__ = prev_trace;
trace->__Trace_line__ = line;
}
// # __Trace_print__
void __Trace_print__(
struct __Trace__ *trace
) {
if (trace) {
printf("%zu", trace->__Trace_line__);
trace = trace->__Trace_prevTrace__;
while (trace) {
printf("|%zu", trace->__Trace_line__);
trace = trace->__Trace_prevTrace__;
}
} else {
printf("nil");
}
}
// # __ZText_countLen__
size_t __ZText_countLen__(const char text[]) {
size_t len = 0;
while(text[len] != 0) len++;
return len;
}
// # __ZText_fromBytes__
void __ZText_fromBytes__(char* buffer, const char bytes[], size_t bytes_len) {
// expected buffer_len >= bytes_len + 1
__Mem_copy__(buffer, bytes, bytes_len);
buffer[bytes_len] = 0;
}
// # __ZText_writeToBuffer__
size_t __ZText_writeToBuffer__(char buffer[], const char data[]) {
const size_t len = __ZText_countLen__(data);
__Mem_copy__(buffer, data, len);
return len;
}
// # __ZText_writeToWriteFn__
size_t __ZText_writeToWriteFn__(__WriteFnPtr__ fn_write, void* context, const char text[]) {
const size_t len = __ZText_countLen__(text);
fn_write(context, text, len);
return len;
}
// # __mem_findFastReverse__
bool __mem_findFastReverse__(
size_t *ret_pos, // func increment this
const char *data,
size_t data_len, // expected >= 1
const char *desired,
size_t desired_len // expected <= data_len
) {
bool finded = false;
size_t final_check_pos = data_len - desired_len;
if (desired_len <= 4) {
for (size_t pos = 0; pos <= final_check_pos + 1; pos++) {
size_t rpos = final_check_pos - pos;
if (__Mem_isEql__(&data[rpos], desired, desired_len)) {
*ret_pos += rpos;
finded = true;
break;
}
}
} else {
const char* final_check_ptr = &data[final_check_pos];
if (__Mem_isEql__(final_check_ptr, desired, desired_len)) {
finded = true;
*ret_pos += final_check_pos;
} else {
uint8_t target_sum = __Crypto_sumBytes__(desired, desired_len);
uint8_t target_xor = __Crypto_xorBytes__(desired, desired_len);
uint8_t hash_sum = __Crypto_sumBytes__(final_check_ptr, desired_len);
uint8_t hash_xor = __Crypto_xorBytes__(final_check_ptr, desired_len);
for (size_t pos = 1; pos <= final_check_pos + 1; pos++) {
size_t rpos = final_check_pos - pos;
uint8_t last_final_byte = data[rpos + desired_len];
hash_xor ^= last_final_byte;
hash_sum -= last_final_byte;
uint8_t new_byte = data[rpos];
hash_xor ^= new_byte;
hash_sum += new_byte;
if (
(hash_xor == target_xor)
and (hash_sum == target_sum)
and (__Mem_isEql__(&data[rpos], desired, desired_len))
) {
*ret_pos += rpos;
finded = true;
break;
}
}
}
}
return finded;
}
// # __u64FromTextDec__ atoi atou
uint64_t
__u64FromTextDec__(
const char *bytes, // expected bytes only with numbers from '0' to '9'
size_t len // expected > 0; expected <= __u64FromTextDec_maxLen__
) {
uint64_t result = 0;
size_t numerical_place = 1;
size_t pos = len - 1; // last symbol
while (true) {
char byte = bytes[pos];
uint64_t value = (uint64_t) ((uint8_t)byte - (uint8_t)'0');
result += value * numerical_place;
if (pos == 0) break;
numerical_place *= 10;
pos -= 1;
}
return result;
}
// # bits_rotl16
uint16_t bits_rotl16(uint16_t value, unsigned int shift) {
shift %= 16;
return (value << shift) | (value >> (16 - shift));
}
// # bits_rotl32
uint32_t bits_rotl32(uint32_t value, unsigned int shift) {
shift %= 32;
return (value << shift) | (value >> (32 - shift));
}
// # bits_rotl64
uint64_t bits_rotl64(uint64_t value, unsigned int shift) {
shift %= 64;
return (value << shift) | (value >> (64 - shift));
}
// # bits_rotl8
uint8_t bits_rotl8(uint8_t value, unsigned int shift) {
shift %= 8;
return (value << shift) | (value >> (8 - shift));
}
// # call_other_trace_example
void call_other_trace_example(
struct __Trace__* prev_trace // can be null
) {
struct __Trace__ trace; __Trace_init__(&trace, prev_trace, __LINE__);
trace.__Trace_line__ = __LINE__; print_trace_example(0, &trace);
}
// # cpu_checkNumberFormat
bool cpu_checkNumberFormat() {
char current_endians = 0;
int n = 1;
if (* (char *) &n == 1) {
current_endians = __TargetMemoryType_endiansLittle__;
} else {
current_endians = __TargetMemoryType_endiansBig__;
}
if (__target_memoryType__ == current_endians) {
return true;
} else {
printf("%d wrong MEMORY_TYPE !\r\n", __LINE__);
}
return false;
}
// # isStartWith
bool isStartWith(struct Slice* a, struct Slice* b) {
return (a->len >= b->len) && __Mem_isEql__(a->ptr, b->ptr, b->len);
}
// # main
#ifndef __COMPILED_FROM_ZIG_FILE__
int main(int args_len, char** args_ptr) {
if (real_main(args_len, args_ptr)) return 0;
return 1;
}
#endif
// # printHex
void printHex(char* buffer_ptr, uintptr_t buffer_len) {
for (int i = 0; i < buffer_len; i++) {
printf(" %02X ", buffer_ptr[i]);
}
}
// # print_trace_example
void print_trace_example(
int anyarg,
struct __Trace__* prev_trace
) {
struct __Trace__ trace; __Trace_init__(&trace, prev_trace, __LINE__);
trace.__Trace_line__ = __LINE__; __Trace_print__(&trace);
}
// # readBig16
uint16_t readBig16(char* src) {
uint16_t ret;
__Mem_nativeToBig__( (char*) &ret, src, 2);
return ret;
}
// # readBig32
uint32_t readBig32(char* src) {
uint32_t ret;
__Mem_nativeToBig__( (char*) &ret, src, 4);
return ret;
}
// # readBig64
uint64_t readBig64(char* src) {
uint64_t ret;
__Mem_nativeToBig__( (char*) &ret, src, 8);
return ret;
}
// # readLittle16
uint16_t readLittle16(char* src) {
uint16_t ret;
__Mem_nativeToLittle__( (char*) &ret, src, 2);
return ret;
}
// # readLittle32
uint32_t readLittle32(char* src) {
uint32_t ret;
__Mem_nativeToLittle__( (char*) &ret, src, 4);
return ret;
}
// # readLittle64
uint64_t readLittle64(char* src) {
uint64_t ret;
__Mem_nativeToLittle__( (char*) &ret, src, 8);
return ret;
}
// # real_main
bool real_main(int args_len, char** args_ptr) {
struct __Trace__ trace; __Trace_init__(&trace, NULL, __LINE__);
bool ok = true;
trace.__Trace_line__ = __LINE__;
if (tests()) {
trace.__Trace_line__ = __LINE__;
printf("%d success tests \r\n", __LINE__);
if (false and __App_init__(&__app__)) {
trace.__Trace_line__ = __LINE__; __Trace_print__(&trace);
while(true) {
if (!__App_process__(&__app__)) break;
__App_waitToNextFrame__(&__app__);
}
__App_deinit__(&__app__);
} else {
ok = false;
printf("%d fail: __App_init__\r\n", __LINE__);
}
} else {
ok = false;
printf("%d fail tests \r\n", __LINE__);
}
return ok;
}
// # test_rot
bool test_rot() {
char a = 0b11111100 >> 2;
if (a == 0b00111111) {
return true;
} else {
printf("%d: failed test_rot.", __LINE__);
}
return false;
}
// # tests
bool tests() {
// const char* test_file_name = "scalpi_testing_file.txt";
// size_t test_file_name_len = __ZText_countLen__(test_file_name);
if ( true
and cpu_checkNumberFormat()
and __Mem_isEql_test__()
// and __FileComplete_write__(test_file_name, test_file_name_len, "abcd", 4)
// and __FileComplete_write__(test_file_name, test_file_name_len, "efgh", 4)
// and __FileComplete_write__(test_file_name, test_file_name_len, "ijkm", 4)
// and etc...
) {
return true;
} else {
printf("%d fail tests \r\n", __LINE__);
return false;
}
return true;
}
// # writeBig16
void writeBig16(
char *dest,
uint16_t value
) {
__Mem_nativeToBig__( dest, (char*)&value, 2);
}
// # writeBig32
void writeBig32(
char *dest,
uint32_t value
) {
__Mem_nativeToBig__(dest, (char*)&value, 4);
}
// # writeBig64
void writeBig64(
char *dest,
uint64_t value
) {
__Mem_nativeToBig__(dest, (char*)&value, 8);
}
// # writeLittle16
void writeLittle16(
char *dest,
uint16_t value
) {
__Mem_nativeToLittle__(dest, (char*)&value, 2);
}
// # writeLittle32
void writeLittle32(
char *dest,
uint32_t value
) {
__Mem_nativeToLittle__(dest, (char*)&value, 4);
}
// # writeLittle64
void writeLittle64(
char *dest,
uint64_t value
) {
__Mem_nativeToLittle__(dest, (char*)&value, 8);
}
// # writeWithOffset
void writeWithOffset(
char *dest,
size_t *writed,
char *data,
size_t data_len // increment by fn
) {
__Mem_copy__(&dest[*writed], data, data_len);
*writed += data_len;
}
// TODO port this zig code to C
/*
const Utf8 = struct {
const BytesIterator = struct {
const Parsed = struct {
num: u64 = 0,
bytes: []const u8 = &.{},
fn is_connector(t: *Parsed) bool {
if (t.num == 0x200D) return true;
return false;
}
};
const Iterator = struct {
bytes: []const u8,
pos: usize = 0,
fn next(t: *Iterator) ?Parsed {
// Masks:
//| 1 byte | 2 byte | 3 byte | 4 byte
//
// 0xxxxxxx
// 110xxxxx 10xxxxxx
// 1110xxxx 10xxxxxx 10xxxxxx
// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
// example "?"
// 208 -- 110 10000
// 159 -- 10 011111
// is
// 1055 -- 000 10000011111
parse: {
var parsed: Parsed = .{};
// 1 byte
if (t.bytes.len <= t.pos) break :parse;
const b1 = t.bytes[t.pos];
const c1: u64 = @intCast(b1);
if (checkMask(b1, 0, 0b10000000)) { // 0xxxxxxx
parsed.num = b1 & 0b01111111;
parsed.bytes = t.bytes[t.pos .. t.pos + 1];
t.pos += 1;
return parsed;
}
// 2 byte
if (t.bytes.len <= t.pos + 1) break :parse;
const b2 = t.bytes[t.pos + 1];
const c2: u64 = @intCast(b2);
if (checkMask(b1, 0b11000000, 0b11100000)) { // 110xxxxx
parsed.num = ((c1 & 31) << 6) + (c2 & 63);
parsed.bytes = t.bytes[t.pos .. t.pos + 2];
t.pos += 2;
return parsed;
}
// 3 byte
if (t.bytes.len <= t.pos + 2) break :parse;
const b3 = t.bytes[t.pos + 2];
const c3: u64 = @intCast(b3);
if (checkMask(b1, 0b11100000, 0b11110000)) { // 1110xxxx
parsed.num = ((c1 & 15) << 12) + ((c2 & 63) << 6) + (c3 & 63);
parsed.bytes = t.bytes[t.pos .. t.pos + 3];
t.pos += 3;
return parsed;
}
// 4 byte
if (t.bytes.len <= t.pos + 3) break :parse;
const b4 = t.bytes[t.pos + 3];
const c4: u64 = @intCast(b4);
if (checkMask(b1, 0b11110000, 0b11111000)) { // 11110xxx
parsed.num = ((c1 & 7) << 21) + ((c2 & 63) << 12) + ((c3 & 63) << 6) + (c4 & 63);
parsed.bytes = t.bytes[t.pos .. t.pos + 4];
t.pos += 4;
return parsed;
}
}
t.pos += 1;
return null;
}
};
fn checkMask(num: u8, mask: u8, used_bits: u8) bool {
if (num & used_bits == mask) {
return true;
} else {
return false;
}
}
fn fromDo(bytes: []const u8) Iterator {
return Iterator{ .bytes = bytes };
}
};
};
*/
|
Added main.zig.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 |
// about
// ScalpiEditor - ansi-only text editor for terminals.
// killer features: no. its just editor.
// licenze:
// This code and its derivatives can be used under the following conditions:
// - Do not attack other countries.
// - Jerk off on public at least 1 time per day.
// - maintain hygiene.
// - check my other projects https://chiselapp.com/user/sergey6661313
// Compile:
// latest release tested with zig ver 0.15.1 downloaded from https://ziglang.org/download/
// for generate executable file use:
// linux: zig build-exe -lc -O ReleaseSmall -target x86_64-linux-gnu -mcpu baseline ./main.zig -I "."
// x86_64-linux-musl not work, becouse zig ^_^
// windows: zig build-exe -lc -O ReleaseSmall -target x86_64-windows -mcpu baseline ./main.zig -I "."
// known bugs in windows:
// f5 - f12 not work in windows in some terminals. (i use Alacritty)
// some time brackets not are not written
// its not editor bug.
// this happened if you try press ctrl+r in prompt shell with non english keyboard.
// this action just crack your terminal session.
// just restart your terminal session and it will be ok.
// to support me
// with boosty:
// https://boosty.to/cutloosedev
// with monero:
// 87T7 qGbA TrM3 a6Br
// DyeC jQQf NWtU u3iZ
// bHVB MC6W mEbN NE13
// Qrrt KhBb e4vF 58NR
// 8PTF dYk2 Sozc HexX
// 4Q69 jbdQ Asrs P7B
// tested in terminals:
// linux
// Alacritty
// WezTerm
// sakura
// windows
// Alacritty-v0.13.2-portable
// tabby-1.0.207-portable-x64
// WezTerm-windows-20240520-135708-b8f94c47.
// contour-0.4.3.6442-win64
// hyper_4.0.0-canary.5
// windows_terminal - need some unbind keys to work.
// not tested in terminals:
// extratermqt-0.77.0-windows-x64 - not run in my system.
// todo
// find way to remove __AppEditorHistoryNote_alloc__ (zig not compiled without it)
// all func uses this is dependence on AppEditor. first move AppEditor to C
// remove from fn c.__OsConsoleOutput_write__ null len variant
// add ability to read part of file for work with extra big files.
// import
const std = @import("std");
const builtin = @import("builtin");
const c = @cImport({
@cDefine("__COMPILED_FROM_ZIG_FILE__", "1");
@cDefine("_NO_CRT_STDIO_INLINE", "1"); // https://github.com/ziglang/zig/issues/515
switch(builtin.os.tag) {
.windows => @cDefine("_WIN32", "1"),
.linux => @cDefine("__linux__", "1"),
else => {},
}
@cInclude("main.c");
});
// functions
// # __AppEditorViewsEasyMotionHorizontal_onKey__
fn __AppEditorViewsEasyMotionHorizontal_onKey__(ctx: ?*anyopaque, cik: c.__ConsoleAnsiInputKey__) callconv(.c) void { __zig_fuck__(ctx);
if ( cik == c.__ConsoleAnsiInputKey_escape__ ) {
c.__AppEditorViewsEasyMotionHorizontalContext_vtable__.*.setAsView.?(c.__AppEditorViewsEasyMotionHorizontal_context__);
} else if ( cik == c.__ConsoleAnsiInputKey_ctrl_q__ ) {
c.__AppEditor_stop__(&c.__app__.editor);
} else {
const byte: u8 = @truncate(cik);
if ( byte >= '0' and byte <= '9' ) {
const pos: usize = byte - '0' + ('z' - 'a') + 1;
c.__AppEditorViewsEasyMotionHorizontal_moveTo__(pos * c.__AppEditorViewsEasyMotionHorizontal_step__);
} else if (byte >= 'a' and byte <= 'z' ) {
const pos: usize = byte - 'a';
c.__AppEditorViewsEasyMotionHorizontal_moveTo__(pos * c.__AppEditorViewsEasyMotionHorizontal_step__);
}
}
}
// # __AppEditorViewsEasyMotionHorizontal_setAsView__
fn __AppEditorViewsEasyMotionHorizontal_setAsView__(last_context: *anyopaque, last_vtable: *const c.__AppEditorViewsVTable__) callconv(.c) void {
c.__AppEditorViewsEasyMotionHorizontal_context__ = last_context;
c.__AppEditorViewsEasyMotionHorizontalContext_vtable__ = last_vtable;
c.__app__.editor.do_ptr = null;
c.__app__.editor.onKey_ptr = &__AppEditorViewsEasyMotionHorizontal_onKey__;
c.__app__.editor.current_ctx = null;
c.__AppEditorViewsEasyMotionHorizontal_draw__();
}
// # __AppEditorViewsEasyMotionVertical_draw__
fn __AppEditorViewsEasyMotionVertical_draw__() !void {
const terminal = &c.__app__.terminal;
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_easy_motion__, c.__AppEditorTheme_easy_motion__.len);
const vox = c.__AppEditorViewsEasyMotionVertical_context_vtable__.*.getOffsetX.?(c.__AppEditorViewsEasyMotionVertical_context__);
var pos: usize = 0;
var rune: u8 = 'a';
while (true) {
if (pos >= terminal.output.size.y - 1 - c.__AppEditorViewsEasyMotionVertical_step__) break;
c.__Terminal_cursorMove__(terminal, vox, pos);
c.__Terminal_writeToOutput__(terminal, &rune, 1);
if (rune == '9') {
break;
} else if (rune == 'z') {
rune = '0';
} else {
rune += 1;
}
pos += c.__AppEditorViewsEasyMotionVertical_step__;
}
}
// # __AppEditorViewsEasyMotionVertical_moveTo__
fn __AppEditorViewsEasyMotionVertical_moveTo__(pos: u8) !void {
const voy = c.__AppEditorViewsEasyMotionVertical_context_vtable__.*.getOffsetY.?(c.__AppEditorViewsEasyMotionVertical_context__);
if (voy > pos) {
const gtpl = c.__AppEditorViewsEasyMotionVertical_context_vtable__.*.goToPrevLine.?;
var i = voy - pos;
while (i > 0) : (i -= 1) {
gtpl(c.__AppEditorViewsEasyMotionVertical_context__);
}
} else if (voy < pos) {
const gtnl = c.__AppEditorViewsEasyMotionVertical_context_vtable__.*.goToNextLine.?;
var i = pos - voy;
while (i > 0) : (i -= 1) {
gtnl(c.__AppEditorViewsEasyMotionVertical_context__);
}
}
else { // (voy == pos)
}
c.__AppEditorViewsEasyMotionVertical_context_vtable__.*.setAsView.?(c.__AppEditorViewsEasyMotionVertical_context__);
}
// # __AppEditorViewsEasyMotionVertical_onKey__
fn __AppEditorViewsEasyMotionVertical_onKey__(ctx: ?*anyopaque, cik: c.__ConsoleAnsiInputKey__) callconv(.c) void { __zig_fuck__(ctx);
if (cik == c.__ConsoleAnsiInputKey_escape__) {
c.__AppEditorViewsEasyMotionVertical_context_vtable__.*.setAsView.?(c.__AppEditorViewsEasyMotionVertical_context__);
} else if (cik == c.__ConsoleAnsiInputKey_ctrl_q__) {
c.__AppEditor_stop__(&c.__app__.editor);
} else {
const byte: u8 = @truncate(cik);
if (byte >= '0' and byte <= '9') {
const pos: u8 = byte - '0' + ('z' - 'a') + 1;
__AppEditorViewsEasyMotionVertical_moveTo__(pos * @as(u8, @intCast(c.__AppEditorViewsEasyMotionVertical_step__))) catch {};
} else if (byte >= 'a' and byte <= 'z') {
const pos: u8 = byte - 'a';
__AppEditorViewsEasyMotionVertical_moveTo__(pos * @as(u8, @intCast(c.__AppEditorViewsEasyMotionVertical_step__))) catch {};
}
}
}
// # __AppEditorViewsEasyMotionVertical_setAsView__
fn __AppEditorViewsEasyMotionVertical_setAsView__(last_context: *anyopaque, last_vtable: *const c.__AppEditorViewsVTable__) callconv(.c) void {
c.__AppEditorViewsEasyMotionVertical_context__ = last_context;
c.__AppEditorViewsEasyMotionVertical_context_vtable__ = last_vtable;
c.__app__.editor.do_ptr = null;
c.__app__.editor.onKey_ptr = &__AppEditorViewsEasyMotionVertical_onKey__;
c.__app__.editor.current_ctx = null;
__AppEditorViewsEasyMotionVertical_draw__() catch unreachable;
}
// # __AppEditorViewsFind_CtrlShiftLeft__
fn __AppEditorViewsFind_CtrlShiftLeft__(t: *c.__AppEditorViewsFind__) callconv(.c) void {
const line: *c.__AppEditorLine__ = t.line;
if (line.text_len > 0) {
const indent = c.__TextAscii_countIndent__(line.text, line.text_len, 1);
if (t.symbol > indent) {
t.goToSymbol(indent);
} else {
t.goToStartOfLine();
}
} else {
t.goToStartOfLine();
}
t.need_redraw = true;
}
// # __AppEditorViewsFind_CtrlShiftRight__
fn __AppEditorViewsFind_CtrlShiftRight__(t: *c.__AppEditorViewsFind__) callconv(.c) void {
const line: *c.__AppEditorLine__ = t.line;
if (line.text_len > 0) {
const indent = c.__TextAscii_countIndent__(line.text, line.text_len, 1);
if (t.symbol < indent) t.goToSymbol(indent) else t.goToEndOfLine();
t.need_redraw = true;
}
}
// # __AppEditorViewsFind_cancel__
fn __AppEditorViewsFind_cancel__(t: *c.__AppEditorViewsFind__) !void {
t.context_vtable.*.setAsView.?(t.context);
}
// # __AppEditorViewsFind_clearLine__
fn __AppEditorViewsFind_clearLine__(t: *c.__AppEditorViewsFind__) callconv(.c) void {
t.line.text_len = 0;
__AppEditorViewsFind_goToStartOfText__(t);
t.need_redraw = true;
}
// # __AppEditorViewsFind_correctOffset__
fn __AppEditorViewsFind_correctOffset__(t: *c.__AppEditorViewsFind__) callconv(.c) void {
const predel = (c.__app__.terminal.output.size.y >> 1) - (c.__app__.terminal.output.size.y >> 4);
if (t.symbol >= predel) t.offset.x = predel;
}
// # __AppEditorViewsFind_ctrlLeft__
fn __AppEditorViewsFind_ctrlLeft__(t: *c.__AppEditorViewsFind__) callconv(.c) void {
__AppEditorViewsFind_goToPrevSymbol__(t);
if (t.symbol == 0) return;
if (t.line.text_len > 0) {
const line: *c.__AppEditorLine__ = &t.line;
const full_text = line.text[0..line.text_len];
const text = full_text[0 .. t.symbol];
const spaces = c.__TextAscii_countIndentReverse__(text.ptr, text.len, 1);
if (spaces > 0) {
__AppEditorViewsFind_goToSymbol__(t, t.symbol - spaces);
t.need_redraw = true;
return;
}
const dest_pos = c.__TextAscii_findBreakOfWordReverse__(text.ptr, text.len) + 1;
__AppEditorViewsFind_goToSymbol__(t, dest_pos);
} else {
__AppEditorViewsFind_goToSymbol__(t, 0);
}
t.need_redraw = true;
}
// # __AppEditorViewsFind_ctrlRight__
fn __AppEditorViewsFind_ctrlRight__(t: *c.__AppEditorViewsFind__) callconv(.c) void {
__AppEditorViewsFind_goToNextSymbol__(t);
if (t.line.text_len > 0) {
const full_text = t.line.text[0..t.line.text_len];
if (t.symbol >= full_text.len) return;
const text = full_text[t.symbol..];
const indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
if (indent > 0) {
__AppEditorViewsFind_goToSymbol__(t, t.symbol + indent);
t.need_redraw = true;
return;
}
__AppEditorViewsFind_goToSymbol__(t, c.__TextAscii_findBreakOfWord__(text.ptr, text.len) + t.symbol);
t.need_redraw = true;
}
}
// # __AppEditorViewsFind_cursorMoveToCurrent__
fn __AppEditorViewsFind_cursorMoveToCurrent__(t: *c.__AppEditorViewsFind__) !void {
c.__Terminal_cursorMove__(&c.__app__.terminal, t.offset.x, t.offset.y);
}
// # __AppEditorViewsFind_deletePrevSymbol__
fn __AppEditorViewsFind_deletePrevSymbol__(t: *c.__AppEditorViewsFind__) !void {
if (t.symbol == 0) {
return;
} else if (t.symbol > t.line.text_len) {
__AppEditorViewsFind_goToPrevSymbol__(t);
} else {
if (t.line.text_len == 0) return;
__AppEditorViewsFind_goToPrevSymbol__(t);
__AppEditorViewsFind_deleteSymbol__(t);
}
t.need_redraw = true;
}
// # __AppEditorViewsFind_deleteSymbol__
fn __AppEditorViewsFind_deleteSymbol__(t: *c.__AppEditorViewsFind__) callconv(.c) void {
if (t.line.text_len == 0) return;
if (c.__Buffer_pop_check__(t.line.text_len, t.symbol)) {
_=c.__Buffer_pop__(&t.line.text[0], &t.line.text_len, t.symbol);
}
t.need_redraw = true;
}
// # __AppEditorViewsFind_deleteWord__
fn __AppEditorViewsFind_deleteWord__(t: *c.__AppEditorViewsFind__) !void {
if (t.symbol > t.line.text_len) {
return;
}
while (true) { // delete current symbol
if (t.symbol == t.line.text_len) {
break;
}
const next_symbol = t.line.text[t.symbol];
if (c.__TextAscii_isLetter__(next_symbol)) {
__AppEditorViewsFind_deleteSymbol__(t);
} else {
break;
}
}
while (true) { // delete prev symbol
if (t.symbol == 0) {
break;
}
const prev_symbol = t.line.text[t.symbol - 1];
if (c.__TextAscii_isLetter__(prev_symbol)) {
try __AppEditorViewsFind_deletePrevSymbol__(t);
} else {
break;
}
}
t.need_redraw = true;
}
// # __AppEditorViewsFind_do__
fn __AppEditorViewsFind_do__(ctx: *anyopaque) callconv(.c) void {
const t = __AppEditorViewsFind_getModel__(ctx);
if (t.need_redraw == true) {
t.need_redraw = false;
__AppEditorViewsFind_draw__(t) catch unreachable;
__AppEditorViewsFind_cursorMoveToCurrent__(t) catch unreachable;
}
}
// # __AppEditorViewsFind_drawEditedLine__
fn __AppEditorViewsFind_drawEditedLine__(t: *c.__AppEditorViewsFind__) !void {
c.__Terminal_resetColors__(&c.__app__.terminal);
if (t.line.text_len > 0) {
const text = t.line.text[0 .. t.line.text_len];
// draw left-to-right from first visible rune
c.__Terminal_moveCursorToStartOfLine__(&c.__app__.terminal);
var pos: usize = t.symbol - t.offset.x;
var offset_x: usize = 0;
// left arrow
if (pos > 0) { // draw '<'
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_arrows__, c.__AppEditorTheme_arrows__.len);
_=__writeTextToWriteFnVoid__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, "<");
pos += 1;
offset_x += 1;
}
// left symbols
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_current__, c.__AppEditorTheme_current__.len);
while (true) {
if (offset_x >= t.offset.x) break;
if (offset_x >= c.__app__.terminal.output.size.x - 1) break;
if (pos >= text.len) break;
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[pos], 1);
pos += 1;
offset_x += 1;
}
// current symbol. maybe inverse cursour?
if (offset_x < c.__app__.terminal.output.size.x - 2) {
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_current_rune__, c.__AppEditorTheme_current_rune__.len);
if (pos < text.len) {
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[pos], 1);
}
pos += 1;
offset_x += 1;
// right symbols
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_current__, c.__AppEditorTheme_current__.len);
while (true) {
if (offset_x >= c.__app__.terminal.output.size.x - 2) break;
if (pos >= text.len) break;
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[pos], 1);
pos += 1;
offset_x += 1;
}
// right arrow
if (pos < text.len) { // draw '>'
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_arrows__, c.__AppEditorTheme_arrows__.len);
_=__writeTextToWriteFnVoid__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, ">");
} else {
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_to_end_line__, 0);
}
}
} else {
c.__Console_clearLine__(&c.__app__.console);
}
}
// # __AppEditorViewsFind_draw__
fn __AppEditorViewsFind_draw__(t: *c.__AppEditorViewsFind__) !void {
defer __AppEditorViewsFind_cursorMoveToCurrent__(t) catch {};
__AppEditorViewsFind_correctOffset__(t);
if (t.offset.x >= c.__app__.terminal.output.size.x) t.offset.x = 0;
if (t.offset.y >= c.__app__.terminal.output.size.y) t.offset.y = 0;
if (t.symbol < t.offset.x) { // unexpected
t.offset.x = 0;
t.symbol = 0;
}
c.__ConsoleOutput_cursorHide__(&c.__app__.console.output);
defer c.__Console_showCursor__(&c.__app__.console);
t.offset.y = 1;
{ // draw banner
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, 0);
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_headers__, c.__AppEditorTheme_headers__.len);
_=__writeTextToWriteFnVoid__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, "text for find:");
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_to_end_line__, 0);
}
{ // draw edit line
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, 1);
try __AppEditorViewsFind_drawEditedLine__(t);
}
var pos_y: usize = 2;
while (true) { // clear other downer lines
if (pos_y >= c.__app__.terminal.output.size.y) break;
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, pos_y);
c.__Console_clearLine__(&c.__app__.console);
pos_y += 1;
}
}
// # __AppEditorViewsFind_find__
fn __AppEditorViewsFind_find__(t: *c.__AppEditorViewsFind__) !void {
t.context_vtable.*.setAsView.?(t.context);
}
// # __AppEditorViewsFind_getModel__
fn __AppEditorViewsFind_getModel__(ptr: *anyopaque) callconv(.c) *c.__AppEditorViewsFind__ {
return @alignCast(@ptrCast(ptr));
}
// # __AppEditorViewsFind_get__
fn __AppEditorViewsFind_get__(t: *c.__AppEditorViewsFind__) ?[]const u8 {
if (t.*.line.text_len > 0) {
return t.*.line.text[0..t.*.line.text_len];
}
return null;
}
// # __AppEditorViewsFind_goToEndOfLine__
fn goToEndOfLine(t: *c.__AppEditorViewsFind__) callconv(.c) void {
t.symbol = t.line.text_len;
if (t.symbol > c.__app__.terminal.output.size.x - 2) {
t.offset.x = c.__app__.terminal.output.size.x - 2;
} else {
t.offset.x = t.symbol;
}
t.need_redraw = true;
}
// # __AppEditorViewsFind_goToNextSymbol__
fn __AppEditorViewsFind_goToNextSymbol__(t: *c.__AppEditorViewsFind__) callconv(.c) void {
const used = t.line.text_len;
if (t.symbol >= used) {
if (true) return;
if (t.line.next) |_| {
t.goToNextLine();
t.goToStartOfText();
}
return;
}
if (t.symbol < c.__AppEditorLineLen_max__ - 1) t.symbol += 1;
if (used - t.symbol >= 10) {
if (t.offset.x < c.__app__.terminal.output.size.x - 12) t.offset.x += 1;
} else {
if (t.offset.x < c.__app__.terminal.output.size.x - 2) t.offset.x += 1;
}
t.need_redraw = true;
}
// # __AppEditorViewsFind_goToPrevSymbol__
fn __AppEditorViewsFind_goToPrevSymbol__(t: *c.__AppEditorViewsFind__) callconv(.c) void {
const used = t.line.text_len;
if (t.symbol == 0) {
if (true) return;
if (t.line.prev) |_| {
t.goToPrevLine();
t.goToEndOfLine();
}
return;
}
if (t.symbol > used) {
t.symbol = used;
if (used < c.__app__.terminal.output.size.x - 1) t.offset.x = t.line.text_len;
t.need_redraw = true;
return;
}
if (t.symbol > 0) t.symbol -= 1;
if (t.symbol >= 10) {
if (t.offset.x > 10) {
t.offset.x -= 1;
}
} else {
if (t.offset.x > 0) t.offset.x -= 1;
}
t.need_redraw = true;
}
// # __AppEditorViewsFind_goToStartOfLine__
fn __AppEditorViewsFind_goToStartOfLine__(t: *c.__AppEditorViewsFind__) callconv(.c) void {
t.symbol = 0;
t.offset.x = 0;
t.need_redraw = true;
}
// # __AppEditorViewsFind_goToStartOfText__
fn __AppEditorViewsFind_goToStartOfText__(t: *c.__AppEditorViewsFind__) callconv(.c) void {
if (t.line.text_len > 0) {
const indent = c.__TextAscii_countIndent__(&t.line.text[0], t.line.text_len, 1);
__AppEditorViewsFind_goToSymbol__(t, indent);
} else {
__AppEditorViewsFind_goToSymbol__(t, 0);
}
}
// # __AppEditorViewsFind_goToSymbol__
fn __AppEditorViewsFind_goToSymbol__(t: *c.__AppEditorViewsFind__, pos: usize) callconv(.c) void {
t.symbol = pos;
if (t.symbol > c.__app__.terminal.output.size.x - 3) {
t.offset.x = 8;
} else {
t.offset.x = t.symbol;
}
t.need_redraw = true;
}
// # __AppEditorViewsFind_init__
fn __AppEditorViewsFind_init__(t: *c.__AppEditorViewsFind__) !void {
t.offset.x = 0;
t.offset.y = 3;
t.need_redraw = true;
t.symbol = 0;
c.__AppEditorLine_init__(&t.line);
}
// # __AppEditorViewsFind_insertSymbol__
fn __AppEditorViewsFind_insertSymbol__(t: *c.__AppEditorViewsFind__, rune: u8) !void {
if (t.symbol > t.line.text_len) __AppEditorViewsFind_goToSymbol__(t, t.line.text_len);
if (t.line.text_len < c.__AppEditorLineLen_max__) {
c.__Buffer_push__(&t.line.text[0], &t.line.text_len, t.symbol, rune);
__AppEditorViewsFind_goToNextSymbol__(t);
}
t.need_redraw = true;
}
// # __AppEditorViewsFind_onKey__
fn __AppEditorViewsFind_onKey__(t: *c.__AppEditorViewsFind__, cik: c.__ConsoleAnsiInputKey__) callconv(.c) void {
__AppEditorViewsFind_onkeyWrap__(t, cik) catch {};
}
// # __AppEditorViewsFind_onkeyWrap__
fn __AppEditorViewsFind_onkeyWrap__(t: *c.__AppEditorViewsFind__, cik: c.__ConsoleAnsiInputKey__) !void {
switch (cik) {
c.__ConsoleAnsiInputKey_ctrl_left__ => __AppEditorViewsFind_ctrlLeft__(t),
c.__ConsoleAnsiInputKey_ctrl_right__ => __AppEditorViewsFind_ctrlRight__(t),
c.__ConsoleAnsiInputKey_delete__ => __AppEditorViewsFind_deleteSymbol__(t),
c.__ConsoleAnsiInputKey_shift_delete__ => __AppEditorViewsFind_clearLine__(t),
c.__ConsoleAnsiInputKey_left__ => __AppEditorViewsFind_goToPrevSymbol__(t),
c.__ConsoleAnsiInputKey_right__ => __AppEditorViewsFind_goToNextSymbol__(t),
c.__ConsoleAnsiInputKey_escape__ => try __AppEditorViewsFind_cancel__(t),
c.__ConsoleAnsiInputKey_ctrl_q__ => try __AppEditorViewsFind_cancel__(t),
c.__ConsoleAnsiInputKey_back_space__ => try __AppEditorViewsFind_deletePrevSymbol__(t),
c.__ConsoleAnsiInputKey_ctrl_bs__ => try __AppEditorViewsFind_deletePrevSymbol__(t),
c.__ConsoleAnsiInputKey_ctrl_j__ => try __AppEditorViewsFind_find__(t),
c.__ConsoleAnsiInputKey_enter__ => try __AppEditorViewsFind_find__(t),
c.__ConsoleAnsiInputKey_ctrl_w__ => try __AppEditorViewsFind_deleteWord__(t),
else => {
const byte: u8 = @truncate(cik);
__AppEditorViewsFind_insertSymbol__(t, byte) catch {};
},
}
}
// # __AppEditorViewsFind_setAsView__
fn __AppEditorViewsFind_setAsView__(t: *c.__AppEditorViewsFind__, last_context: *anyopaque, last_vtable: *const c.__AppEditorViewsVTable__) callconv(.c) void {
t.context = last_context;
t.context_vtable = last_vtable;
c.__app__.editor.do_ptr = @ptrCast(&__AppEditorViewsFind_do__);
c.__app__.editor.onKey_ptr = @ptrCast(&__AppEditorViewsFind_onKey__);
c.__app__.editor.current_ctx = t;
t.need_redraw = true;
}
// # __AppEditorViewsFlatVtable_countLineNum__
fn __AppEditorViewsFlatVtable_countLineNum__(ctx: *anyopaque) callconv(.c) usize {
const view: *c.__AppEditorViewsFlat__ = @alignCast(@ptrCast(ctx));
return __AppEditorViewsFlat_countLineNum__(view, view.line);
}
// # __AppEditorViewsFlatVtable_getOffsetX__
fn __AppEditorViewsFlatVtable_getOffsetX__(ctx: *anyopaque) callconv(.c) usize {
const view: *c.__AppEditorViewsFlat__ = @alignCast(@ptrCast(ctx));
return view.offset.x;
}
// # __AppEditorViewsFlatVtable_getOffsetY__
fn __AppEditorViewsFlatVtable_getOffsetY__(ctx: *anyopaque) callconv(.c) usize {
const view: *c.__AppEditorViewsFlat__ = @alignCast(@ptrCast(ctx));
return view.offset.y;
}
// # __AppEditorViewsFlatVtable_getSymbolPosX__
fn __AppEditorViewsFlatVtable_getSymbolPosX__(ctx: *anyopaque) callconv(.c) usize {
const view: *c.__AppEditorViewsFlat__ = @alignCast(@ptrCast(ctx));
return view.symbol;
}
// # __AppEditorViewsFlatVtable_goToLineFromNumber__
fn __AppEditorViewsFlatVtable_goToLineFromNumber__(ctx: *anyopaque, _num: usize) callconv(.c) void {
const view: *c.__AppEditorViewsFlat__ = @alignCast(@ptrCast(ctx));
return __AppEditorViewsFlat_goToLineFromNumber__(view, _num);
}
// # __AppEditorViewsFlatVtable_goToNextLine__
fn __AppEditorViewsFlatVtable_goToNextLine__(ctx: *anyopaque) callconv(.c) void {
const view: *c.__AppEditorViewsFlat__ = @alignCast(@ptrCast(ctx));
_=__AppEditorViewsFlat_goToNextLine__(view);
}
// # __AppEditorViewsFlatVtable_goToPrevLine__
fn __AppEditorViewsFlatVtable_goToPrevLine__(ctx: *anyopaque) callconv(.c) void {
const view: *c.__AppEditorViewsFlat__ = @alignCast(@ptrCast(ctx));
_=__AppEditorViewsFlat_goToPrevLine__(view);
}
// # __AppEditorViewsFlatVtable_goToSymbolPosX__
fn __AppEditorViewsFlatVtable_goToSymbolPosX__(ctx: *anyopaque, pos: usize) callconv(.c) void {
const view: *c.__AppEditorViewsFlat__ = @alignCast(@ptrCast(ctx));
__AppEditorViewsFlat_goToSymbol__(view, pos);
}
// # __AppEditorViewsFlatVtable_init__
fn __AppEditorViewsFlatVtable_init__(t: *c.__AppEditorViewsVTable__) void {
t.setAsView = @ptrCast(&__AppEditorViewsFlatVtable_setAsView__);
t.goToPrevLine = @ptrCast(&__AppEditorViewsFlatVtable_goToPrevLine__);
t.goToNextLine = @ptrCast(&__AppEditorViewsFlatVtable_goToNextLine__);
t.getOffsetX = @ptrCast(&__AppEditorViewsFlatVtable_getOffsetX__);
t.getOffsetY = @ptrCast(&__AppEditorViewsFlatVtable_getOffsetY__);
t.goToSymbolPosX = @ptrCast(&__AppEditorViewsFlatVtable_goToSymbolPosX__);
t.getSymbolPosX = @ptrCast(&__AppEditorViewsFlatVtable_getSymbolPosX__);
t.countLineNum = @ptrCast(&__AppEditorViewsFlatVtable_countLineNum__);
t.goToLineFromNumber = @ptrCast(&__AppEditorViewsFlatVtable_goToLineFromNumber__);
}
// # __AppEditorViewsFlatVtable_setAsView__
fn __AppEditorViewsFlatVtable_setAsView__(ctx: *anyopaque) callconv(.c) void {
const view: *c.__AppEditorViewsFlat__ = @alignCast(@ptrCast(ctx));
__AppEditorViewsFlat_setAsView__(view) catch unreachable;
c.__app__.editor.current_vtable = &c.__AppEditorViewsVtable_flat__;
}
// # __AppEditorViewsFlat_addIndent__
fn __AppEditorViewsFlat_addIndent__(t: *c.__AppEditorViewsFlat__) !void {
var text: []u8 = "";
if (t.line.text_len > 0) text = t.line.text[0 .. t.line.text_len];
const indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
if (c.__AppEditorLine_setIndent__(t.line, indent + 4) == false) return error.Unexpected;
t.need_redraw = true;
}
// # __AppEditorViewsFlat_addNextLine__
fn __AppEditorViewsFlat_addNextLine__(t: *c.__AppEditorViewsFlat__) !void {
var ok: bool = true;
var new_line: *c.__AppEditorLine__ = undefined;
if ( c.__AppEditorLine_alloc__( @ptrCast(&new_line) ) ) {
c.__AppEditorLine_init__(new_line);
c.__MemList_pushAfter__(&t.lines, &t.line.*.link, &new_line.link);
_=__AppEditorViewsFlat_goToNextLine__(t);
__AppEditorViewsFlat_goToStartOfText__(t);
t.need_redraw = true;
if (!ok) c.__AppEditorLine_free__(new_line);
} else {
ok = false;
}
if (!ok) return error.Unexpected;
}
// # __AppEditorViewsFlat_addPrevLine__
fn __AppEditorViewsFlat_addPrevLine__(t: *c.__AppEditorViewsFlat__) !void {
var ok: bool = true;
var new_line: *c.__AppEditorLine__ = undefined;
if ( c.__AppEditorLine_alloc__( @ptrCast(&new_line) ) ) {
c.__AppEditorLine_init__(new_line);
c.__MemList_pushBefore__(&t.lines, &t.line.*.link, &new_line.link);
_=__AppEditorViewsFlat_goToPrevLine__(t);
__AppEditorViewsFlat_goToStartOfText__(t);
t.need_redraw = true;
if (!ok) c.__AppEditorLine_free__(new_line);
} else {
ok = false;
}
if (!ok) return error.Unexpected;
}
// # __AppEditorViewsFlat_bakupTextOnCurrentLine__
fn __AppEditorViewsFlat_bakupTextOnCurrentLine__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
if (t.line.*.text_len > 0) {
t.bakup_line.text_len = t.line.*.text_len;
c.__Mem_copy__(&t.bakup_line.text[0], &t.line.*.text[0], t.line.*.text_len);
}
}
// # __AppEditorViewsFlat_changeOffsetX__
fn __AppEditorViewsFlat_changeOffsetX__(t: *c.__AppEditorViewsFlat__, pos: usize) callconv(.c) void {
t.offset.x = pos;
__AppEditorViewsFlat_correctOffsetX__(t);
}
// # __AppEditorViewsFlat_clearLine__
fn __AppEditorViewsFlat_clearLine__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
t.line.*.text_len = 0;
__AppEditorViewsFlat_goToStartOfText__(t);
t.need_redraw = true;
}
// # __AppEditorViewsFlat_copyDownIntervals__
fn __AppEditorViewsFlat_copyDownIntervals__(t: *c.__AppEditorViewsFlat__) !void {
const next_line_link: *c.__MemListLink__ = t.line.*.link.next orelse return;
const next_line: *c.__AppEditorLine__ = @fieldParentPtr("link", next_line_link);
try t.copyIntervalsAfterDC(next_line);
try t.copyIntervalsBeforeEQ(next_line);
t.need_redraw = true;
}
// # __AppEditorViewsFlat_copyUpIntervals__
fn __AppEditorViewsFlat_copyUpIntervals__(t: *c.__AppEditorViewsFlat__) !void {
const prev_line_link: *c.__MemListLink__ = t.line.*.link.prev orelse return;
const prev_line: *c.__AppEditorLine__ = @fieldParentPtr("link", prev_line_link);
try t.copyIntervalsAfterDC(prev_line);
try t.copyIntervalsBeforeEQ(prev_line);
t.need_redraw = true;
}
// # __AppEditorViewsFlat_copyWordToFind__
fn __AppEditorViewsFlat_copyWordToFind__(t: *c.__AppEditorViewsFlat__) !void {
const line = t.line;
if (line.*.text_len > 0) {
const text = t.line.*.text[0 .. t.line.*.text_len];
if (t.symbol < line.*.text_len) {
const sow: usize = blk: { // start_of_word
var pos: usize = t.symbol;
while (true) {
if (pos == 0) break;
const prev_symbol = text[pos - 1];
if (c.__TextAscii_isLetter__(prev_symbol) == false) break;
pos -= 1;
}
break :blk pos;
};
const eow: usize = blk: { // end_of_word
var pos: usize = t.symbol;
while (true) {
if (pos >= t.line.*.text_len - 1) {
break;
}
const next_symbol = text[pos + 1];
if (c.__TextAscii_isLetter__(next_symbol) == false) break;
pos += 1;
}
break :blk pos;
};
const word = text[sow .. eow + 1];
{ // copy to find_line
// current word cannot be bigger than __AppEditorLineLen_max__, but when lines size be dynamic allocated then need recheck
const find_line: *c.__AppEditorLine__ = &c.__app__.editor.views.find.line;
find_line.text_len = word.len;
c.__Mem_copy__(&find_line.text[0], word.ptr, word.len);
}
__AppEditor_changeStatus__("word copied");
} else {
__AppEditor_changeStatus__("cursor not an word");
}
}
}
// # __AppEditorViewsFlat_correctOffsetX__
fn __AppEditorViewsFlat_correctOffsetX__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
const tsx = c.__app__.terminal.output.size.x;
if (t.offset.x >= tsx) t.offset.x = 0;
const predel = (tsx >> 1) - (tsx >> 4);
if (t.symbol >= predel) t.offset.x = predel;
}
// # __AppEditorViewsFlat_correctOffsetY__
fn __AppEditorViewsFlat_correctOffsetY__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
// { correct offset_y:
const tsy = c.__app__.terminal.output.size.y;
if (t.offset.y >= tsy) t.offset.y = 0;
if (tsy <= 5) return;
// count downest_lines
var count_to_downest_line: usize = 0;
var line: *c.__MemListLink__ = &t.line.*.link;
while (count_to_downest_line < 5) {
if (line.next) |down_next| {
count_to_downest_line += 1;
line = down_next;
} else {
break;
}
}
if (tsy - t.offset.y < count_to_downest_line) {
t.offset.y = tsy - count_to_downest_line;
}
//}
}
// # __AppEditorViewsFlat_countLineNum__
fn __AppEditorViewsFlat_countLineNum__(t: *c.__AppEditorViewsFlat__, line: *c.__AppEditorLine__) callconv(.c) usize {
_ = t;
var pos: usize = 1;
var link: [*c]c.__MemListLink__ = &line.link;
while (c.__MemListLink_isFirst__(link) == false) { // todo just use while prev
pos += 1;
link = link.*.prev;
}
return pos;
}
// # __AppEditorViewsFlat_ctrlDown__
fn __AppEditorViewsFlat_ctrlDown__ (t: *c.__AppEditorViewsFlat__) callconv(.c) void {
var last_text: []const u8 = "";
if (t.line.*.text_len > 0) last_text = t.line.*.text[0 .. t.line.*.text_len];
const last_indent = c.__TextAscii_countIndent__(last_text.ptr, last_text.len, 1);
while(__AppEditorViewsFlat_goToNextLine__(t)) {
var new_text: []u8 = "";
if (t.line.*.text_len > 0) new_text = t.line.*.text[0 .. t.line.*.text_len];
const new_indent = c.__TextAscii_countIndent__(new_text.ptr, new_text.len, 1);
if (true // line not empty and indent <= last_indent
// line not empty
and new_text.len > new_indent
and c.__TextAscii_isVisible__(new_text[new_indent])
and new_indent <= last_indent
) {
break;
}
}
}
// # __AppEditorViewsFlat_ctrlLeft__
fn __AppEditorViewsFlat_ctrlLeft__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
__AppEditorViewsFlat_goToPrevSymbol__(t);
if (t.symbol > 0) {
const line: *c.__AppEditorLine__ = t.line;
if (line.text_len > 0) {
const text: []u8 = line.text[0 .. t.symbol];
const spaces: usize = c.__TextAscii_countIndentReverse__(text.ptr, text.len, 1);
var dest_pos: usize = 0;
if (spaces > 0) {
dest_pos = t.symbol - spaces;
} else {
dest_pos = c.__TextAscii_findBreakOfWordReverse__(text.ptr, text.len);
if (dest_pos > 0) dest_pos += 1;
}
__AppEditorViewsFlat_goToSymbol__(t, dest_pos);
} else {
__AppEditorViewsFlat_goToSymbol__(t, 0);
}
}
t.need_redraw = true;
}
// # __AppEditorViewsFlat_ctrlRight__
fn __AppEditorViewsFlat_ctrlRight__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
__AppEditorViewsFlat_goToNextSymbol__(t);
if (t.line.*.text_len > 0) {
const full_text = t.line.*.text[0 .. t.line.*.text_len];
if (t.symbol >= full_text.len) return;
const text = full_text[t.symbol..];
const spaces = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
if (spaces > 0) {
__AppEditorViewsFlat_goToSymbol__(t, t.symbol + spaces);
t.need_redraw = true;
return;
}
const dest_pos = c.__TextAscii_findBreakOfWord__(text.ptr, text.len) + t.symbol;
__AppEditorViewsFlat_goToSymbol__(t, dest_pos);
}
t.need_redraw = true;
}
// # __AppEditorViewsFlat_ctrlShiftLeft__
fn __AppEditorViewsFlat_ctrlShiftLeft__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
var text: []u8 = "";
if (t.line.*.text_len > 0) {
text = t.line.*.text[0 .. t.line.*.text_len];
const indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
if (t.symbol > indent) {
__AppEditorViewsFlat_goToSymbol__(t, indent);
} else {
__AppEditorViewsFlat_goToStartOfLine__(t);
}
}
t.need_redraw = true;
}
// # __AppEditorViewsFlat_ctrlShiftRight__
fn __AppEditorViewsFlat_ctrlShiftRight__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
var text: []u8 = "";
if (t.line.*.text_len > 0) {text = t.line.*.text[0 .. t.line.*.text_len];}
const indent: usize = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
if (t.symbol < indent) __AppEditorViewsFlat_goToSymbol__(t, indent) else __AppEditorViewsFlat_goToEndOfLine__(t);
t.need_redraw = true;
}
// # __AppEditorViewsFlat_ctrlUp__
fn __AppEditorViewsFlat_ctrlUp__ (t: *c.__AppEditorViewsFlat__) callconv(.c) void {
var last_text: []u8 = "";
if (t.line.*.text_len > 0) last_text = t.line.*.text[0 .. t.line.*.text_len];
const last_indent = c.__TextAscii_countIndent__(last_text.ptr, last_text.len, 1);
while(__AppEditorViewsFlat_goToPrevLine__(t)) {
var new_text: []u8 = "";
if (t.line.*.text_len > 0) new_text = t.line.*.text[0 .. t.line.*.text_len];
const new_indent = c.__TextAscii_countIndent__(new_text.ptr, new_text.len, 1);
if (true // line not empty and indent <= last_indent
// line not empty
and new_text.len > new_indent
and c.__TextAscii_isVisible__(new_text[new_indent])
//
and new_indent <= last_indent
) {
break;
}
}
}
// # __AppEditorViewsFlat_ctrl_t__
fn __AppEditorViewsFlat_ctrl_t__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
const text = "__scalpi__.__print__(__TRACE__(), )";
for (text) |symbol| {
__AppEditorViewsFlat_insertSymbol__(t, symbol) catch {};
}
__AppEditorViewsFlat_goToPrevSymbol__(t);
}
// # __AppEditorViewsFlat_cursorMoveToCurrent__
fn __AppEditorViewsFlat_cursorMoveToCurrent__(t: *c.__AppEditorViewsFlat__) !void {
c.__Terminal_cursorMove__(&c.__app__.terminal, t.offset.x, t.offset.y);
}
// # __AppEditorViewsFlat_cutLine__
fn __AppEditorViewsFlat_cutLine__(t: *c.__AppEditorViewsFlat__) !void {
var ok: bool = true;
const current_link = &t.line.*.link;
var next_link: *c.__MemListLink__ = undefined;
if (current_link.next) |_next_link| {
next_link = _next_link;
} else if (current_link.prev) |prev_link| {
next_link = prev_link;
} else {
// create prev line
var new_empty_line: *c.__AppEditorLine__ = undefined;
if ( c.__AppEditorLine_alloc__( @ptrCast(&new_empty_line) ) ) {
c.__AppEditorLine_init__(new_empty_line);
c.__MemList_pushFirst__(&t.lines, &new_empty_line.link); {
next_link = &new_empty_line.link;
if (!ok) c.__MemList_pop__(&t.lines, &new_empty_line.link);
}
if (!ok) c.__AppEditorLine_free__(new_empty_line);
} else {
ok = false;
}
}
if (ok) {
// move to cut
c.__MemList_pop__(&t.lines, current_link);
c.__MemList_pushLast__(&t.cutted, current_link);
// update screen
const line: *c.__AppEditorLine__ = @fieldParentPtr("link", next_link);
t.line = line;
t.need_redraw = true;
__AppEditorViewsFlat_bakupTextOnCurrentLine__(t);
}
if (!ok) return error.Unexpected;
}
// # __AppEditorViewsFlat_deleteCutted__
fn __AppEditorViewsFlat_deleteCutted__(t: *c.__AppEditorViewsFlat__) !void {
while (t.cutted.count > 0) {
const link: *c.__MemListLink__ = t.cutted.first orelse unreachable;
c.__MemList_pop__(&t.cutted, link);
const line: *c.__AppEditorLine__ = @fieldParentPtr("link", link);
c.__AppEditorLine_free__(line);
}
__AppEditor_changeStatus__("cutted lines is gone :)");
__AppEditorViewsFlat_cursorMoveToCurrent__(t) catch {};
}
// # __AppEditorViewsFlat_deleteIndent__
fn __AppEditorViewsFlat_deleteIndent__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
_=c.__AppEditorLine_setIndent__(t.line, 0);
t.need_redraw = true;
}
// # __AppEditorViewsFlat_deletePrevSymbol__
fn __AppEditorViewsFlat_deletePrevSymbol__(t: *c.__AppEditorViewsFlat__) !void {
__AppEditorViewsFlat_goToPrevSymbol__(t);
if (t.line.*.text_len > t.symbol) {
__AppEditorViewsFlat_deleteSymbol__(t);
}
t.need_redraw = true;
}
// # __AppEditorViewsFlat_deleteSymbol__
fn __AppEditorViewsFlat_deleteSymbol__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
if (t.line.*.text_len == 0) return;
if (c.__Buffer_pop_check__(t.line.*.text_len, t.symbol)) {
_=c.__Buffer_pop__(&t.line.*.text[0], &t.line.*.text_len, t.symbol);
}
t.need_redraw = true;
}
// # __AppEditorViewsFlat_deleteWord__
fn __AppEditorViewsFlat_deleteWord__(t: *c.__AppEditorViewsFlat__) !void {
if (t.symbol > t.line.*.text_len) {
return;
}
while (true) { // delete current symbol
if (t.symbol == t.line.*.text_len) {
break;
}
const next_symbol = t.line.*.text[t.symbol];
if (c.__TextAscii_isLetter__(next_symbol)) {
__AppEditorViewsFlat_deleteSymbol__(t);
} else {
break;
}
}
while (true) { // delete prev symbol
if (t.symbol == 0) {
break;
}
const prev_symbol = t.line.*.text[t.symbol - 1];
if (c.__TextAscii_isLetter__(prev_symbol)) {
try __AppEditorViewsFlat_deletePrevSymbol__(t);
} else {
break;
}
}
t.need_redraw = true;
}
// # __AppEditorViewsFlat_divideLine__
fn __AppEditorViewsFlat_divideLine__(t: *c.__AppEditorViewsFlat__) !void {
if (t.line.*.text_len > 0) {
const current_text: []u8 = t.line.*.text[0 .. t.line.*.text_len];
const indent = c.__TextAscii_countIndent__(current_text.ptr, current_text.len, 1);
if (t.symbol <= indent) { // just add prev line
const last_symbol = t.symbol;
const last_offset = t.offset.x;
try __AppEditorViewsFlat_addPrevLine__(t);
// copy indent
for (t.line.*.text[0..indent], current_text[0..indent])
|*rune, indent_symbol|
rune.* = indent_symbol
;
t.line.*.text_len = indent;
t.symbol = last_symbol;
t.offset.x = last_offset;
} else if (t.symbol >= t.line.*.text_len) {
try __AppEditorViewsFlat_addNextLine__(t);
// copy indent
if (t.__AppEditorViewsFlat_autoSpace__) {
for (t.line.*.text[0..indent], current_text[0..indent]) |*rune, indent_symbol| rune.* = indent_symbol;
t.line.*.text_len = indent;
}
} else { // separate text to 2 line
const parent = t.line;
const pos = t.symbol;
const copy_text = current_text[pos..];
try __AppEditorViewsFlat_addNextLine__(t);
t.line.*.text_len = indent + current_text.len;
// copy indent
if (t.__AppEditorViewsFlat_autoSpace__) {
for (t.line.*.text[0..indent], current_text[0..indent]) |*rune, indent_symbol| rune.* = indent_symbol;
t.line.*.text_len = indent;
std.mem.copyForwards(u8, t.line.*.text[indent..], copy_text);
parent.*.text_len = pos;
t.line.*.text_len = indent + copy_text.len;
} else {
std.mem.copyForwards(u8, t.line.*.text[0..], copy_text);
parent.*.text_len = pos;
t.line.*.text_len = copy_text.len;
}
}
} else {
try __AppEditorViewsFlat_addNextLine__(t);
}
__AppEditorViewsFlat_goToStartOfText__(t);
t.need_redraw = true;
}
// # __AppEditorViewsFlat_do__
fn __AppEditorViewsFlat_do__(ctx: *anyopaque) callconv(.c) void {
var ok: bool = true;
const t: *c.__AppEditorViewsFlat__ = @alignCast(@ptrCast(ctx));
if (t.need_redraw) {
t.need_redraw = false;
if (__AppEditorViewsFlat_draw__(t)) {
if (__AppEditorViewsFlat_cursorMoveToCurrent__(t)) {
} else |_| {
ok = false;
}
} else |_| {
ok = false;
}
}
if (t.need_draw_line_num) {
t.need_draw_line_num = false;
if (__AppEditorViewsFlat_drawCountLineNum__(t)) {
if (__AppEditorViewsFlat_cursorMoveToCurrent__(t)) {
} else |_| {
ok = false;
}
} else |_| {
ok = false;
}
}
if (!ok) unreachable;
//return ok;
}
// # __AppEditorViewsFlat_drawCountLineNum__
fn __AppEditorViewsFlat_drawCountLineNum__(t: *c.__AppEditorViewsFlat__) !void {
const pos: usize = __AppEditorViewsFlat_countLineNum__(t, t.line);
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, c.__app__.terminal.output.size.y - 1);
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_notification__, c.__AppEditorTheme_notification__.len);
//print("line number = {pos}");
_=__writeTextToWriteFnVoid__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, " line number = ");
_=c.__Text_formatU64__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, pos, 1);
c.__Terminal_resetColors__(&c.__app__.terminal);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_to_end_line__, 0);
try __AppEditorViewsFlat_cursorMoveToCurrent__(t);
t.need_redraw = false;
}
// # __AppEditorViewsFlat_drawDownerLines__
fn __AppEditorViewsFlat_drawDownerLines__(t: *c.__AppEditorViewsFlat__) !void {
// change color
c.__Terminal_resetColors__(&c.__app__.terminal);
var pos_y: usize = t.offset.y + 1;
c.__app__.editor.lines_drawing = pos_y;
if (pos_y >= c.__app__.terminal.output.size.y) return;
var link = &t.line.*.link;
while (true) { // draw
link = link.next orelse break;
const line: *c.__AppEditorLine__ = @fieldParentPtr("link", link);
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, pos_y);
try __AppEditorViewsFlat_drawLine__(t, line);
if (pos_y >= c.__app__.terminal.output.size.y - 1) {
c.__app__.editor.lines_drawing = c.__app__.terminal.output.size.y;
return;
}
pos_y += 1;
}
c.__app__.editor.lines_drawing = pos_y;
c.__Terminal_resetColors__(&c.__app__.terminal);
while (true) { // clear other downer lines
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, pos_y);
c.__Console_clearLine__(&c.__app__.console);
if (pos_y >= c.__app__.terminal.output.size.y - 1) return;
pos_y += 1;
}
}
// # __AppEditorViewsFlat_drawEditedLine__
fn __AppEditorViewsFlat_drawEditedLine__(t: *c.__AppEditorViewsFlat__) !void {
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, t.offset.y);
if (t.line.*.text_len > 0) {
const text = t.line.*.text[0 .. t.line.*.text_len];
try __AppEditorViewsFlat_drawLine__(t, t.line);
const screen_start: usize = t.symbol - t.offset.x; // first visible rune
const screen_end: usize = screen_start + c.__app__.terminal.output.size.x;
// draw left arrow '<'
if (screen_start > 0) {
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, t.offset.y);
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_arrows__, c.__AppEditorTheme_arrows__.len);
_=__writeTextToWriteFnVoid__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, "<");
}
// draw right arrow '>'
if (screen_end < text.len) {
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_arrows__, c.__AppEditorTheme_arrows__.len);
c.__Terminal_cursorMove__(&c.__app__.terminal, c.__app__.terminal.output.size.x - 1, t.offset.y);
_=__writeTextToWriteFnVoid__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, ">");
}
// redraw current symbol
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_current_rune__, c.__AppEditorTheme_current_rune__.len);
c.__Terminal_cursorMove__(&c.__app__.terminal, t.offset.x, t.offset.y);
if (t.symbol < text.len) {
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[t.symbol], 1);
} else {
c.__Terminal_writeToOutput__(&c.__app__.terminal, "#", 1);
}
} else {
c.__Terminal_resetColors__(&c.__app__.terminal);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_line__, 0);
}
}
// # __AppEditorViewsFlat_drawLine__
fn __AppEditorViewsFlat_drawLine__(t: *c.__AppEditorViewsFlat__, line: *c.__AppEditorLine__) !void {
c.__Terminal_moveCursorToStartOfLine__(&c.__app__.terminal);
if (line.text_len > 0) {
const text = line.text[0 .. line.text_len];
// draw left-to-right from first visible rune
const screen_start: usize = t.symbol - t.offset.x; // first visible rune
const screen_end: usize = screen_start + c.__app__.terminal.output.size.x;
if (text.len > screen_start) {
c.__Terminal_resetColors__(&c.__app__.terminal);
var visible_text_ptr: [*c]const u8 = undefined; _=&visible_text_ptr;
var visible_text_len: usize = undefined; _=&visible_text_len;
if (c.__TextAscii_getNonIndent__(&visible_text_ptr, &visible_text_len, text.ptr, text.len)) {
const visible_text: []const u8 = visible_text_ptr[0..visible_text_len];
var is_comment: u8 = 0; // 0 - false, 1 - commentary, 2 - disabled commentary
if (false // comment with space
or std.mem.startsWith(u8, visible_text, "# ")
or std.mem.startsWith(u8, visible_text, "// ")
or std.mem.startsWith(u8, visible_text, "; ")
or std.mem.startsWith(u8, visible_text, "-- ")
) { // is commentary
is_comment = 1;
} else if (false // commant without space
or std.mem.startsWith(u8, visible_text, "#")
or std.mem.startsWith(u8, visible_text, "//")
or std.mem.startsWith(u8, visible_text, ";")
or std.mem.startsWith(u8, visible_text, "--")
) { // is disabled commentary
is_comment = 2;
}
// draw
var text_end: usize = text.len;
if (text.len > screen_end) text_end = screen_end;
const draw_len = text_end - screen_start;
if (is_comment == 2) {
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_disabled__, c.__AppEditorTheme_disabled__.len);
const draw_ptr = &text[screen_start];
c.__Terminal_writeToOutput__(&c.__app__.terminal, draw_ptr, draw_len);
} else if (is_comment == 1) {
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_commentary__, c.__AppEditorTheme_commentary__.len);
const draw_ptr = &text[screen_start];
c.__Terminal_writeToOutput__(&c.__app__.terminal, draw_ptr, draw_len);
} else { // coloring ^_^
var color: [5]u8 = "\x1B[90m".*;
var last_pos: usize = 0;
var pos: usize = 0;
var hash_summ: u8 = 0;
var last_symbol_is_word: bool = false;
while (pos < draw_len) {
const symbol: u8 = text[screen_start + pos];
if (c.__TextAsciiSymbol_isWordSymbol__(symbol)) {
if (last_symbol_is_word == false) {
last_symbol_is_word = true;
color[3] = '0' + ((hash_summ & 0b111));
c.__Terminal_setFontStyle__(&c.__app__.terminal, &color[0], color.len);
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[screen_start + last_pos], pos - last_pos);
last_pos = pos;
hash_summ = 0;
}
hash_summ +%= symbol;
pos += 1;
} else {
color[3] = '0' + ((hash_summ & 0b111));
c.__Terminal_setFontStyle__(&c.__app__.terminal, &color[0], color.len);
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[screen_start + last_pos], pos - last_pos);
last_pos = pos;
hash_summ = symbol;
pos += 1;
if (false) { // spaces
if (symbol == ' ') {
while(pos < draw_len-1) {
if (text[screen_start + pos+1] != ' ') {
break;
}
pos += 1;
}
}
c.__Terminal_setFontStyle__(&c.__app__.terminal, &color[0], color.len);
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[screen_start + last_pos], pos - last_pos);
last_pos = pos;
}
last_symbol_is_word = false;
}
}
if (last_pos < draw_len) {
color[3] = '0' + (hash_summ & 0b111);
c.__Terminal_setFontStyle__(&c.__app__.terminal, &color[0], color.len);
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[screen_start + last_pos], draw_len - last_pos);
}
}
}
}
}
// clear other line space
c.__Terminal_resetColors__(&c.__app__.terminal);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_to_end_line__, 0);
}
// # __AppEditorViewsFlat_drawUpperLines__
fn __AppEditorViewsFlat_drawUpperLines__(t: *c.__AppEditorViewsFlat__) !void {
// change color
c.__Terminal_resetColors__(&c.__app__.terminal);
if (t.offset.y == 0) return;
var pos_y: usize = t.offset.y - 1;
var link = &t.line.*.link;
while (true) { // draw
link = link.prev orelse break;
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, pos_y);
const line: *c.__AppEditorLine__ = @fieldParentPtr("link", link);
try __AppEditorViewsFlat_drawLine__(t, line);
if (pos_y == 0) return;
pos_y -= 1;
}
c.__Terminal_resetColors__(&c.__app__.terminal);
while (true) { // clear other upp lines
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, pos_y);
c.__Console_clearLine__(&c.__app__.console);
if (pos_y == 0) return;
pos_y -= 1;
}
}
// # __AppEditorViewsFlat_draw__
fn __AppEditorViewsFlat_draw__(t: *c.__AppEditorViewsFlat__) !void {
defer __AppEditorViewsFlat_cursorMoveToCurrent__(t) catch {};
__AppEditorViewsFlat_correctOffsetX__(t);
__AppEditorViewsFlat_correctOffsetY__(t);
c.__ConsoleOutput_cursorHide__(&c.__app__.console.output);
defer c.__Console_showCursor__(&c.__app__.console);
// draw edit line
try __AppEditorViewsFlat_drawEditedLine__(t);
// draw other lines
if (c.__app__.terminal.output.size.y <= 1) return;
try __AppEditorViewsFlat_drawUpperLines__(t);
try __AppEditorViewsFlat_drawDownerLines__(t);
}
// # __AppEditorViewsFlat_duplicateLineAndCut__
fn __AppEditorViewsFlat_duplicateLineAndCut__(t: *c.__AppEditorViewsFlat__) !void {
try __AppEditorViewsFlat_duplicateLine__(t);
try __AppEditorViewsFlat_cutLine__(t);
__AppEditor_changeStatus__("copied.");
__AppEditorViewsFlat_cursorMoveToCurrent__(t) catch {};
}
// # __AppEditorViewsFlat_duplicateLine__
fn __AppEditorViewsFlat_duplicateLine__(t: *c.__AppEditorViewsFlat__) !void {
var ok: bool = true;
var copy: *c.__AppEditorLine__ = undefined;
if ( c.__AppEditorLine_alloc__( @ptrCast(©) ) ) {
c.__AppEditorLine_init__(copy);
copy.text_len = t.line.*.text_len;
if (t.line.*.text_len > 0) c.__Mem_copy__(©.text[0], &t.line.*.text[0], t.line.*.text_len);
c.__MemList_pushAfter__(&t.lines, &t.line.*.link, ©.link);
t.line = copy;
t.need_redraw = true;
if (!ok) c.__AppEditorLine_free__(copy);
} else {
ok = false;
}
if (!ok) return error.Unexpected;
}
// # __AppEditorViewsFlat_easyMotionH__
fn __AppEditorViewsFlat_easyMotionH__(t: *c.__AppEditorViewsFlat__) !void {
__AppEditorViewsEasyMotionHorizontal_setAsView__(t, &c.__AppEditorViewsVtable_flat__);
}
// # __AppEditorViewsFlat_easyMotionV__
fn __AppEditorViewsFlat_easyMotionV__(t: *c.__AppEditorViewsFlat__) !void {
__AppEditorViewsEasyMotionVertical_setAsView__(t, &c.__AppEditorViewsVtable_flat__);
}
// # __AppEditorViewsFlat_enterToBlock__
fn __AppEditorViewsFlat_enterToBlock__ (t: *c.__AppEditorViewsFlat__) callconv(.c) void {
var last_text: []u8 = "";
if (t.line.*.text_len > 0) last_text = t.line.*.text[0 .. t.line.*.text_len];
const last_indent = c.__TextAscii_countIndent__(last_text.ptr, last_text.len, 1);
while(__AppEditorViewsFlat_goToNextLine__(t)) {
var new_text: []u8 = "";
if (t.line.*.text_len > 0) new_text = t.line.*.text[0 .. t.line.*.text_len];
const new_indent = c.__TextAscii_countIndent__(new_text.ptr, new_text.len, 1);
if ( true
// line not empty
and new_text.len > new_indent
and c.__TextAscii_isVisible__(new_text[new_indent])
and new_indent != last_indent
) {
break;
}
}
__AppEditorViewsFlat_moveCursorToStartOfLine__(t);
}
// # __AppEditorViewsFlat_externalCopy__
fn __AppEditorViewsFlat_externalCopy__(t: *c.__AppEditorViewsFlat__) !bool {
const path = &c.__app__.editor.__AppEditor_pathToClipboard__[0];
const path_len = c.__app__.editor.__AppEditor_pathToClipboard_len__;
var ok: bool = true;
if (t.cutted.count == 0) {
try __AppEditorViewsFlat_duplicateLine__(t);
try __AppEditorViewsFlat_cutLine__(t);
}
__AppEditor_changeStatus__("saving ...");
if (c.__AppEditorListOfLine_writeToFile__( &t.cutted, path, path_len ) ) {
// print "saved to {clipboard}"
var buffer: [1024]u8 = undefined;
var writed: usize = 0;
writed += __zig_writeToBuffer__(&buffer[writed], "clipboard saved to ");
c.__Mem_copy__(&buffer[writed], path, path_len);
writed += path_len;
__AppEditor_changeStatus__(buffer[0..writed]);
} else {
ok = false;
// print "NOT saved to {clipboard}"
var buffer: [1024]u8 = undefined;
var writed: usize = 0;
writed += __zig_writeToBuffer__(&buffer[writed], "clipboard NOT saved to ");
c.__Mem_copy__(&buffer[writed], path, path_len);
writed += path_len;
__AppEditor_changeStatus__(buffer[0..writed]);
}
t.need_redraw = false;
return ok;
}
// # __AppEditorViewsFlat_externalPaste__
fn __AppEditorViewsFlat_externalPaste__(t: *c.__AppEditorViewsFlat__) !void {
t.__AppEditorViewsFlat_autoSpace__ = false;
var ok: bool = true;
// read file
const path = c.__app__.editor.__AppEditor_pathToClipboard__;
const path_len = c.__app__.editor.__AppEditor_pathToClipboard_len__;
var file: c.__OsFileHandle__ = undefined;
if (c.__OsFile_open__(&file, &path[0], path_len)) {
const file_size: usize = c.__OsFile_getSize__(file);
var file_data: [*]u8 = undefined;
if (c.__OsMem_allocAny__(&file_data, file_size)) {
if (c.__OsFile_readToBuffer__(file, file_data, file_size, 0)) {
// paste
const line = t.line;
try __AppEditorViewsFlat_addPrevLine__(t);
for (file_data[0..file_size]) |rune| { // parse lines
switch (rune) {
13 => {},
10 => {
try __AppEditorViewsFlat_addNextLine__(t);
},
else => {
try __AppEditorViewsFlat_insertSymbol__(t, rune);
},
}
if (!ok) break;
}
if (ok) {
t.line = line;
t.need_redraw = true;
}
} else {
ok = false;
}
c.__OsMem_freeAny__(file_data);
} else {
ok = false;
}
} else {
ok = false;
}
if (!ok) { // print error
c.__Terminal_resetColors__(&c.__app__.terminal);
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_notification__, c.__AppEditorTheme_notification__.len);
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, 0);
_=__writeTextToWriteFnVoid__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, "file ~/clipboard.tmp not reedable.");
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, 1);
_=__writeTextToWriteFnVoid__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, path[0..path_len]);
c.__Terminal_resetColors__(&c.__app__.terminal);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_to_end_line__, 0);
}
t.__AppEditorViewsFlat_autoSpace__ = true;
if (!ok) return error.Unexpected;
}
// # __AppEditorViewsFlat_findNextAndDraw__
fn __AppEditorViewsFlat_findNextAndDraw__(t: *c.__AppEditorViewsFlat__) !void {
try __AppEditorViewsFlat_findNext__(t);
t.need_redraw = true;
t.need_draw_line_num = true;
}
// # __AppEditorViewsFlat_findNext__
fn __AppEditorViewsFlat_findNext__(
t: *c.__AppEditorViewsFlat__
) !void {
const finding_text: []const u8 = __AppEditorViewsFind_get__(&c.__app__.editor.views.find) orelse return;
if (finding_text.len > 0){
var finded: bool = false;
if (t.line.*.text_len > 0) { // try find on current line
const text = t.line.*.text[0 .. t.line.*.text_len];
if (t.symbol < text.len) {
const start_find_pos: usize = t.symbol + 1;
const find_data: [*]const u8 = text.ptr[start_find_pos..];
const find_data_len: usize = text.len - (start_find_pos);
var pos: usize = 0;
if (find_data_len >= finding_text.len and c.__Mem_findFast__(&pos, find_data, find_data_len, finding_text.ptr, finding_text.len)){
t.symbol += pos + 1;
finded = true;
}
}
}
if (finded == false) { // find on next lines
var current: *c.__MemListLink__ = &t.line.*.link;
while (true) {
if (current == t.lines.last) break;
if (current.next) |nl| {
current = nl;
}
const line: *c.__AppEditorLine__ = @fieldParentPtr("link", current);
if (line.text_len > 0) {
var pos: usize = 0;
if (line.text_len >= finding_text.len and c.__Mem_findFast__(&pos, line.text[0..].ptr, line.text_len, finding_text.ptr, finding_text.len)) {
t.line = line;
t.offset.y = (c.__app__.terminal.output.size.y >> 1) + (c.__app__.terminal.output.size.y >> 3);
t.symbol = pos;
__AppEditorViewsFlat_changeOffsetX__(t, pos);
__AppEditorViewsFlat_bakupTextOnCurrentLine__(t);
break;
}
}
}
}
}
}
// # __AppEditorViewsFlat_findPrevAndDraw__
fn __AppEditorViewsFlat_findPrevAndDraw__(t: *c.__AppEditorViewsFlat__) !void {
try __AppEditorViewsFlat_findPrev__(t);
t.need_redraw = true;
t.need_draw_line_num = true;
}
// # __AppEditorViewsFlat_findPrev__
fn __AppEditorViewsFlat_findPrev__(t: *c.__AppEditorViewsFlat__) !void {
const finding_text: []const u8 = __AppEditorViewsFind_get__(&c.__app__.editor.views.find) orelse return;
find_on_current_line: {
var current_text: []u8 = "";
if (t.line.*.text_len > 0) {
current_text = t.line.*.text[0 .. t.line.*.text_len];
} else {
break :find_on_current_line;
}
if (t.symbol > current_text.len) __AppEditorViewsFlat_goToSymbol__(t, current_text.len);
var pos: usize = 0;
if (t.symbol >= finding_text.len and c.__mem_findFastReverse__(&pos, current_text.ptr, t.symbol, finding_text.ptr, finding_text.len)) {
t.symbol = pos;
__AppEditorViewsFlat_changeOffsetX__(t, pos);
__AppEditorViewsFlat_bakupTextOnCurrentLine__(t);
t.need_redraw = true;
t.need_draw_line_num = true;
return;
} else {
break :find_on_current_line;
}
}
var current = &t.line.*.link;
while (true) {
const prev_link = current.prev orelse break;
current = prev_link;
var line: *c.__AppEditorLine__ = @fieldParentPtr("link", current);
var line_text: []u8 = "";
if (line.text_len > 0) {
line_text = line.text[0 .. line.text_len];
} else {
continue;
}
var pos: usize = 0;
if (line_text.len >= finding_text.len and c.__mem_findFastReverse__(&pos, line_text.ptr, line_text.len, finding_text.ptr, finding_text.len)) {
t.line = line;
t.offset.y = (c.__app__.terminal.output.size.y >> 1) - (c.__app__.terminal.output.size.y >> 3);
__AppEditorViewsFlat_goToStartOfText__(t);
t.symbol = pos;
__AppEditorViewsFlat_changeOffsetX__(t, pos);
break;
} else {
continue;
}
}
__AppEditorViewsFlat_bakupTextOnCurrentLine__(t);
}
// # __AppEditorViewsFlat_fold__
fn __AppEditorViewsFlat_fold__(t: *c.__AppEditorViewsFlat__) !void {
const vf = &c.__app__.editor.views.folded;
{ // fold (set links in tree)
var blanked_lines: c.__MemList__ = undefined;
c.__MemList_init__(&blanked_lines);
const tree_root = &vf.lines;
var current: *c.__MemTree__ = tree_root;
while (t.lines.count > 0) {
const next_line_link: *c.__MemListLink__ = t.lines.first.?; // flat link. not null. garanty by count > 0
c.__MemList_pop__(&t.lines, next_line_link);
const next_line: *c.__AppEditorLine__ = @fieldParentPtr("link", next_line_link);
const next_line_tree: *c.__MemTree__ = &next_line.tree;
var next_text: []u8 = "";
if (next_line.text_len > 0) next_text = next_line.text[0 .. next_line.text_len];
const next_indent: usize = c.__TextAscii_countIndent__(next_text.ptr, next_text.len, 1);
const next_non_indent: usize = c.__TextAscii_countNonIndent__(next_text.ptr, next_text.len);
if (next_non_indent == 0) {
c.__MemList_pushLast__(&blanked_lines, next_line_link);
} else {
while (current != tree_root) { // findLineWithLessIndent
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", current);
var line_text: []u8 = "";
if (line.text_len > 0) line_text = line.text[0 .. line.text_len];
const non_indent = c.__TextAscii_countNonIndent__(line_text.ptr, line_text.len);
const indent = c.__TextAscii_countIndent__(line_text.ptr, line_text.len, 1);
if (non_indent != 0 and indent < next_indent) break;
c.__MemTree_getParent__(@ptrCast(¤t), current); // current not null - garanty by loop. current is child of tree_root
}
c.__MemTree_pushChild__(current, next_line_tree);
current = next_line_tree;
while (blanked_lines.count > 0) {
const blank_link: *c.__MemListLink__ = blanked_lines.first.?;
c.__MemList_pop__(&blanked_lines, blank_link);
const blank_line: *c.__AppEditorLine__ = @fieldParentPtr("link", blank_link);
c.__MemTree_pushPrev__(current, &blank_line.tree);
}
}
}
while (blanked_lines.count > 0) {
const blank_link: *c.__MemListLink__ = blanked_lines.first.?; // non nil - garanty by count > 0
c.__MemList_pop__(&blanked_lines, blank_link);
const blank_line: *c.__AppEditorLine__ = @fieldParentPtr("link", blank_link);
c.__MemTree_pushChild__(tree_root, &blank_line.tree);
}
}
{ // changeView
vf.line = t.line;
vf.offset = t.offset;
vf.symbol = t.symbol;
vf.marked_line = t.marked_line;
vf.need_redraw = true;
try __AppEditorViewsFolded_setAsView__(vf);
}
}
// # __AppEditorViewsFlat_goToEndOfLine__
fn __AppEditorViewsFlat_goToEndOfLine__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
t.symbol = t.line.*.text_len;
__AppEditorViewsFlat_changeOffsetX__(t, t.symbol);
t.need_redraw = true;
}
// # __AppEditorViewsFlat_goToFirstLine__
fn __AppEditorViewsFlat_goToFirstLine__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
const link = t.lines.first orelse unreachable;
t.line = @fieldParentPtr("link", link);
t.goToStartOfText();
t.offset.y = (c.__app__.terminal.output.size.y >> 1) - (c.__app__.terminal.output.size.y >> 2);
t.need_redraw = true;
t.bakup();
}
// # __AppEditorViewsFlat_goToLastLine__
fn __AppEditorViewsFlat_goToLastLine__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
const link = t.lines.last orelse unreachable;
t.line = @fieldParentPtr("link", link);
t.goToStartOfText();
t.offset.y = (c.__app__.terminal.output.size.y >> 1) + (c.__app__.terminal.output.size.y >> 2);
t.need_redraw = true;
t.bakup();
}
// # __AppEditorViewsFlat_goToLineFromNumber__
fn __AppEditorViewsFlat_goToLineFromNumber__(t: *c.__AppEditorViewsFlat__, _num: usize) callconv(.c) void {
if (_num == 0) return;
__AppEditorViewsFlat_goToRoot__(t);
var pos: usize = 1;
while (pos < _num and __AppEditorViewsFlat_goToNextLine__(t)) {
pos += 1;
}
var indent: usize = 0;
const text_len = t.line.*.text_len;
if (text_len > 0) {
const text = &t.line.*.text[0];
indent = c.__TextAscii_countIndent__(text, text_len, 1);
}
__AppEditorViewsFlat_goToSymbol__(t, indent);
t.offset.y = c.__app__.terminal.output.size.y >> 1;
__AppEditorViewsFlat_bakupTextOnCurrentLine__(t);
t.need_redraw = true;
}
// # __AppEditorViewsFlat_goToMarked__
fn __AppEditorViewsFlat_goToMarked__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
if (t.marked_line) |mark| {
t.line = mark;
t.need_redraw = true;
__AppEditorViewsFlat_bakupTextOnCurrentLine__(t);
}
}
// # __AppEditorViewsFlat_goToNextLine__
fn __AppEditorViewsFlat_goToNextLine__(t: *c.__AppEditorViewsFlat__) callconv(.c) bool {
var ok: bool = true;
const last_line: *c.__AppEditorLine__ = t.line;
if (@intFromPtr(t.line.*.link.next) != @intFromPtr(c.NULL)) {
const next_link: *c.__MemListLink__ = @ptrCast(t.line.*.link.next);
// set current line to prev line
const next_line: *c.__AppEditorLine__ = @fieldParentPtr("link", next_link);
t.line = next_line;
__AppEditorViewsFlat_bakupTextOnCurrentLine__(t);
t.need_redraw = true;
if (t.offset.y < c.__app__.terminal.output.size.y - 1) t.offset.y += 1;
// if cursor on start of text - move cursor to new start of text
var last_text: []u8 = "";
if (last_line.text_len > 0) {
last_text = last_line.text[0 .. last_line.text_len];
}
if (t.symbol == c.__TextAscii_countIndent__(last_text.ptr, last_text.len, 1)) {
var next_text: []u8 = "";
if (next_line.text_len > 0) next_text = next_line.text[0 .. next_line.text_len];
__AppEditorViewsFlat_goToSymbol__(t, c.__TextAscii_countIndent__(next_text.ptr, next_text.len, 1));
}
} else {
ok = false;
}
return ok;
}
// # __AppEditorViewsFlat_goToNextSymbol__
fn __AppEditorViewsFlat_goToNextSymbol__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
if (t.symbol < t.line.*.text_len) {
// inc symbol
if (t.symbol >= c.__AppEditorLineLen_max__ - 1) return; // todo rewrite lines to use allocator for lines. and remove this check.
t.symbol += 1;
t.need_redraw = true;
__AppEditorViewsFlat_changeOffsetX__(t, t.symbol);
}
}
// # __AppEditorViewsFlat_goToPrevLine__
fn __AppEditorViewsFlat_goToPrevLine__(t: *c.__AppEditorViewsFlat__) callconv(.c) bool {
var ok: bool = true;
const last_line = t.line;
if (@intFromPtr(t.line.*.link.prev) != @intFromPtr(c.NULL)) {
const prev_link: *c.__MemListLink__ = @ptrCast(t.line.*.link.prev);
// set current line to prev line
const prev_line: *c.__AppEditorLine__ = @fieldParentPtr("link", prev_link);
t.need_redraw = true;
t.line = prev_line;
if (t.offset.y > 5) {
t.offset.y -= 1;
}
__AppEditorViewsFlat_bakupTextOnCurrentLine__(t);
// if cursor on start of text - move cursor to new start of text
var last_indent: usize = 0;
if (last_line.*.text_len > 0) {
last_indent = c.__TextAscii_countIndent__(&last_line.*.text[0], last_line.*.text_len, 1);
}
if (t.symbol == last_indent) {
__AppEditorViewsFlat_moveCursorToStartOfLine__(t);
}
} else {
ok = false;
}
return ok;
}
// # __AppEditorViewsFlat_goToPrevSymbol__
fn __AppEditorViewsFlat_goToPrevSymbol__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
const used = t.line.*.text_len;
if (t.symbol > used) {
t.symbol = used;
} else if (t.symbol > 0) {
t.symbol -= 1;
}
__AppEditorViewsFlat_changeOffsetX__(t, t.symbol);
t.need_redraw = true;
}
// # __AppEditorViewsFlat_goToRoot__
fn __AppEditorViewsFlat_goToRoot__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
const first_line_link: *c.__MemListLink__ = t.lines.first orelse unreachable;
const line: *c.__AppEditorLine__ = @fieldParentPtr("link", first_line_link);
t.line = line;
t.offset.y = 5;
__AppEditorViewsFlat_goToStartOfText__(t);
t.need_redraw = true;
__AppEditorViewsFlat_bakupTextOnCurrentLine__(t);
}
// # __AppEditorViewsFlat_goToStartOfLine__
fn __AppEditorViewsFlat_goToStartOfLine__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
t.symbol = 0;
t.offset.x = 0;
t.need_redraw = true;
}
// # __AppEditorViewsFlat_goToStartOfText__
fn __AppEditorViewsFlat_goToStartOfText__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
var text: []u8 = "";
if (t.line.*.text_len > 0) text = t.line.*.text[0 .. t.line.*.text_len];
const indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
__AppEditorViewsFlat_goToSymbol__(t, indent);
}
// # __AppEditorViewsFlat_goToSymbol__
fn __AppEditorViewsFlat_goToSymbol__(t: *c.__AppEditorViewsFlat__, pos: usize) callconv(.c) void {
t.symbol = pos;
__AppEditorViewsFlat_changeOffsetX__(t, t.symbol);
t.need_redraw = true;
}
// # __AppEditorViewsFlat_init__
fn __AppEditorViewsFlat_init__(t: *c.__AppEditorViewsFlat__) !void {
c.__MemList_init__(&t.lines);
c.__MemList_init__(&t.cutted);
c.__AppEditorLine_init__(&t.bakup_line);
t.need_redraw = true;
t.need_draw_line_num = true;
t.marked_line = null;
t.offset = .{ .x = 0, .y = 3 };
t.symbol = 0;
t.__AppEditorViewsFlat_autoSpace__ = true;
// t.line - is setted by outside
}
// # __AppEditorViewsFlat_insertFindedText__
fn __AppEditorViewsFlat_insertFindedText__(t: *c.__AppEditorViewsFlat__) !void {
const text: []const u8 = __AppEditorViewsFind_get__(&c.__app__.editor.views.find) orelse return;
for (text) |rune| {
__AppEditorViewsFlat_insertSymbol__(t, rune) catch {};
}
t.need_redraw = true;
}
// # __AppEditorViewsFlat_insertSymbol__
fn __AppEditorViewsFlat_insertSymbol__(t: *c.__AppEditorViewsFlat__, rune: u8) !void {
if (t.symbol > t.line.*.text_len) __AppEditorViewsFlat_goToSymbol__(t, t.line.*.text_len);
if (t.line.*.text_len < c.__AppEditorLineLen_max__) {
c.__Buffer_push__(&t.line.*.text[0], &t.line.*.text_len, t.symbol, rune);
__AppEditorViewsFlat_goToNextSymbol__(t);
}
t.need_redraw = true;
}
// # __AppEditorViewsFlat_joinLines__
fn __AppEditorViewsFlat_joinLines__(t: *c.__AppEditorViewsFlat__) !void {
//var ok: bool = true
if (@intFromPtr(t.line.*.link.prev) != @intFromPtr(c.NULL)) {
const prev_link: *c.__MemListLink__ = t.line.*.link.prev;
const prev_line: *c.__AppEditorLine__ = @fieldParentPtr("link", prev_link);
if (t.line.*.text_len > 0) {
if (prev_line.text_len > 0) {
// count non indent text len
const prev_indent: usize = c.__Text_countIndent__(&prev_line.text[0], prev_line.text_len, 1);
const prev_non_indent: usize = prev_line.text_len - prev_indent;
if (prev_non_indent > 0) {
const line_indent: usize = c.__Text_countIndent__(&t.line.*.text[0], t.line.*.text_len, 1);
const line_non_indent: usize = t.line.*.text_len - line_indent;
if (line_non_indent > 0) {
// copy text
const space_len: usize = @as(usize, c.__AppEditorLineLen_max__) - prev_line.text_len; // TODO use allocator for realocating. Maybe create virtual lines for too big text?
if (space_len > line_non_indent) { // size checked
const prev_len: usize = prev_line.text_len;
c.__Mem_copy__(&prev_line.text[prev_line.text_len], &t.line.*.text[line_indent], line_non_indent);
prev_line.text_len += line_non_indent;
// delete line
c.__MemList_pop__(&t.lines, &t.line.*.link);
c.__AppEditorLine_free__(t.line);
// replace to prev line
t.line = prev_line;
__AppEditorViewsFlat_goToSymbol__(t, prev_len);
} else {
__AppEditor_changeStatus__("line is too big");
}
} else { // current line text is nil (only spaces)
// remove current line
c.__MemList_pop__(&t.lines, &t.line.*.link);
c.__AppEditorLine_free__(t.line);
// replace to prev line
t.line = prev_line;
__AppEditorViewsFlat_goToSymbol__(t, prev_line.text_len);
}
} else { // prev_text is nil
c.__MemList_pop__(&t.lines, prev_link);
c.__AppEditorLine_free__(prev_line);
}
} else {
c.__MemList_pop__(&t.lines, prev_link);
c.__AppEditorLine_free__(prev_line);
}
} else {
// delete current line
c.__MemList_pop__(&t.lines, &t.line.*.link);
c.__AppEditorLine_free__(t.line);
// replace to prev line
t.line = prev_line;
__AppEditorViewsFlat_goToSymbol__(t, prev_line.text_len);
}
}
t.need_redraw = true;
}
// # __AppEditorViewsFlat_jumpToOutOfBlock__
fn __AppEditorViewsFlat_jumpToOutOfBlock__ (t: *c.__AppEditorViewsFlat__) callconv(.c) void {
var last_text: []u8 = "";
if (t.line.*.text_len > 0) last_text = t.line.*.text[0 .. t.line.*.text_len];
const last_indent = c.__TextAscii_countIndent__(last_text.ptr, last_text.len, 1);
while(__AppEditorViewsFlat_goToPrevLine__(t)) {
var new_text: []u8 = "";
if (t.line.*.text_len > 0) new_text = t.line.*.text[0 .. t.line.*.text_len];
const new_indent = c.__TextAscii_countIndent__(new_text.ptr, new_text.len, 1);
if ( true
// line not empty
and new_text.len > new_indent
and c.__TextAscii_isVisible__(new_text[new_indent])
and new_indent < last_indent
) {
break;
}
}
__AppEditorViewsFlat_moveCursorToStartOfLine__(t);
}
// # __AppEditorViewsFlat_manyIndent__
fn __AppEditorViewsFlat_manyIndent__(t: *c.__AppEditorViewsFlat__) !void { // todo rename to __AppEditorFlat_lessIndent__
var text: []u8 = "";
if (t.line.text_len > 0) text = t.line.text[0 .. t.line.text_len];
const indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
if (indent < 4) return;
if (c.__AppEditorLine_setIndent__(t.line, indent - 4) == false) return error.Unexpected;
t.need_redraw = true;
}
// # __AppEditorViewsFlat_markThisLine__
fn __AppEditorViewsFlat_markThisLine__(t: *c.__AppEditorViewsFlat__) !void {
t.marked_line = t.line;
__AppEditor_changeStatus__("marked.");
}
// # __AppEditorViewsFlat_moveBlockToMarkedOut__
fn __AppEditorViewsFlat_moveBlockToMarkedOut__(t: *c.__AppEditorViewsFlat__) !void {
var ok: bool = true;
const marked = t.marked_line orelse return;
if (marked == t.line) return;
// move
var next_link: *c.__MemListLink__ = undefined; { // select next_link
const current_link = &t.line.*.link;
if (current_link.next) |_next_link| {
next_link = _next_link;
} else if (current_link.prev) |prev_link| {
next_link = prev_link;
} else {
ok = false;
}
}
if (ok) {
const line_link = &t.line.*.link;
c.__MemList_pop__(&t.lines, line_link);
c.__MemList_pushBefore__(&t.lines, &marked.*.link, line_link);
const line: *c.__AppEditorLine__ = @fieldParentPtr("link", next_link);
t.line = line;
t.need_redraw = true;
__AppEditor_changeStatus__("moved to marked.");
}
if (!ok) return error.Unexpected;
}
// # __AppEditorViewsFlat_moveCursorToStartOfLine__
fn __AppEditorViewsFlat_moveCursorToStartOfLine__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
var indent: usize = 0;
if (t.line.*.text.len > 0) {indent = c.__TextAscii_countIndent__(&t.line.*.text[0], t.line.*.text_len, 1);}
__AppEditorViewsFlat_goToSymbol__(t, indent);
}
// # __AppEditorViewsFlat_moveFoldedBlockToMarkedIn__
fn __AppEditorViewsFlat_moveFoldedBlockToMarkedIn__(t: *c.__AppEditorViewsFlat__) !void {
const vf = &c.__app__.editor.views.folded;
try __AppEditorViewsFlat_fold__(t);
try __AppEditorViewsFolded_moveBlockToMarkedInWithAddIndent__(vf);
try __AppEditorViewsFolded_unFold__(vf);
}
// # __AppEditorViewsFlat_onKey__
fn __AppEditorViewsFlat_onKey__(ctx: *c.__AppEditorViewsFlat__, cik: c.__ConsoleAnsiInputKey__) callconv(.c) void {
__AppEditorViewsFlat_onkeyWrap__(ctx, cik) catch {};
}
// # __AppEditorViewsFlat_onkeyWrap__
fn __AppEditorViewsFlat_onkeyWrap__(ctx: ?*anyopaque, cik: c.__ConsoleAnsiInputKey__) !void {
const t: *c.__AppEditorViewsFlat__ = @alignCast(@ptrCast(ctx));
switch (cik) {
c.__ConsoleAnsiInputKey_ctrl_q__ => {c.__AppEditor_stop__(&c.__app__.editor);},
c.__ConsoleAnsiInputKey_ctrl_s__ => {__AppEditorViewsFlat_save__(t) catch {};},
// change view
c.__ConsoleAnsiInputKey_alt_e__ => {try __AppEditorViewsFlat_easyMotionV__(t);},
c.__ConsoleAnsiInputKey_alt_q__ => {try __AppEditorViewsFlat_easyMotionH__(t);},
c.__ConsoleAnsiInputKey_ctrl_e__ => {try __AppEditorViewsFlat_fold__(t);},
c.__ConsoleAnsiInputKey_ctrl_f__ => {__AppEditorViewsFlat_toFind__(t);},
c.__ConsoleAnsiInputKey_ctrl_g__ => {__AppEditorViewsFlat_toGoTo__(t);},
c.__ConsoleAnsiInputKey_alt_5__ => {__AppEditorViewsFlat_toReplace__(t);},
// navigation
// blocks
c.__ConsoleAnsiInputKey_escape__ => {__AppEditorViewsFlat_jumpToOutOfBlock__(t);},
c.__ConsoleAnsiInputKey_tab__ => {__AppEditorViewsFlat_enterToBlock__(t);},
c.__ConsoleAnsiInputKey_alt_0__ => {try __AppEditorViewsFlat_moveBlockToMarkedOut__(t);},
c.__ConsoleAnsiInputKey_alt_9__ => {__AppEditorViewsFlat_moveFoldedBlockToMarkedIn__(t) catch {};},
// lines
c.__ConsoleAnsiInputKey_up__ => {_=__AppEditorViewsFlat_goToPrevLine__(t);},
c.__ConsoleAnsiInputKey_down__ => {_=__AppEditorViewsFlat_goToNextLine__(t);},
c.__ConsoleAnsiInputKey_page_up__ => {__AppEditorViewsFlat_pageUp__(t);},
c.__ConsoleAnsiInputKey_page_down__ => {__AppEditorViewsFlat_pageDown__(t);},
c.__ConsoleAnsiInputKey_alt_g__ => {__AppEditorViewsFlat_goToMarked__(t);},
c.__ConsoleAnsiInputKey_alt_m__ => {try __AppEditorViewsFlat_markThisLine__(t);},
// text
c.__ConsoleAnsiInputKey_left__ => {__AppEditorViewsFlat_goToPrevSymbol__(t);},
c.__ConsoleAnsiInputKey_right__ => {__AppEditorViewsFlat_goToNextSymbol__(t);},
c.__ConsoleAnsiInputKey_ctrl_up__ => {__AppEditorViewsFlat_ctrlUp__(t);},
c.__ConsoleAnsiInputKey_ctrl_down__ => {__AppEditorViewsFlat_ctrlDown__(t);},
c.__ConsoleAnsiInputKey_ctrl_shift_left__ => {__AppEditorViewsFlat_ctrlShiftLeft__(t);},
c.__ConsoleAnsiInputKey_ctrl_shift_right__ => {__AppEditorViewsFlat_ctrlShiftRight__(t);},
c.__ConsoleAnsiInputKey_ctrl_left__ => {__AppEditorViewsFlat_ctrlLeft__(t);},
c.__ConsoleAnsiInputKey_ctrl_right__ => {__AppEditorViewsFlat_ctrlRight__(t);},
c.__ConsoleAnsiInputKey_end__ => {__AppEditorViewsFlat_goToEndOfLine__(t);},
c.__ConsoleAnsiInputKey_home__ => {__AppEditorViewsFlat_goToStartOfLine__(t);},
// edit
// blocks
// lines
c.__ConsoleAnsiInputKey_alt_up__ => {try __AppEditorViewsFlat_swapWithUpper__(t);},
c.__ConsoleAnsiInputKey_alt_down__ => {try __AppEditorViewsFlat_swapWithBottom__(t);},
c.__ConsoleAnsiInputKey_shift_delete__ => {__AppEditorViewsFlat_clearLine__(t);},
c.__ConsoleAnsiInputKey_ctrl_d__ => {try __AppEditorViewsFlat_duplicateLine__(t);},
c.__ConsoleAnsiInputKey_enter__ => {__AppEditorViewsFlat_divideLine__(t) catch {};},
c.__ConsoleAnsiInputKey_ctrl_j__ => {try __AppEditorViewsFlat_joinLines__(t);},
c.__ConsoleAnsiInputKey_ctrl_enter__ => {try __AppEditorViewsFlat_joinLines__(t);},
// text
c.__ConsoleAnsiInputKey_alt_6__ => {__AppEditorViewsFlat_replace__(t) catch {};},
c.__ConsoleAnsiInputKey_alt_1__ => {try __AppEditorViewsFlat_copyWordToFind__(t);},
c.__ConsoleAnsiInputKey_alt_2__ => {try __AppEditorViewsFlat_findPrevAndDraw__(t);},
c.__ConsoleAnsiInputKey_alt_3__ => {try __AppEditorViewsFlat_findNextAndDraw__(t);},
c.__ConsoleAnsiInputKey_alt_4__ => {try __AppEditorViewsFlat_insertFindedText__(t);},
c.__ConsoleAnsiInputKey_delete__ => {__AppEditorViewsFlat_deleteSymbol__(t);},
c.__ConsoleAnsiInputKey_ctrl_z__ => {try __AppEditorViewsFlat_restoreTextOnCurrentLine__(t);},
c.__ConsoleAnsiInputKey_ctrl_w__ => {try __AppEditorViewsFlat_deleteWord__(t);},
//c.__ConsoleAnsiInputKey_ctrl_t__ => {__AppEditorViewsFlat_insertSymbol__(t, '\t') catch {};},
c.__ConsoleAnsiInputKey_back_space__ => {try __AppEditorViewsFlat_deletePrevSymbol__(t);},
c.__ConsoleAnsiInputKey_ctrl_bs__ => {try __AppEditorViewsFlat_deletePrevSymbol__(t);},
// copy paste
c.__ConsoleAnsiInputKey_ctrl_x__ => {try __AppEditorViewsFlat_cutLine__(t);},
c.__ConsoleAnsiInputKey_ctrl_c__ => {try __AppEditorViewsFlat_duplicateLineAndCut__(t);},
c.__ConsoleAnsiInputKey_ctrl_v__ => {__AppEditorViewsFlat_pasteLine__(t) catch {};},
c.__ConsoleAnsiInputKey_alt_z__ => {try __AppEditorViewsFlat_deleteCutted__(t);},
c.__ConsoleAnsiInputKey_alt_b__ => {
t.__AppEditorViewsFlat_autoSpace__ = !t.__AppEditorViewsFlat_autoSpace__;
if (t.__AppEditorViewsFlat_autoSpace__) {
__AppEditor_changeStatus__("auto space enabled");
} else {
__AppEditor_changeStatus__("auto space disabled");
}
},
// external
c.__ConsoleAnsiInputKey_alt_c__ => {_=__AppEditorViewsFlat_externalCopy__(t) catch {};},
c.__ConsoleAnsiInputKey_alt_v__ => {__AppEditorViewsFlat_externalPaste__(t) catch {};},
c.__ConsoleAnsiInputKey_ctrl_t__ => __AppEditorViewsFlat_ctrl_t__(t),
else => {
if (cik > 255) return;
const byte: u8 = @truncate(cik);
__AppEditorViewsFlat_insertSymbol__(t, byte) catch {};
t.need_redraw = true;
},
}
}
// # __AppEditorViewsFlat_pageDown__
fn __AppEditorViewsFlat_pageDown__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
var pos: usize = 0;
while (pos < 10) : (pos += 1) {
if (!__AppEditorViewsFlat_goToNextLine__(t)) break;
}
}
// # __AppEditorViewsFlat_pageUp__
fn __AppEditorViewsFlat_pageUp__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
var pos: usize = 0;
while (pos < 10) : (pos += 1) {
if (!__AppEditorViewsFlat_goToPrevLine__(t)) break;
}
}
// # __AppEditorViewsFlat_pasteLine__
fn __AppEditorViewsFlat_pasteLine__(t: *c.__AppEditorViewsFlat__) !void {
if (t.cutted.count == 0) return;
const indent = count_indent: {
var text: []u8 = "";
if (t.line.*.text_len > 0) text = t.line.*.text[0 .. t.line.*.text_len];
const current_indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
const prev_line_link: *c.__MemListLink__ = t.line.*.link.prev orelse break :count_indent current_indent;
const prev_line: *c.__AppEditorLine__ = @fieldParentPtr("link", prev_line_link);
var prev_text: []u8 = "";
if (prev_line.text_len > 0) prev_text = prev_line.text[0 .. prev_line.text_len];
const prev_indent = c.__TextAscii_countIndent__(prev_text.ptr, prev_text.len, 1);
break :count_indent @max(current_indent, prev_indent);
};
const link: *c.__MemListLink__ = t.cutted.last orelse unreachable;
c.__MemList_pop__(&t.cutted, link);
c.__MemList_pushBefore__(&t.lines, &t.line.*.link, link);
t.offset.y += 1;
_=__AppEditorViewsFlat_goToPrevLine__(t);
if (c.__AppEditorLine_setIndent__(t.line, indent) == false) return error.Unexpected;
t.need_redraw = true;
}
// # __AppEditorViewsFlat_replace__
fn __AppEditorViewsFlat_replace__(t: *c.__AppEditorViewsFlat__) !void {
const find_line = &c.__app__.editor.views.find.line;
const replace_line = &c.__app__.editor.views.replace.line;
const current_line = t.line;
const check_len = find_line.text_len;
if (true
and current_line.*.text_len - t.symbol >= check_len
and c.__Mem_isEql__(¤t_line.*.text[t.symbol], &find_line.text[0], find_line.text_len)
) {
// delete old text
var pos: usize = 0;
while (pos < check_len):(pos += 1) {
__AppEditorViewsFlat_deleteSymbol__(t);
}
// insert new_text
pos = 0;
while (pos < replace_line.text_len):(pos += 1) {
const rune = replace_line.text[pos];
__AppEditorViewsFlat_insertSymbol__(t, rune) catch {};
}
t.need_redraw = true;
}
}
// # __AppEditorViewsFlat_restoreTextOnCurrentLine__
fn __AppEditorViewsFlat_restoreTextOnCurrentLine__(t: *c.__AppEditorViewsFlat__) !void {
var text: []u8 = "";
if (t.bakup_line.text_len > 0) text = t.bakup_line.text[0 .. t.bakup_line.text_len];
c.__AppEditorLine_setText__(t.line, text.ptr, text.len);
t.need_redraw = true;
}
// # __AppEditorViewsFlat_save__
fn __AppEditorViewsFlat_save__(t: *c.__AppEditorViewsFlat__) !void {
var ok: bool = true;
__AppEditor_changeStatus__("saving ...");
ok = c.__AppEditorListOfLine_writeToFile__(
&t.lines,
&c.__app__.editor.__AppEditor_fileName__[0],
c.__app__.editor.__AppEditor_fileName_len__
);
if (ok) {
__AppEditor_changeStatus__("saved ...");
} else {
__AppEditor_changeStatus__("NOT saved ...");
ok = false;
}
t.need_redraw = false;
if (!ok) return error.Unexpected;
// return ok;
}
// # __AppEditorViewsFlat_setAsView__
fn __AppEditorViewsFlat_setAsView__(t: *c.__AppEditorViewsFlat__) !void {
c.__app__.editor.do_ptr = @ptrCast(&__AppEditorViewsFlat_do__);
c.__app__.editor.onKey_ptr = @ptrCast(&__AppEditorViewsFlat_onKey__);
c.__app__.editor.current_ctx = t;
c.__app__.editor.current_vtable = &c.__AppEditorViewsVtable_flat__;
__AppEditorViewsFlat_bakupTextOnCurrentLine__(t);
t.need_redraw = true;
__AppEditor_changeStatus__("Flat mode.");
__AppEditorViewsFlat_cursorMoveToCurrent__(t) catch {};
}
// # __AppEditorViewsFlat_swapWithBottom__
fn __AppEditorViewsFlat_swapWithBottom__(t: *c.__AppEditorViewsFlat__) !void {
try __AppEditorViewsFlat_cutLine__(t);
var text: []u8 = "";
if (t.line.*.text_len > 0) text = t.line.*.text[0 .. t.line.*.text_len];
const indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
const link: *c.__MemListLink__ = t.cutted.last orelse unreachable;
c.__MemList_pop__(&t.cutted, link);
c.__MemList_pushAfter__(&t.lines, &t.line.*.link, link);
_=__AppEditorViewsFlat_goToNextLine__(t);
if (c.__AppEditorLine_setIndent__(t.line, indent) == false) return error.Unexpected;
t.need_redraw = true;
}
// # __AppEditorViewsFlat_swapWithUpper__
fn __AppEditorViewsFlat_swapWithUpper__(t: *c.__AppEditorViewsFlat__) !void {
if (t.line.*.link.next == null) {
try __AppEditorViewsFlat_cutLine__(t);
try __AppEditorViewsFlat_pasteLine__(t);
} else {
try __AppEditorViewsFlat_cutLine__(t);
_=__AppEditorViewsFlat_goToPrevLine__(t);
try __AppEditorViewsFlat_pasteLine__(t);
}
t.need_redraw = true;
}
// # __AppEditorViewsFlat_toFind__
fn __AppEditorViewsFlat_toFind__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
__AppEditorViewsFind_setAsView__(&c.__app__.editor.views.find, t, &c.__AppEditorViewsVtable_flat__);
}
// # __AppEditorViewsFlat_toGoTo__
fn __AppEditorViewsFlat_toGoTo__(t: *c.__AppEditorViewsFlat__) callconv(.c) void { __zig_fuck__(t);
__AppEditorViewsGoToLine_setAsView__(&c.__app__.editor.views.go_to_line, t, &c.__AppEditorViewsVtable_flat__);
}
// # __AppEditorViewsFlat_toReplace__
fn __AppEditorViewsFlat_toReplace__(t: *c.__AppEditorViewsFlat__) callconv(.c) void {
__AppEditorViewsReplace_setAsView__(&c.__app__.editor.views.replace, t, &c.__AppEditorViewsVtable_flat__);
}
// # __AppEditorViewsFoldedVtable_countLineNum__
fn __AppEditorViewsFoldedVtable_countLineNum__(model: *c.__AppEditorViewsFolded__) callconv(.c) usize {
const view = __AppEditorViewsFoldedVtable_getModel__(model);
return __AppEditorViewsFolded_countLineNum__(view);
}
// # __AppEditorViewsFoldedVtable_getModel__
fn __AppEditorViewsFoldedVtable_getModel__(ptr: *anyopaque) callconv(.c) *c.__AppEditorViewsFolded__ {
const ret_ptr: *c.__AppEditorViewsFolded__ = @ptrFromInt(@intFromPtr(ptr));
return ret_ptr;
}
// # __AppEditorViewsFoldedVtable_getOffsetX__
fn __AppEditorViewsFoldedVtable_getOffsetX__(model: *anyopaque) callconv(.c) usize {
const view = __AppEditorViewsFoldedVtable_getModel__(model);
return view.offset.x;
}
// # __AppEditorViewsFoldedVtable_getOffsetY__
fn __AppEditorViewsFoldedVtable_getOffsetY__(model: *anyopaque) callconv(.c) usize {
const view = __AppEditorViewsFoldedVtable_getModel__(model);
return view.offset.y;
}
// # __AppEditorViewsFoldedVtable_getSymbolPosX__
fn __AppEditorViewsFoldedVtable_getSymbolPosX__(model: *c.__AppEditorViewsFolded__) callconv(.c) usize {
const view = __AppEditorViewsFoldedVtable_getModel__(model);
return view.symbol;
}
// # __AppEditorViewsFoldedVtable_goToLineFromNumber__
fn __AppEditorViewsFoldedVtable_goToLineFromNumber__(ctx: *c.__AppEditorViewsFolded__, _num: usize) callconv(.c) void {
const view = __AppEditorViewsFoldedVtable_getModel__(ctx);
return __AppEditorViewsFolded_goToLineFromNumber__(view, _num);
}
// # __AppEditorViewsFoldedVtable_goToNextLine__
fn __AppEditorViewsFoldedVtable_goToNextLine__(model: *anyopaque) callconv(.c) void {
const view = __AppEditorViewsFoldedVtable_getModel__(model);
__AppEditorViewsFolded_goToNextLine__(view);
}
// # __AppEditorViewsFoldedVtable_goToPrevLine__
fn __AppEditorViewsFoldedVtable_goToPrevLine__(model: *anyopaque) callconv(.c) void {
const view = __AppEditorViewsFoldedVtable_getModel__(model);
__AppEditorViewsFolded_goToPrevLine__(view);
}
// # __AppEditorViewsFoldedVtable_goToSymbolPosX__
fn __AppEditorViewsFoldedVtable_goToSymbolPosX__(model: *anyopaque, pos: usize) callconv(.c) void {
const view = __AppEditorViewsFoldedVtable_getModel__(model);
__AppEditorViewsFolded_goToSymbol__(view, pos);
}
// # __AppEditorViewsFoldedVtable_init__
fn __AppEditorViewsFoldedVtable_init__(t: *c.__AppEditorViewsVTable__) void {
t.setAsView = @ptrCast(&__AppEditorViewsFoldedVtable_setAsView__);
t.goToPrevLine = @ptrCast(&__AppEditorViewsFoldedVtable_goToPrevLine__);
t.goToNextLine = @ptrCast(&__AppEditorViewsFoldedVtable_goToNextLine__);
t.getOffsetX = @ptrCast(&__AppEditorViewsFoldedVtable_getOffsetX__);
t.getOffsetY = @ptrCast(&__AppEditorViewsFoldedVtable_getOffsetY__);
t.goToSymbolPosX = @ptrCast(&__AppEditorViewsFoldedVtable_goToSymbolPosX__);
t.getSymbolPosX = @ptrCast(&__AppEditorViewsFoldedVtable_getSymbolPosX__);
t.countLineNum = @ptrCast(&__AppEditorViewsFoldedVtable_countLineNum__);
t.goToLineFromNumber = @ptrCast(&__AppEditorViewsFoldedVtable_goToLineFromNumber__);
}
// # __AppEditorViewsFoldedVtable_setAsView__
fn __AppEditorViewsFoldedVtable_setAsView__(model: *anyopaque) callconv(.c) void {
const view = __AppEditorViewsFoldedVtable_getModel__(model);
__AppEditorViewsFolded_setAsView__(view) catch unreachable;
c.__app__.editor.current_vtable = &c.__AppEditorViewsVtable_folded__;
}
// # __AppEditorViewsFolded_CtrlShiftLeft__
fn __AppEditorViewsFolded_CtrlShiftLeft__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
const line = t.line;
if (line.*.text_len > 0) {
const indent = c.__TextAscii_countIndent__(&line.*.text[0], line.*.text_len, 1);
if (t.symbol > indent) {
__AppEditorViewsFolded_goToSymbol__(t, indent);
} else {
__AppEditorViewsFolded_goToStartOfLine__(t);
}
t.need_redraw = true;
}
}
// # __AppEditorViewsFolded_CtrlShiftRight__
fn __AppEditorViewsFolded_CtrlShiftRight__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
const line = t.line;
if (line.*.text_len > 0) {
const indent = c.__TextAscii_countIndent__(&line.*.text[0], line.*.text_len, 1);
if (t.symbol < indent) {
__AppEditorViewsFolded_goToSymbol__(t, indent);
} else {
__AppEditorViewsFolded_goToEndOfLine__(t);
}
t.need_redraw = true;
}
}
// # __AppEditorViewsFolded_Line_GetLastByte__
fn __AppEditorViewsFolded_Line_GetLastByte__(t: *c.__AppEditorViewsFolded__, line: *c.__AppEditorLine__) callconv(.c) ?u8 { __zig_fuck__(t);
if (line.text_len < 1) return null;
return line.text[line.text_len - 1];
}
// # __AppEditorViewsFolded_Line_getFirstChildLine__
fn __AppEditorViewsFolded_Line_getFirstChildLine__(t: *c.__AppEditorViewsFolded__, line: *c.__AppEditorLine__) callconv(.c) ?*c.__AppEditorLine__ { __zig_fuck__(t);
const link: *c.__MemListLink__ = line.tree.childs orelse return null;
const tree: *c.__MemTree__ = @fieldParentPtr("link", link);
return @fieldParentPtr("tree", tree);
}
// # __AppEditorViewsFolded_Line_getFirstSibling__
fn __AppEditorViewsFolded_Line_getFirstSibling__(t: *c.__AppEditorViewsFolded__, line: *c.__AppEditorLine__) callconv(.c) ?*c.__AppEditorLine__ { __zig_fuck__(t);
// maybe return self
const parent = __AppEditorViewsFolded_Line_getFirstChildLine__(t, line) orelse return null;
return __AppEditorViewsFolded_Line_getFirstChildLine__(t, parent) orelse return null;
}
// # __AppEditorViewsFolded_Line_getNearestUncleLine__
fn __AppEditorViewsFolded_Line_getNearestUncleLine__(t: *c.__AppEditorViewsFolded__, line: *c.__AppEditorLine__) callconv(.c) ?*c.__AppEditorLine__ {
var current = line;
while(true) {
const parent = __AppEditorViewsFolded_Line_getParentLine__(t, current) orelse return null;
const uncle = __AppEditorViewsFolded_Line_getNextLine__(t, parent) orelse {
current = parent;
continue;
};
return uncle;
}
}
// # __AppEditorViewsFolded_Line_getNextLine__
fn __AppEditorViewsFolded_Line_getNextLine__(t: *c.__AppEditorViewsFolded__, line: *c.__AppEditorLine__) callconv(.c) ?*c.__AppEditorLine__ { __zig_fuck__(t);
const link: *c.__MemListLink__ = line.tree.link.next orelse return null;
const tree: *c.__MemTree__ = @fieldParentPtr("link", link);
return @fieldParentPtr("tree", tree);
}
// # __AppEditorViewsFolded_Line_getParentLine__
fn __AppEditorViewsFolded_Line_getParentLine__(t: *c.__AppEditorViewsFolded__, line: *c.__AppEditorLine__) callconv(.c) ?*c.__AppEditorLine__ {
if (c.__MemTree_isChild__(@ptrCast(&line.tree))) {
var tree: *c.__MemTree__ = undefined;
c.__MemTree_getParent__(@ptrCast(&tree), &line.tree);
if (tree == &t.lines) return null;
return @fieldParentPtr("tree", tree);
}
return null;
}
// # __AppEditorViewsFolded_Line_getPrevLine__
fn __AppEditorViewsFolded_Line_getPrevLine__(t: *c.__AppEditorViewsFolded__, line: *c.__AppEditorLine__) callconv(.c) ?*c.__AppEditorLine__ {
const link: *c.__MemListLink__ = line.tree.link.prev orelse return null;
const tree: *c.__MemTree__ = @fieldParentPtr("link", link);
if (tree == &t.lines) return null;
return @fieldParentPtr("tree", tree);
}
// # __AppEditorViewsFolded_addIndent__
fn __AppEditorViewsFolded_addIndent__(t: *c.__AppEditorViewsFolded__) !void {
var ok: bool = true;
var indent: usize = 0;
if (t.line.*.text_len > 0) {
indent = c.__TextAscii_countIndent__(&t.line.*.text[0], t.line.*.text_len, 1);
}
if (c.__AppEditorLine_setIndent__(t.line, indent + 4)) {
} else {
ok = false;
}
t.need_redraw = true;
if (!ok) return error.Unexpected;
}
// # __AppEditorViewsFolded_addNextLine__
fn __AppEditorViewsFolded_addNextLine__(t: *c.__AppEditorViewsFolded__) !void {
var status = false;
var new_line: *c.__AppEditorLine__ = undefined;
if ( c.__AppEditorLine_alloc__( @ptrCast(&new_line) ) ) {
c.__AppEditorLine_init__(new_line);
c.__MemTree_pushNext__(&t.line.*.tree, &new_line.tree);
__AppEditorViewsFolded_goToNextLine__(t);
__AppEditorViewsFolded_goToStartOfText__(t);
t.need_redraw = true;
status = true;
if (status == false) c.__AppEditorLine_free__(new_line);
} else {
// TODO debug
}
if (status == false) return error.Unexpected;
}
// # __AppEditorViewsFolded_addPrevLine__
fn __AppEditorViewsFolded_addPrevLine__(t: *c.__AppEditorViewsFolded__) !void {
var ok: bool = true;
var new_line: *c.__AppEditorLine__ = undefined;
if ( c.__AppEditorLine_alloc__( @ptrCast(&new_line) ) ) {
c.__AppEditorLine_init__(new_line);
c.__MemTree_pushPrev__(&t.line.*.tree, &new_line.tree);
__AppEditorViewsFolded_goToPrevLine__(t);
__AppEditorViewsFolded_goToStartOfText__(t);
t.need_redraw = true;
if (!ok) c.__AppEditorLine_free__(new_line);
} else {
ok = true;
}
if (!ok) return error.Unexpected;
}
// # __AppEditorViewsFolded_alt2__
fn __AppEditorViewsFolded_alt2__(t: *c.__AppEditorViewsFolded__) !void {
try __AppEditorViewsFolded_unFold__(t);
const flat = &c.__app__.editor.views.flat;
try __AppEditorViewsFlat_findPrev__(flat);
try __AppEditorViewsFlat_fold__(flat);
}
// # __AppEditorViewsFolded_alt3__
fn __AppEditorViewsFolded_alt3__(t: *c.__AppEditorViewsFolded__) !void {
try __AppEditorViewsFolded_unFold__(t);
const flat = &c.__app__.editor.views.flat;
try __AppEditorViewsFlat_findNext__(flat);
try __AppEditorViewsFlat_fold__(flat);
}
// # __AppEditorViewsFolded_bakup__
fn __AppEditorViewsFolded_bakup__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
t.bakup_line.text_len = t.line.*.text_len;
c.__Mem_copy__(&t.bakup_line.text[0], &t.line.*.text[0], t.line.*.text_len);
}
// # __AppEditorViewsFolded_clearLine__
fn __AppEditorViewsFolded_clearLine__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
t.line.*.text_len = 0;
__AppEditorViewsFolded_goToStartOfText__(t);
t.need_redraw = true;
}
// # __AppEditorViewsFolded_copyWordToFind__
fn __AppEditorViewsFolded_copyWordToFind__(t: *c.__AppEditorViewsFolded__) !void {
if (t.line.*.text_len > 0) {
const text = t.line.*.text[0..t.line.*.text_len];
if (t.symbol < text.len) {
const sow: usize = blk: { // start_of_word
const buffer = t.line.*.text[0..];
var pos: usize = t.symbol;
while (true) {
if (pos == 0) break;
const prev_symbol = buffer[pos - 1];
if (c.__TextAscii_isLetter__(prev_symbol) == false) break;
pos -= 1;
}
break :blk pos;
};
const eow: usize = blk: { // end_of_word
const buffer = t.line.*.text[0..];
var pos: usize = t.symbol;
while (true) {
if (pos >= t.line.*.text_len - 1) {
break;
}
const next_symbol = buffer[pos + 1];
if (c.__TextAscii_isLetter__(next_symbol) == false) break;
pos += 1;
}
break :blk pos;
};
const word = t.line.*.text[sow .. eow + 1];
c.__AppEditorLine_setText__(&c.__app__.editor.views.find.line, word.ptr, word.len);
__AppEditor_changeStatus__(word);
} else {
__AppEditor_changeStatus__("cursor not an word");
}
__AppEditorViewsFolded_cursorMoveToCurrent__(t) catch {};
}
}
// # __AppEditorViewsFolded_correctOffsetX__
fn __AppEditorViewsFolded_correctOffsetX__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
const tsx = c.__app__.terminal.output.size.x;
if (t.offset.x >= tsx) t.offset.x = 0;
const predel = (tsx >> 1) - (tsx >> 4);
if (t.symbol >= predel) t.offset.x = predel;
}
// # __AppEditorViewsFolded_correctOffsetY__
fn __AppEditorViewsFolded_correctOffsetY__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
const tsy = c.__app__.terminal.output.size.y;
if (t.offset.y >= tsy) t.offset.y = 0;
if (tsy <= 5) return;
// count downest_lines
var count_to_downest_line: usize = 0;
var current_tree_link: *c.__MemListLink__ = &t.line.*.tree.link;
while (count_to_downest_line < 5) {
count_to_downest_line += 1;
current_tree_link = current_tree_link.next orelse break;
}
if (tsy - t.offset.y < count_to_downest_line) {
t.offset.y = tsy - count_to_downest_line;
}
}
// # __AppEditorViewsFolded_countLineNum__
fn __AppEditorViewsFolded_countLineNum__(t: *c.__AppEditorViewsFolded__) callconv(.c) usize {
var pos: usize = 0;
var current: *c.__MemTree__ = &t.line.*.tree;
while (true) {
if (c.__MemTree_isFirst__(current) == false) {
const prev_tree: *c.__MemTree__ = c.__MemTree_getPrev__(current);
pos += prev_tree.count;
current = prev_tree;
pos += 1;
} else if (c.__MemTree_isChild__(current)) {
c.__MemTree_getParent__(@ptrCast(¤t), current);
pos += 1;
} else {
break;
}
}
return pos;
}
// # __AppEditorViewsFolded_ctrlLeft__
fn __AppEditorViewsFolded_ctrlLeft__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
__AppEditorViewsFolded_goToPrevSymbol__(t);
if (t.symbol > 0) {
var dest_pos: usize = 0;
if (t.line.*.text_len > 0) {
const full_text = t.line.*.text[0..t.line.*.text_len];
const text = full_text[0 .. t.symbol];
const spaces = c.__TextAscii_countIndentReverse__(text.ptr, text.len, 1);
if (spaces > 0) {
dest_pos = t.symbol - spaces;
} else {
dest_pos = c.__TextAscii_findBreakOfWordReverse__(text.ptr, text.len) + 1;
}
}
__AppEditorViewsFolded_goToSymbol__(t, dest_pos);
t.need_redraw = true;
}
}
// # __AppEditorViewsFolded_ctrlRight__
fn __AppEditorViewsFolded_ctrlRight__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
__AppEditorViewsFolded_goToNextSymbol__(t);
if (t.line.*.text_len > 0) {
const full_text = t.line.*.text[0..t.line.*.text_len];
if (t.symbol < full_text.len) {
const text = full_text[t.symbol..];
const indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
if (indent > 0) {
__AppEditorViewsFolded_goToSymbol__(t, t.symbol + indent);
t.need_redraw = true;
return;
}
__AppEditorViewsFolded_goToSymbol__(t, c.__TextAscii_findBreakOfWord__(text.ptr, text.len) + t.symbol);
t.need_redraw = true;
}
}
}
// # __AppEditorViewsFolded_cursorMoveToCurrent__
fn __AppEditorViewsFolded_cursorMoveToCurrent__(t: *c.__AppEditorViewsFolded__) !void {
c.__Terminal_cursorMove__(&c.__app__.terminal, t.offset.x, t.offset.y);
}
// # __AppEditorViewsFolded_cut__
fn __AppEditorViewsFolded_cut__(t: *c.__AppEditorViewsFolded__) !void {
var ok: bool = true;
const current_tree: *c.__MemTree__ = &t.line.*.tree;
var next_tree: *c.__MemTree__ = select: {
if (@intFromPtr(current_tree.link.next) != @intFromPtr(c.NULL)) {
const next_link: *c.__MemListLink__ = current_tree.link.next;
break :select @fieldParentPtr("link", next_link);
} else if (@intFromPtr(current_tree.link.prev) != @intFromPtr(c.NULL)) {
const prev_link: *c.__MemListLink__ = current_tree.link.prev;
break :select @fieldParentPtr("link", prev_link);
} else {
var parent: *c.__MemTree__ = undefined;
c.__MemTree_getParent__(@ptrCast(&parent), current_tree);
break :select @ptrCast(parent);
}
};
if (next_tree == &t.lines) {
// create prev line
var new_empty_line: *c.__AppEditorLine__ = undefined;
if ( c.__AppEditorLine_alloc__( @ptrCast(&new_empty_line) ) ) {
c.__AppEditorLine_init__(new_empty_line);
c.__MemTree_pushPrev__(&t.line.*.tree, &new_empty_line.tree);
// copy indent
var indent: usize = 0;
if (t.line.*.text_len > 0) {
indent = c.__TextAscii_countIndent__(&t.line.*.text[0], t.line.*.text_len, 1);
}
if (c.__AppEditorLine_setIndent__(new_empty_line, indent)) {
// cut current
c.__MemTree_pop__(&t.line.*.tree);
c.__MemTree_pushChild__(&t.cutted, &t.line.*.tree);
// set as next
next_tree = &new_empty_line.tree;
} else {
ok = false;
}
} else {
// TODO debug
ok = false;
}
if (!ok) c.__AppEditorLine_free__(new_empty_line);
}
if (ok) {
// move to cut
c.__MemTree_pop__(current_tree);
c.__MemTree_pushChild__(&t.cutted, current_tree);
// update screen
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", next_tree);
t.line = line;
t.need_redraw = true;
__AppEditorViewsFolded_bakup__(t);
}
if (!ok) return error.Unexpected;
}
// # __AppEditorViewsFolded_deleteCutted__
fn __AppEditorViewsFolded_deleteCutted__(t: *c.__AppEditorViewsFolded__) !void {
var tree_a: *allowzero c.__MemTree__ = c.__MemTree_traverse__(&t.cutted);
while(@intFromPtr(tree_a) != @intFromPtr(c.NULL)) {
if (@intFromPtr(tree_a) == @intFromPtr(&t.cutted)) unreachable;
const tree: *c.__MemTree__ = @ptrCast(tree_a);
const next: *allowzero c.__MemTree__ = c.__MemTree_traverse__(tree);
if (tree.childs.count > 0) {
c.__MemTree_growChilds__(tree); // root skipped by first traverse
}
c.__MemTree_pop__(tree);
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", tree);
c.__AppEditorLine_free__(line);
tree_a = next;
}
// clear t.cutted
t.cutted.childs.count = 0;
t.cutted.childs.first = 0;
t.cutted.childs.last = 0;
t.cutted.count = 0;
__AppEditor_changeStatus__("cutted lines is gone :)");
}
// # __AppEditorViewsFolded_deleteIndent__
fn __AppEditorViewsFolded_deleteIndent__(t: *c.__AppEditorViewsFolded__) !void {
t.need_redraw = true;
if(c.__AppEditorLine_setIndent__(t.line, 0) == false) return error.Unexpected;
// traversal
const start_tree = &t.line.*.tree;
const end_tree_link = start_tree.link.next orelse return;
const end_tree: *c.__MemTree__ = @fieldParentPtr("link", end_tree_link);
var wlkr = start_tree.walker();
while (wlkr.next()) |tree| {
if (tree == end_tree) break;
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", tree);
if(c.__AppEditorLine_setIndent__(line, 0) == false) return error.Unexpected;
}
}
// # __AppEditorViewsFolded_deletePrevSymbol__
fn __AppEditorViewsFolded_deletePrevSymbol__(t: *c.__AppEditorViewsFolded__, ) !void {
if (t.symbol == 0) {
if (t.line.*.tree.childs.count > 0) return;
if (&t.line.*.tree.link == t.lines.childs.first) return;
const prev_link: *c.__MemListLink__ = t.line.*.tree.link.prev orelse return;
const prev_tree: *c.__MemTree__ = @fieldParentPtr("link", prev_link);
const prev_line: *c.__AppEditorLine__ = @fieldParentPtr("tree", prev_tree);
// maybe just delete current line?
const current_line_non_indent: usize = blk: {
var indent: usize = 0;
if (t.line.*.text_len > 0){
indent = c.__TextAscii_countNonIndent__(&t.line.*.text[0], t.line.*.text_len);
}
break :blk indent;
};
if (current_line_non_indent == 0) { // delete t line
const line_to_delete: *c.__AppEditorLine__ = t.line;
const tree_to_delete: *c.__MemTree__ = &line_to_delete.tree;
c.__MemTree_pop__(tree_to_delete);
c.__AppEditorLine_free__(line_to_delete);
t.line = prev_line;
t.need_redraw = true;
__AppEditorViewsFolded_goToEndOfLine__(t);
return;
}
// or just delete prev line
const prev_non_indent: usize = blk: {
var indent: usize = 0;
if (prev_line.text_len > 0) {
indent = c.__TextAscii_countNonIndent__(&prev_line.text[0], prev_line.text_len);
}
break :blk indent;
};
if (prev_non_indent == 0) {
c.__MemTree_pop__(&prev_line.tree);
c.__AppEditorLine_free__(prev_line);
t.need_redraw = true;
return;
}
} else if (t.symbol > t.line.*.text_len) {
__AppEditorViewsFolded_goToPrevSymbol__(t);
} else {
if (t.line.*.text_len == 0) return;
__AppEditorViewsFolded_goToPrevSymbol__(t);
__AppEditorViewsFolded_deleteSymbol__(t);
}
t.need_redraw = true;
}
// # __AppEditorViewsFolded_deleteSymbol__
fn __AppEditorViewsFolded_deleteSymbol__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
if (t.line.*.text_len == 0) return;
if (c.__Buffer_pop_check__(t.line.*.text_len, t.symbol)) {
_=c.__Buffer_pop__(&t.line.*.text[0], &t.line.*.text_len, t.symbol);
}
t.need_redraw = true;
}
// # __AppEditorViewsFolded_deleteWord__
fn __AppEditorViewsFolded_deleteWord__(t: *c.__AppEditorViewsFolded__) !void {
if (t.symbol > t.line.*.text_len) {
return;
}
while (true) { // delete current symbol
if (t.symbol == t.line.*.text_len) {
break;
}
const next_symbol = t.line.*.text[t.symbol];
if (c.__TextAscii_isLetter__(next_symbol)) {
__AppEditorViewsFolded_deleteSymbol__(t);
} else {
break;
}
}
while (true) { // delete prev symbol
if (t.symbol == 0) {
break;
}
const prev_symbol = t.line.*.text[t.symbol - 1];
if (c.__TextAscii_isLetter__(prev_symbol)) {
try __AppEditorViewsFolded_deletePrevSymbol__(t);
} else {
break;
}
}
t.need_redraw = true;
}
// # __AppEditorViewsFolded_divide__
fn __AppEditorViewsFolded_divide__(t: *c.__AppEditorViewsFolded__) !void {
try __AppEditorViewsFolded_unFold__(t);
const flat = &c.__app__.editor.views.flat;
try __AppEditorViewsFlat_divideLine__(flat);
}
// # __AppEditorViewsFolded_doWrap__
fn __AppEditorViewsFolded_doWrap__(ctx: *anyopaque) !void {
const t = __AppEditorViewsFoldedVtable_getModel__(ctx);
if (t.need_redraw == true) {
t.need_redraw = false;
__AppEditorViewsFolded_draw__(t) catch unreachable;
__AppEditorViewsFolded_cursorMoveToCurrent__(t) catch unreachable;
}
if (t.need_draw_line_num) {
t.need_draw_line_num = false;
try __AppEditorViewsFolded_drawCountLineNum__(t);
__AppEditorViewsFolded_cursorMoveToCurrent__(t) catch unreachable;
}
}
// # __AppEditorViewsFolded_do__
fn __AppEditorViewsFolded_do__(ctx: *anyopaque) callconv(.c) void {
__AppEditorViewsFolded_doWrap__(ctx) catch unreachable;
}
// # __AppEditorViewsFolded_drawCountLineNum__
fn __AppEditorViewsFolded_drawCountLineNum__(t: *c.__AppEditorViewsFolded__) !void {
const pos = __AppEditorViewsFolded_countLineNum__(t);
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, c.__app__.terminal.output.size.y - 1);
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_notification__, c.__AppEditorTheme_notification__.len);
// print("line number = {pos}");
const tt: []const u8 = "line_number = ";
c.__Terminal_writeToOutput__(&c.__app__.terminal, tt.ptr, tt.len);
_=c.__Text_formatU64__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, pos, 1);
c.__Terminal_resetColors__(&c.__app__.terminal);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_to_end_line__, 0);
try __AppEditorViewsFolded_cursorMoveToCurrent__(t);
t.need_redraw = false;
}
// # __AppEditorViewsFolded_drawDownerLines__
fn __AppEditorViewsFolded_drawDownerLines__(t: *c.__AppEditorViewsFolded__) !void {
var pos_y: usize = t.offset.y + 1;
c.__app__.editor.lines_drawing = pos_y;
if (pos_y >= c.__app__.terminal.output.size.y) return;
var current_tree = &t.line.*.tree;
while (true) { // draw lines
c.__Terminal_resetColors__(&c.__app__.terminal);
const next_tree_link: *c.__MemListLink__ = current_tree.link.next orelse break;
const next_tree: *c.__MemTree__ = @fieldParentPtr("link", next_tree_link);
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", next_tree);
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, pos_y);
try __AppEditorViewsFolded_drawLine__(t, line);
if (pos_y >= c.__app__.terminal.output.size.y - 1) {
c.__app__.editor.lines_drawing = c.__app__.terminal.output.size.y;
return;
}
pos_y += 1;
current_tree = next_tree;
}
c.__app__.editor.lines_drawing = pos_y;
c.__Terminal_resetColors__(&c.__app__.terminal);
while (true) { // clear other downer lines
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, pos_y);
c.__Console_clearLine__(&c.__app__.console);
if (pos_y >= c.__app__.terminal.output.size.y - 1) return;
pos_y += 1;
}
}
// # __AppEditorViewsFolded_drawEditedLine__
fn __AppEditorViewsFolded_drawEditedLine__(t: *c.__AppEditorViewsFolded__) !void {
const line = t.line;
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, t.offset.y);
// reset color and bold
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_reset__, c.__AppEditorTheme_reset__.len);
c.__Terminal_resetColors__(&c.__app__.terminal);
if (line.*.text_len > 0) {
const text = line.*.text[0 .. line.*.text_len];
try __AppEditorViewsFolded_drawLine__(t, line);
const screen_start: usize = t.symbol - t.offset.x; // first visible rune
const screen_end: usize = screen_start + c.__app__.terminal.output.size.x;
// draw fold indicator
if (t.line.*.tree.childs.count > 0) {
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, t.offset.y);
var symbol: u8 = ' ';
if (screen_start < text.len) {
symbol = text[screen_start];
}
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_folded__, c.__AppEditorTheme_folded__.len);
c.__Terminal_writeToOutput__(&c.__app__.terminal, &symbol, 1);
}
// draw left arrow '<'
if (screen_start != 0) { // this means cursor_pos.x > 0
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, t.offset.y);
if (t.line.*.tree.childs.count > 0) {
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_folded_arrows__, c.__AppEditorTheme_folded_arrows__.len);
} else {
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_arrows__, c.__AppEditorTheme_arrows__.len);
}
c.__Terminal_writeToOutput__(&c.__app__.terminal, "<", 1);
}
// draw right arrow '>'
if (screen_end < text.len) {
c.__Terminal_cursorMove__(&c.__app__.terminal, c.__app__.terminal.output.size.x - 1, t.offset.y);
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_arrows__, c.__AppEditorTheme_arrows__.len);
c.__Terminal_writeToOutput__(&c.__app__.terminal, ">", 1);
}
// current symbol
c.__Terminal_cursorMove__(&c.__app__.terminal, t.offset.x, t.offset.y);
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_current_rune__, c.__AppEditorTheme_current_rune__.len);
if (t.symbol < text.len) {
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[t.symbol], 1);
} else {
c.__Terminal_writeToOutput__(&c.__app__.terminal, " ", 1);
}
} else {
c.__Terminal_resetColors__(&c.__app__.terminal);
c.__Console_clearLine__(&c.__app__.console);
}
}
// # __AppEditorViewsFolded_drawLine__
fn __AppEditorViewsFolded_drawLine__(t: *c.__AppEditorViewsFolded__, line: *c.__AppEditorLine__) !void {
const screen_start: usize = t.symbol - t.offset.x; // first visible rune
const screen_end: usize = screen_start + c.__app__.terminal.output.size.x;
// draw left-to-right from first visible rune
c.__Terminal_moveCursorToStartOfLine__(&c.__app__.terminal);
// reset color and bold
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_reset__, c.__AppEditorTheme_reset__.len);
c.__Terminal_resetColors__(&c.__app__.terminal);
if (line.text_len > screen_start) {
const text = line.text[0 .. line.text_len];
var visible_text_ptr: [*c]const u8 = undefined; _=&visible_text_ptr;
var visible_text_len: usize = undefined; _=&visible_text_len;
if (c.__TextAscii_getNonIndent__(&visible_text_ptr, &visible_text_len, text.ptr, text.len)) {
const visible_text: []const u8 = visible_text_ptr[0..visible_text_len];
if (text.len > screen_start) {
const text_end = if (text.len > screen_end) screen_end else text.len;
const draw_len = text_end - screen_start;
// bold if childs
if (line.tree.childs.count > 0) {
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_folded__, c.__AppEditorTheme_folded__.len);
}
var is_comment: usize = 0;
if (false
or std.mem.startsWith(u8, visible_text, "# ")
or std.mem.startsWith(u8, visible_text, "// ")
or std.mem.startsWith(u8, visible_text, "; ")
or std.mem.startsWith(u8, visible_text, "-- ")
) { // if is commentary
is_comment = 1;
} else if (false
or std.mem.startsWith(u8, visible_text, "#")
or std.mem.startsWith(u8, visible_text, "//")
or std.mem.startsWith(u8, visible_text, ";")
or std.mem.startsWith(u8, visible_text, "--")
) { // if is disabled commentary
is_comment = 2;
}
// draw text
// const to_draw = text[screen_start..text_end];
// c.__Terminal_writeToOutput__(&c.__app__.terminal, to_draw.ptr, to_draw.len);
if (is_comment == 2) {
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_disabled__, c.__AppEditorTheme_disabled__.len);
const draw_ptr = &text[screen_start];
c.__Terminal_writeToOutput__(&c.__app__.terminal, draw_ptr, draw_len);
} else if (is_comment == 1) {
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_commentary__, c.__AppEditorTheme_commentary__.len);
const draw_ptr = &text[screen_start];
c.__Terminal_writeToOutput__(&c.__app__.terminal, draw_ptr, draw_len);
} else { // coloring ^_^
var color: [5]u8 = "\x1B[90m".*;
var last_pos: usize = 0;
var pos: usize = 0;
var hash_summ: u8 = 0;
var last_symbol_is_word: bool = false;
while (pos < draw_len) {
const symbol: u8 = text[screen_start + pos];
if (c.__TextAsciiSymbol_isWordSymbol__(symbol)) {
if (last_symbol_is_word == false) {
last_symbol_is_word = true;
color[3] = '0' + ((hash_summ & 0b111));
c.__Terminal_setFontStyle__(&c.__app__.terminal, &color[0], color.len);
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[screen_start + last_pos], pos - last_pos);
last_pos = pos;
hash_summ = 0;
}
hash_summ +%= symbol;
pos += 1;
} else {
color[3] = '0' + ((hash_summ & 0b111));
c.__Terminal_setFontStyle__(&c.__app__.terminal, &color[0], color.len);
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[screen_start + last_pos], pos - last_pos);
last_pos = pos;
hash_summ = symbol;
pos += 1;
if (false) { // spaces
if (symbol == ' ') {
while(pos < draw_len-1) {
if (text[screen_start + pos+1] != ' ') {
break;
}
pos += 1;
}
}
c.__Terminal_setFontStyle__(&c.__app__.terminal, &color[0], color.len);
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[screen_start + last_pos], pos - last_pos);
last_pos = pos;
}
last_symbol_is_word = false;
}
}
if (last_pos < draw_len) {
color[3] = '0' + (hash_summ & 0b111);
c.__Terminal_setFontStyle__(&c.__app__.terminal, &color[0], color.len);
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[screen_start + last_pos], draw_len - last_pos);
}
}
} else {
// draw "#" if childs
if (line.tree.childs.count > 0) {
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_folded__, c.__AppEditorTheme_folded__.len);
c.__Terminal_writeToOutput__(&c.__app__.terminal, "#", 1);
}
}
}
// clear other
c.__Terminal_resetColors__(&c.__app__.terminal);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_to_end_line__, 0);
// draw folded indicator
if (line.tree.childs.count > 0) {
c.__Terminal_moveCursorToStartOfLine__(&c.__app__.terminal);
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_folded__, c.__AppEditorTheme_folded__.len);
var symbol: u8 = '>';
if (text.len > screen_start) symbol = text[screen_start];
c.__Terminal_writeToOutput__(&c.__app__.terminal, &symbol, 1);
}
// reset color and bold
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_reset__, c.__AppEditorTheme_reset__.len);
c.__Terminal_resetColors__(&c.__app__.terminal);
} else {
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_to_end_line__, 0);
}
}
// # __AppEditorViewsFolded_drawParentLine__
fn __AppEditorViewsFolded_drawParentLine__(t: *c.__AppEditorViewsFolded__, parent: *c.__AppEditorLine__) !void {
c.__Terminal_moveCursorToStartOfLine__(&c.__app__.terminal);
if (parent.text_len > 0) {
const text = parent.text[0.. parent.text_len];
const indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
var symbol: usize = indent;
if (indent >= t.symbol - t.offset.x) {
symbol = t.symbol - t.offset.x;
}
var offset_x: usize = 0;
while (true) {
if (symbol >= text.len) {
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_to_end_line__, 0);
break;
}
if (offset_x >= c.__app__.terminal.output.size.x - 2) break;
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[symbol], 1);
symbol += 1;
offset_x += 1;
}
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_to_end_line__, 0);
} else {
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_to_end_line__, 0);
}
}
// # __AppEditorViewsFolded_drawUpperLines__
fn __AppEditorViewsFolded_drawUpperLines__(t: *c.__AppEditorViewsFolded__) !void {
const nested = t.line.*.tree.nested;
if (t.offset.y == 0) return;
var pos_y: usize = t.offset.y - 1;
var current_tree = &t.line.*.tree;
c.__Terminal_resetColors__(&c.__app__.terminal);
while (true) { // draw lines
// draw upper arrow
const term_1_3 = (c.__app__.terminal.output.size.y >> 3) * 3;
const upperest_line = if (nested > term_1_3) term_1_3 else nested;
if (t.offset.y > upperest_line and pos_y < upperest_line) {
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, pos_y + 1);
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_commentary__, c.__AppEditorTheme_commentary__.len);
c.__Terminal_writeToOutput__(&c.__app__.terminal, "^", 1);
break;
}
//
const prev_tree_link: *c.__MemListLink__ = current_tree.link.prev orelse break;
const prev_tree: *c.__MemTree__ = @fieldParentPtr("link", prev_tree_link);
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", prev_tree);
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, pos_y);
try __AppEditorViewsFolded_drawLine__(t, line);
if (pos_y == 0) return;
pos_y -= 1;
current_tree = prev_tree;
}
// draw headers (parents)
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_headers__, c.__AppEditorTheme_headers__.len);
while (c.__MemTree_isChild__(current_tree)) {
var parent_tree: *c.__MemTree__ = undefined;
c.__MemTree_getParent__(@ptrCast(&parent_tree), current_tree);
if (parent_tree == &t.lines) break;
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", parent_tree);
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, pos_y);
try __AppEditorViewsFolded_drawParentLine__(t, line);
if (pos_y == 0) return;
pos_y -= 1;
current_tree = parent_tree;
}
// clear other up lines
c.__Terminal_resetColors__(&c.__app__.terminal);
while (true) {
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, pos_y);
c.__Console_clearLine__(&c.__app__.console);
if (pos_y == 0) return;
pos_y -= 1;
}
}
// # __AppEditorViewsFolded_draw__
fn __AppEditorViewsFolded_draw__(t: *c.__AppEditorViewsFolded__) !void {
defer __AppEditorViewsFolded_cursorMoveToCurrent__(t) catch {};
__AppEditorViewsFolded_correctOffsetX__(t);
__AppEditorViewsFolded_correctOffsetY__(t);
if (t.symbol < t.offset.x) { // unexpected
unreachable;
//t.offset.x = 0;
//t.symbol = 0;
}
c.__ConsoleOutput_cursorHide__(&c.__app__.console.output);
defer c.__Console_showCursor__(&c.__app__.console);
// draw edit line
try __AppEditorViewsFolded_drawEditedLine__(t);
// draw other lines
if (c.__app__.terminal.output.size.y <= 1) return;
try __AppEditorViewsFolded_drawUpperLines__(t);
try __AppEditorViewsFolded_drawDownerLines__(t);
}
// # __AppEditorViewsFolded_duplicateAndCut__
fn __AppEditorViewsFolded_duplicateAndCut__(t: *c.__AppEditorViewsFolded__) !void {
try __AppEditorViewsFolded_duplicate__(t);
try __AppEditorViewsFolded_cut__(t);
__AppEditor_changeStatus__("copied.");
}
// # __AppEditorViewsFolded_duplicate__
fn __AppEditorViewsFolded_duplicate__(t: *c.__AppEditorViewsFolded__) !void {
// copy roots
const copy_line = try __AppEditorViewsFolded_duplicate_line__(t.line);
const copy_root = ©_line.tree;
c.__MemTree_pushNext__(&t.line.*.tree, copy_root);
// copy trees
var current_tree: *c.__MemTree__ = &t.line.*.tree;
var copy_tree: *c.__MemTree__ = copy_root;
while (true) {
if (@intFromPtr(current_tree.childs.first) != @intFromPtr(c.NULL)) {
const child_link: *c.__MemListLink__ = current_tree.childs.first;
// duplicate
const child_tree: *c.__MemTree__ = @fieldParentPtr("link", child_link);
const child_line: *c.__AppEditorLine__ = @fieldParentPtr("tree", child_tree);
const copy_child_line = try __AppEditorViewsFolded_duplicate_line__(child_line);
// place
const copy_child_tree = ©_child_line.tree;
c.__MemTree_pushChild__(copy_tree, copy_child_tree);
// update currents
current_tree = child_tree;
copy_tree = copy_child_tree;
} else if (@intFromPtr(current_tree.link.next) != @intFromPtr(c.NULL)) {
const next_link: *c.__MemListLink__ = current_tree.link.next;
const next_tree: *c.__MemTree__ = @fieldParentPtr("link", next_link);
if (next_tree == copy_root) break;
// duplicate
const next_line: *c.__AppEditorLine__ = @fieldParentPtr("tree", next_tree);
const copy_next_line = try __AppEditorViewsFolded_duplicate_line__(next_line);
// place
const copy_next_tree = ©_next_line.tree;
c.__MemTree_pushNext__(copy_tree, copy_next_tree);
// update currents
current_tree = next_tree;
copy_tree = copy_next_tree;
} else { // find parent with next
// find parent with next
var next_tree: *c.__MemTree__ = copy_root;
while (true) {
if (@intFromPtr(current_tree.link.next) != @intFromPtr(c.NULL)) {
const next_link: *c.__MemListLink__ = current_tree.link.next;
next_tree = @fieldParentPtr("link", next_link);
break;
}
if (c.__MemTree_isChild__(current_tree)) {
c.__MemTree_getParent__(@ptrCast(¤t_tree), current_tree);
c.__MemTree_getParent__(@ptrCast(©_tree), copy_tree);
} else {
break;
}
}
if (next_tree == copy_root) break;
// duplicate
const next_line: *c.__AppEditorLine__ = @fieldParentPtr("tree", next_tree);
const copy_next_line = try __AppEditorViewsFolded_duplicate_line__(next_line);
// place
const copy_next_tree = ©_next_line.tree;
c.__MemTree_pushNext__(copy_tree, copy_next_tree);
// update currents
current_tree = next_tree;
copy_tree = copy_next_tree;
}
}
// update current working line and screen
t.line = copy_line;
t.need_redraw = true;
}
// # __AppEditorViewsFolded_duplicate_line__
fn __AppEditorViewsFolded_duplicate_line__(line: *c.__AppEditorLine__) !*c.__AppEditorLine__ {
var new_line: *c.__AppEditorLine__ = undefined;
if (c.__AppEditorLine_alloc__( @ptrCast(&new_line) ) ) {
c.__AppEditorLine_init__(new_line);
if (line.text_len > 0) {
const old_text = line.text[0 .. line.text_len];
c.__AppEditorLine_setText__(new_line, old_text.ptr, old_text.len);
}
return new_line;
// if (status == false) c.__AppEditorLine_free__(new_line);
} else {
return error.LineNotAllocated;
}
}
// # __AppEditorViewsFolded_easyMotionH__
fn __AppEditorViewsFolded_easyMotionH__(t: *c.__AppEditorViewsFolded__) !void {
__AppEditorViewsEasyMotionHorizontal_setAsView__(t, &c.__AppEditorViewsVtable_folded__);
}
// # __AppEditorViewsFolded_easyMotionV__
fn __AppEditorViewsFolded_easyMotionV__(t: *c.__AppEditorViewsFolded__) !void {
__AppEditorViewsEasyMotionVertical_setAsView__(t, &c.__AppEditorViewsVtable_folded__);
}
// # __AppEditorViewsFolded_externalCopy__
fn __AppEditorViewsFolded_externalCopy__(t: *c.__AppEditorViewsFolded__) !void {
const path_len = c.__app__.editor.__AppEditor_pathToClipboard_len__;
const path_buffer = c.__app__.editor.__AppEditor_pathToClipboard__;
const path_slice = path_buffer[0..path_len];
const path = &c.__app__.editor.__AppEditor_pathToClipboard__[0];
const tree = &t.cutted;
if (t.cutted.childs.count > 0) {
try __AppEditorViewsFolded_saveTreeToFile__(tree, path_slice, .skip_root);
t.need_redraw = false;
// print "saved to {clipboard}"
var buffer: [1024]u8 = undefined;
var writed: usize = 0;
writed += __zig_writeToBuffer__(&buffer[writed], "clipboard saved to ");
c.__Mem_copy__(&buffer[writed], path, path_len);
writed += path_len;
__AppEditor_changeStatus__(buffer[0..writed]);
} else {
try __AppEditorViewsFolded_saveTreeToFile__(tree, path_slice, .not_skip_root);
// print "saved to {clipboard}"
var buffer: [1024]u8 = undefined;
var writed: usize = 0;
writed += __zig_writeToBuffer__(&buffer[writed], "clipboard saved to ");
c.__Mem_copy__(&buffer[writed], path, path_len);
writed += path_len;
__AppEditor_changeStatus__(buffer[0..writed]);
}
t.need_redraw = false;
}
// # __AppEditorViewsFolded_externalPaste__
fn __AppEditorViewsFolded_externalPaste__(t: *c.__AppEditorViewsFolded__) !void {
var ok: bool = true;
// read file
const path = &c.__app__.editor.__AppEditor_pathToClipboard__[0];
const path_len = c.__app__.editor.__AppEditor_pathToClipboard_len__;
var file: c.__OsFileHandle__ = undefined;
if (c.__OsFile_open__(&file, path, path_len)) {
// read file
const file_size: usize = c.__OsFile_getSize__(file);
var file_data: [*c]u8 = undefined;
if (c.__OsMem_allocAny__(&file_data, file_size)) {
if (c.__OsFile_readToBuffer__(file, file_data, file_size, 0)) {
// paste
const line = t.line;
try __AppEditorViewsFolded_addPrevLine__(t);
for (file_data[0..file_size]) |rune| { // parse lines
switch (rune) {
13 => {},
10 => {try __AppEditorViewsFolded_addNextLine__(t); },
else => {try __AppEditorViewsFolded_insertSymbol__(t, rune); },
}
}
t.line = line;
t.need_redraw = true;
} else {
ok = false;
}
c.__OsMem_freeAny__(file_data);
} else {
ok = false;
}
c.__OsFile_close__(file);
} else {
ok = false;
}
if (!ok) {
t.need_redraw = false;
// print error
{ // moving cursor
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, 0);
{ // set text color
c.__Terminal_resetColors__(&c.__app__.terminal);
c.__Terminal_setFontStyle__(
&c.__app__.terminal,
c.__AppEditorTheme_notification__,
c.__AppEditorTheme_notification__.len
);
{ // write text
const tt: []const u8 = " file ~/clipboard.tmp not reedable.";
c.__Terminal_writeToOutput__(&c.__app__.terminal, tt.ptr, tt.len);
}
c.__Terminal_resetColors__(&c.__app__.terminal);
}
}
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_to_end_line__, 0);
}
if (!ok) return error.Unexpected;
}
// # __AppEditorViewsFolded_findNext__
fn __AppEditorViewsFolded_findNext__(t: *c.__AppEditorViewsFolded__) !void {
const finding_text: []const u8 = c.__app__.editor.views.find.get() orelse return;
if (finding_text.len == 0) {
var finded = true;
if (t.line.text_len > 0) { // try find on current line
const text = t.line.text[0 .. t.line.text_len];
if (t.symbol + 1 <= text.len) {
const data: [*]const u8 = &text[t.symbol + 1];
const data_len: usize = text.len - (t.symbol + 1);
const pos: usize = 0;
if (data_len >= finding_text.len and c.__Mem_findFast__(&pos, data, data_len, finding_text.ptr, finding_text.len)) {
finded = true;
__AppEditorViewsFolded_goToSymbol__(t, t.symbol + pos + 1);
}
}
}
if (finded == false) { // find on next lines
var maybe_current: *allowzero c.__MemTree__ = c.__MemTree_traverse__(&t.line.*.tree);
while (@intFromPtr(maybe_current) != 0) {
{
const current: *c.__MemTree__ = maybe_current.?;
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", current);
if (line.text_len > 0) {
const line_text: []const u8 = line.text[0 .. line.text_len];
const pos: usize = 0;
if (line_text.len >= finding_text.len and c.__Mem_findFast__(&pos, line_text.ptr, line_text.len, finding_text.ptr, finding_text.len)) {
t.line = line;
t.need_redraw = true;
t.offset.y = (c.__app__.terminal.output.size.y >> 1) + (c.__app__.terminal.output.size.y >> 3);
__AppEditorViewsFolded_goToSymbol__(t, pos);
finded = true;
break;
}
}
}
maybe_current = c.__MemTree_traverse__(maybe_current);
}
}
if (finded) {
t.need_redraw = true;
t.bakup();
try __AppEditorViewsFolded_draw__(t);
try __AppEditorViewsFolded_drawCountLineNum__(t);
}
}
}
// # __AppEditorViewsFolded_findPrev__
fn __AppEditorViewsFolded_findPrev__(t: *c.__AppEditorViewsFolded__) !void {
const find_line = &c.__app__.editor.views.find.text;
if (find_line.text_len > 0) {
const finding_text: []const u8 = find_line.text[0 .. find_line.text_len];
{ // find_on_current_line
if (t.line.text_len > 0) {
const current_text: []const u8 = t.line.text[0 .. t.line.text_len];
if (t.symbol > current_text.len) t.goToSymbol(finding_text.len);
var pos: usize = 0;
if (t.symbol >= finding_text.len and c.__mem_findFastReverse__(&pos, current_text.ptr, t.symbol, finding_text.ptr, finding_text.len)) {
__AppEditorViewsFolded_goToSymbol__(t, pos);
__AppEditorViewsFolded_bakup__(t);
t.need_redraw = true;
t.need_draw_line_num = true;
return;
}
}
}
var current = &t.line.*.tree;
while (true) {
const prev_link = current.link.prev orelse return;
const prev_tree: *c.__MemTree__ = @fieldParentPtr("link", prev_link);
current = prev_tree;
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", current);
if (line.text_len > 0) {
const line_text = line.text[0..line.text_len];
var pos: usize = 0;
if (line_text.len >= finding_text and c.__mem_findFastReverse__(&pos, line_text.ptr, line_text.len, finding_text.ptr, finding_text.len)) {
t.line = line;
t.need_redraw = true;
t.goToSymbol(pos);
break;
}
}
}
t.bakup();
try t.draw();
try t.drawCountLineNum();
}
}
// # __AppEditorViewsFolded_fixIndent__
fn __AppEditorViewsFolded_fixIndent__(t: *c.__AppEditorViewsFolded__, first_line: *c.__AppEditorLine__, indent_delta: isize) !void {
if (indent_delta == 0) return;
t.need_redraw = true;
const end_tree: ?*c.__MemTree__ = blk: {
if (__AppEditorViewsFolded_Line_getNextLine__(t, first_line)) |next_line| {
break: blk &next_line.tree;
} else if (__AppEditorViewsFolded_Line_getNearestUncleLine__(t, first_line)) |uncle_line| {
break: blk &uncle_line.tree;
}
break: blk null;
};
var maybe_tree: ?*c.__MemTree__ = &first_line.tree;
while (maybe_tree) |tree| {
if (tree == end_tree) break;
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", tree);
// count indents
var current_indent: usize = 0;
if (line.text_len > 0) {
const line_text = line.text[0..line.text_len];
current_indent = c.__TextAscii_countIndent__(line_text.ptr, line_text.len, 1);
}
const new_indent: usize = blk: {
if (indent_delta > 0) {
break: blk current_indent + @as(usize, @intCast(indent_delta));
} else { // indent_delta < 0
const abs_delta: usize = @intCast(indent_delta * -1);
if (abs_delta > current_indent) {
break: blk 0;
} else { // abs_delta <= current_indent
break: blk current_indent - abs_delta;
}
}
};
if (c.__AppEditorLine_setIndent__(line, new_indent) == false) return error.Unexpected;
maybe_tree = c.__MemTree_traverse__(tree);
}
}
// # __AppEditorViewsFolded_goToEndOfLine__
fn __AppEditorViewsFolded_goToEndOfLine__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
t.symbol = t.line.*.text_len;
if (t.symbol > c.__app__.terminal.output.size.x - 2) {
t.offset.x = c.__app__.terminal.output.size.x - 2;
} else {
t.offset.x = t.symbol;
}
t.need_redraw = true;
}
// # __AppEditorViewsFolded_goToFirstLine__
fn __AppEditorViewsFolded_goToFirstLine__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
const current = &t.line.*.tree;
if (c.__MemTree_isChild__(current)) {
var parent: *c.__MemTree__ = undefined;
c.__MemTree_getParent__(@ptrCast(&parent), current);
const list: *c.__MemList__ = &parent.childs;
const link: *c.__MemListLink__ = list.first orelse unreachable;
const tree: *c.__MemTree__ = @fieldParentPtr("link", link);
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", tree);
t.line = line;
__AppEditorViewsFolded_goToStartOfText__(t);
t.offset.y = (c.__app__.terminal.output.size.y >> 1) - (c.__app__.terminal.output.size.y >> 2);
t.need_redraw = true;
__AppEditorViewsFolded_bakup__(t);
}
}
// # __AppEditorViewsFolded_goToIn__
fn __AppEditorViewsFolded_goToIn__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
const child_tree_link: *c.__MemListLink__ = t.line.*.tree.childs.first orelse return;
const child_tree: *c.__MemTree__ = @fieldParentPtr("link", child_tree_link);
const child: *c.__AppEditorLine__ = @fieldParentPtr("tree", child_tree);
t.line = child;
var child_indent: usize = 0;
if (child.text_len > 0) {
const text = child.text[0..child.text_len];
child_indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
}
__AppEditorViewsFolded_goToSymbol__(t, child_indent);
t.offset.y = (c.__app__.terminal.output.size.y >> 1) - (c.__app__.terminal.output.size.y >> 3);
__AppEditorViewsFolded_bakup__(t);
t.need_redraw = true;
}
// # __AppEditorViewsFolded_goToLastLine__
fn __AppEditorViewsFolded_goToLastLine__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
const current = &t.line.*.tree;
if (c.__MemTree_isChild__(current)) {
var parent: *c.__MemTree__ = undefined;
c.__MemTree_getParent__(@ptrCast(&parent), current);
const list: *c.__MemList__ = &parent.childs;
const link: *c.__MemListLink__ = list.last orelse unreachable;
const tree: *c.__MemTree__ = @fieldParentPtr("link", link);
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", tree);
t.line = line;
__AppEditorViewsFolded_goToStartOfText__(t);
t.offset.y = (c.__app__.terminal.output.size.y >> 1) + (c.__app__.terminal.output.size.y >> 2);
t.need_redraw = true;
__AppEditorViewsFolded_bakup__(t);
}
}
// # __AppEditorViewsFolded_goToLineFromNumber__
fn __AppEditorViewsFolded_goToLineFromNumber__(t: *c.__AppEditorViewsFolded__, _num: usize) callconv(.c) void {
switch (_num) {
0 => {
return;
},
1 => {
const first_link: *c.__MemListLink__ = t.lines.childs.first.?;
const tree_link: *c.__MemTree__ = @fieldParentPtr("link", first_link);
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", tree_link);
t.line = line;
if (t.line.*.text_len > 0) {
const text = t.line.*.text[0..t.line.*.text_len];
__AppEditorViewsFolded_goToSymbol__(t, c.__TextAscii_countIndent__(text.ptr, text.len, 1));
} else {
__AppEditorViewsFolded_goToSymbol__(t, 0);
}
},
else => {
var pos: usize = 1;
const first_link: *c.__MemListLink__ = t.lines.childs.first.?;
var current: *c.__MemTree__ = @fieldParentPtr("link", first_link);
while (true) {
if (_num == pos + current.count) {
const next_link: *c.__MemListLink__ = current.childs.last orelse break;
current = @fieldParentPtr("link", next_link);
break;
}
if (_num > pos + current.count) {
pos += current.count + 1;
const next_link: *c.__MemListLink__ = current.link.next orelse break;
current = @fieldParentPtr("link", next_link);
if (pos >= _num) break;
continue;
}
const link: *c.__MemListLink__ = current.childs.first.?;
current = @fieldParentPtr("link", link);
pos += 1;
if (pos >= _num) break;
}
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", current);
t.line = line;
if (t.line.*.text_len > 0) {
const text = t.line.*.text[0..t.line.*.text_len];
__AppEditorViewsFolded_goToSymbol__(t, c.__TextAscii_countIndent__(text.ptr, text.len, 1));
} else {
__AppEditorViewsFolded_goToSymbol__(t, 0);
}
},
}
t.need_redraw = true;
t.need_draw_line_num = true;
}
// # __AppEditorViewsFolded_goToMarked__
fn __AppEditorViewsFolded_goToMarked__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
if (t.marked_line) |mark| {
t.line = mark;
t.need_redraw = true;
__AppEditorViewsFolded_bakup__(t);
}
}
// # __AppEditorViewsFolded_goToNextComment__
fn __AppEditorViewsFolded_goToNextComment__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
var last_line = t.line;
while (true) {
__AppEditorViewsFolded_goToNextLine__(t);
if (last_line == t.line) break;
last_line = t.line;
if (t.line.*.text_len > 0) {
const text = t.line.*.text[0..t.line.*.text_len];
var visible_text_ptr: [*c]const u8 = undefined; _=&visible_text_ptr;
var visible_text_len: usize = undefined; _=&visible_text_len;
if (c.__TextAscii_getNonIndent__(&visible_text_ptr, &visible_text_len, text.ptr, text.len)) {
const visible_text: []const u8 = visible_text_ptr[0..visible_text_len];
if (std.mem.startsWith(u8, visible_text, "#")) {
break;
} else if (std.mem.startsWith(u8, visible_text, "//")) {
break;
}
}
}
}
t.offset.y = (c.__app__.terminal.output.size.y >> 1) - (c.__app__.terminal.output.size.y >> 2);
}
// # __AppEditorViewsFolded_goToNextLine__
fn __AppEditorViewsFolded_goToNextLine__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
const next_tree_link: *c.__MemListLink__ = t.line.*.tree.link.next orelse return;
const next_tree: *c.__MemTree__ = @fieldParentPtr("link", next_tree_link);
const next: *c.__AppEditorLine__ = @fieldParentPtr("tree", next_tree);
t.line = next;
__AppEditorViewsFolded_bakup__(t);
t.need_redraw = true;
if (t.offset.y < c.__app__.terminal.output.size.y - 1) t.offset.y += 1;
}
// # __AppEditorViewsFolded_goToNextParagraph__
fn __AppEditorViewsFolded_goToNextParagraph__(t: *c.__AppEditorViewsFolded__) !void {
// go to next line while not empty line
while (true) {
__AppEditorViewsFolded_goToNextLine__(t);
if (t.line.*.text_len > 0) {
const text = t.line.*.text[0..t.line.*.text_len];
var visible_text_ptr: [*c]const u8 = undefined; _=&visible_text_ptr;
var visible_text_len: usize = undefined; _=&visible_text_len;
if (c.__TextAscii_getNonIndent__(&visible_text_ptr, &visible_text_len, text.ptr, text.len) == false) break;
if (t.line.*.tree.link.next == null) return;
} else {
break;
}
}
// go to next line while empty line
while (true) {
__AppEditorViewsFolded_goToNextLine__(t);
if (t.line.*.text_len > 0) {
const text = t.line.*.text[0..t.line.*.text_len];
var visible_text_ptr: [*c]const u8 = undefined; _=&visible_text_ptr;
var visible_text_len: usize = undefined; _=&visible_text_len;
if (c.__TextAscii_getNonIndent__(&visible_text_ptr, &visible_text_len, text.ptr, text.len) != false) break;
}
if (t.line.*.tree.link.next == null) return;
}
}
// # __AppEditorViewsFolded_goToNextSymbol__
fn __AppEditorViewsFolded_goToNextSymbol__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
const used = t.line.*.text_len;
// inc symbol
if (t.symbol >= c.__AppEditorLineLen_max__ - 1) return;
if (t.symbol >= used) return;
t.symbol += 1;
t.need_redraw = true;
// inc offset
const rs = c.__app__.terminal.output.size.x - (c.__app__.terminal.output.size.x >> 2);
if (t.offset.x >= rs) return;
t.offset.x += 1;
}
// # __AppEditorViewsFolded_goToOut__
fn __AppEditorViewsFolded_goToOut__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
const parent_tree: *allowzero c.__MemTree__ = c.__MemTree_getParentOrNull__(&t.line.*.tree);
if (@intFromPtr(parent_tree) != @intFromPtr(c.NULL)) {
if (parent_tree == &t.lines) {
__AppEditorViewsFolded_goToRoot__(t);
__AppEditorViewsFolded_bakup__(t);
t.need_redraw = true;
return;
}
const parent: *c.__MemTree__ = @ptrCast(parent_tree);
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", parent);
t.line = line;
var indent: usize = 0;
if (line.text_len > 0) {
const text = line.text[0..line.text_len];
indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
}
__AppEditorViewsFolded_goToSymbol__(t, indent);
t.offset.y = (c.__app__.terminal.output.size.y >> 1) - (c.__app__.terminal.output.size.y >> 3);
__AppEditorViewsFolded_bakup__(t);
t.need_redraw = true;
} else {
return;
}
}
// # __AppEditorViewsFolded_goToPrevComment__
fn __AppEditorViewsFolded_goToPrevComment__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
var last_line = t.line;
while (true) {
__AppEditorViewsFolded_goToPrevLine__(t);
if (last_line == t.line) return;
last_line = t.line;
if (t.line.*.text_len > 0) {
const text = t.line.*.text[0..t.line.*.text_len];
var visible_text_ptr: [*c]const u8 = undefined; _=&visible_text_ptr;
var visible_text_len: usize = undefined; _=&visible_text_len;
if (c.__TextAscii_getNonIndent__(&visible_text_ptr, &visible_text_len, text.ptr, text.len)) {
const visible_text: []const u8 = visible_text_ptr[0..visible_text_len];
if (std.mem.startsWith(u8, visible_text, "#")) {
return;
} else if (std.mem.startsWith(u8, visible_text, "//")) {
return;
}
}
}
}
}
// # __AppEditorViewsFolded_goToPrevLine__
fn __AppEditorViewsFolded_goToPrevLine__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
const prev_tree_link: *c.__MemListLink__ = t.line.*.tree.link.prev orelse return;
const prev_tree: *c.__MemTree__ = @fieldParentPtr("link", prev_tree_link);
const prev: *c.__AppEditorLine__ = @fieldParentPtr("tree", prev_tree);
t.line = prev;
t.need_redraw = true;
if (t.offset.y > 10) {
t.offset.y -= 1;
}
__AppEditorViewsFolded_bakup__(t);
}
// # __AppEditorViewsFolded_goToPrevParagraph__
fn __AppEditorViewsFolded_goToPrevParagraph__(t: *c.__AppEditorViewsFolded__) !void {
while (true) { // go to prev line while empty line
const prev_tree_link: *c.__MemListLink__ = t.line.*.tree.link.prev orelse return;
const prev_tree: *c.__MemTree__ = @fieldParentPtr("link", prev_tree_link);
const prev: *c.__AppEditorLine__ = @fieldParentPtr("tree", prev_tree);
if (prev.text_len > 0) {
const prev_text = prev.text[0..prev.text_len];
var visible_text_ptr: [*c]const u8 = undefined; _=&visible_text_ptr;
var visible_text_len: usize = undefined; _=&visible_text_len;
if (c.__TextAscii_getNonIndent__(&visible_text_ptr, &visible_text_len, prev_text.ptr, prev_text.len)) {
// const visible_text: []const u8 = visible_text_ptr[0..visible_text_len];
break;
}
}
__AppEditorViewsFolded_goToPrevLine__(t);
}
while (true) { // go to prev line while not empty line
const prev_tree_link: *c.__MemListLink__ = t.line.*.tree.link.prev orelse return;
const prev_tree: *c.__MemTree__ = @fieldParentPtr("link", prev_tree_link);
const prev: *c.__AppEditorLine__ = @fieldParentPtr("tree", prev_tree);
if (prev.text_len > 0) {
const prev_text = prev.text[0..prev.text_len];
var visible_text_ptr: [*c]const u8 = undefined; _=&visible_text_ptr;
var visible_text_len: usize = undefined; _=&visible_text_len;
if (c.__TextAscii_getNonIndent__(&visible_text_ptr, &visible_text_len, prev_text.ptr, prev_text.len) == false) break;
__AppEditorViewsFolded_goToPrevLine__(t);
} else {
break;
}
}
}
// # __AppEditorViewsFolded_goToPrevSymbol__
fn __AppEditorViewsFolded_goToPrevSymbol__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
const used = t.line.*.text_len;
// inc symbol
if (t.symbol == 0) return;
if (t.symbol > used) {
t.symbol = used;
if (used < c.__app__.terminal.output.size.x - 1) t.offset.x = t.line.*.text_len;
t.need_redraw = true;
return;
}
if (t.symbol > 0) t.symbol -= 1;
t.need_redraw = true;
// inc offset
const rs = c.__app__.terminal.output.size.x >> 2;
if (t.offset.x == 0) return;
if (t.symbol >= t.offset.x and t.offset.x < rs) return;
t.offset.x -= 1;
}
// # __AppEditorViewsFolded_goToRoot__
fn __AppEditorViewsFolded_goToRoot__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
const r_tree_link: *c.__MemListLink__ = t.lines.childs.first orelse return;
const r_tree: *c.__MemTree__ = @fieldParentPtr("link", r_tree_link);
const r: *c.__AppEditorLine__ = @fieldParentPtr("tree", r_tree);
t.line = r;
t.offset.y = 5;
__AppEditorViewsFolded_goToStartOfText__(t);
t.need_redraw = true;
__AppEditorViewsFolded_bakup__(t);
}
// # __AppEditorViewsFolded_goToStartOfLine__
fn __AppEditorViewsFolded_goToStartOfLine__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
t.symbol = 0;
t.offset.x = 0;
t.need_redraw = true;
}
// # __AppEditorViewsFolded_goToStartOfText__
fn __AppEditorViewsFolded_goToStartOfText__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
if (t.line.*.text_len > 0) {
const text = t.line.*.text[0..t.line.*.text_len];
__AppEditorViewsFolded_goToSymbol__(t, c.__TextAscii_countIndent__(text.ptr, text.len, 1));
} else {
__AppEditorViewsFolded_goToSymbol__(t, 0);
}
}
// # __AppEditorViewsFolded_goToSymbol__
fn __AppEditorViewsFolded_goToSymbol__(t: *c.__AppEditorViewsFolded__, pos: usize) callconv(.c) void {
t.symbol = pos;
if (t.symbol > c.__app__.terminal.output.size.x - 3) {
t.offset.x = 8;
} else {
t.offset.x = t.symbol;
}
t.need_redraw = true;
}
// # __AppEditorViewsFolded_indentToCutieLine__
fn __AppEditorViewsFolded_indentToCutieLine__(
t: *c.__AppEditorViewsFolded__,
line: *c.__AppEditorLine__
) !void { // todo not bool
var new_indent: usize = 0;
if (@intFromPtr(line.tree.parent) != @intFromPtr(c.NULL)) {
const parent_tree: *c.__MemTree__ = @ptrCast(line.tree.parent);
if (parent_tree != &t.lines) {
const parent: *c.__AppEditorLine__ = @fieldParentPtr("tree", parent_tree);
new_indent = 0;
if (parent.text_len > 0) {
const text = parent.text[0..parent.text_len];
new_indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1) + 4;
}
}
if (c.__AppEditorLine_setIndent__(line, new_indent) == false) return error.Unexpected;
}
}
// # __AppEditorViewsFolded_indentToCutie__
fn __AppEditorViewsFolded_indentToCutie__(t: *c.__AppEditorViewsFolded__, line: *c.__AppEditorLine__) !void {
t.need_redraw = true;
// get indent_delta
var indent_delta: isize = 0;
var line_indent: usize = 0;
if (line.text_len > 0) {
const line_text: []const u8 = line.text[0..line.text_len];
line_indent = c.__TextAscii_countIndent__(line_text.ptr, line_text.len, 1);
}
var around_indent: usize = 0;
{
if (__AppEditorViewsFolded_Line_getNextLine__(t, line)) |next_line| {
if (next_line.text_len > 0) {
const next_line_text = next_line.text[0..next_line.text_len];
around_indent = c.__TextAscii_countIndent__(next_line_text.ptr, next_line_text.len, 1);
}
} else if (__AppEditorViewsFolded_Line_getPrevLine__(t, line)) |prev_line| {
if (prev_line.text_len > 0) {
const prev_line_text = prev_line.text[0..prev_line.text_len];
around_indent = c.__TextAscii_countIndent__(prev_line_text.ptr, prev_line_text.len, 1); // i can take in last symbol and add indent but its bad for indent specific languages
}
} else if (__AppEditorViewsFolded_Line_getParentLine__(t, line)) |parent_line| {
if (parent_line.text_len > 0) {
const parent_line_text = parent_line.text[0..parent_line.text_len];
around_indent = c.__TextAscii_countIndent__(parent_line_text.ptr, parent_line_text.len, 1); // do not add automate indent inside blocks. use empty line with needed indents
}
}
}
indent_delta = @as(isize, @intCast(around_indent)) - @as(isize, @intCast(line_indent));
if (indent_delta == 0) return;
try __AppEditorViewsFolded_fixIndent__(t, line, indent_delta);
}
// # __AppEditorViewsFolded_init__
fn __AppEditorViewsFolded_init__(t: *c.__AppEditorViewsFolded__) !void {
t.need_redraw = true;
t.need_draw_line_num = true;
t.marked_line = null;
t.symbol = 0;
t.offset = .{ .x = 0, .y = 0 }; // __math_d2_U_Pos__
c.__MemTree_init__(&t.lines);
c.__MemTree_init__(&t.cutted);
c.__AppEditorLine_init__(&t.bakup_line);
}
// # __AppEditorViewsFolded_insertFindedText__
fn __AppEditorViewsFolded_insertFindedText__(t: *c.__AppEditorViewsFolded__) !void {
const text: []const u8 = __AppEditorViewsFind_get__(&c.__app__.editor.views.find) orelse return;
for (text) |rune| {
__AppEditorViewsFolded_insertSymbol__(t, rune) catch {};
}
t.need_redraw = true;
}
// # __AppEditorViewsFolded_insertSymbol__
fn __AppEditorViewsFolded_insertSymbol__(t: *c.__AppEditorViewsFolded__, rune: u8) !void {
if (t.symbol > t.line.*.text_len) {
__AppEditorViewsFolded_goToSymbol__(t, t.line.*.text_len);
}
if (t.line.*.text_len < c.__AppEditorLineLen_max__) {
c.__Buffer_push__(&t.line.*.text[0], &t.line.*.text_len, t.symbol, rune);
__AppEditorViewsFolded_goToNextSymbol__(t);
}
t.need_redraw = true;
}
// # __AppEditorViewsFolded_joinLines__
fn __AppEditorViewsFolded_joinLines__(t: *c.__AppEditorViewsFolded__) !void {
try __AppEditorViewsFolded_unFold__(t);
const flat = &c.__app__.editor.views.flat;
try __AppEditorViewsFlat_joinLines__(flat);
}
// # __AppEditorViewsFolded_manyIndent__
fn __AppEditorViewsFolded_manyIndent__(t: *c.__AppEditorViewsFolded__) !void { // TODO rename to decrease indent
var indent: usize = 0;
if (t.line.*.text_len > 0) {
const text = t.line.*.text[0..t.line.*.text_len];
indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
}
if (indent < 4) return;
if (c.__AppEditorLine_setIndent__(t.line, indent - 4) == false) return error.Unexpected;
t.need_redraw = true;
}
// # __AppEditorViewsFolded_markThisLine__
fn __AppEditorViewsFolded_markThisLine__(t: *c.__AppEditorViewsFolded__) !void {
t.marked_line = t.line;
__AppEditor_changeStatus__("marked.");
}
// # __AppEditorViewsFolded_moveBlockOutside__
fn __AppEditorViewsFolded_moveBlockOutside__(t: *c.__AppEditorViewsFolded__) !void {
const current_tree = &t.line.*.tree;
if (c.__MemTree_isChild__(current_tree)) {
var parent_tree: *c.__MemTree__ = undefined;
c.__MemTree_getParent__(@ptrCast(&parent_tree), current_tree);
const next_tree: *c.__MemTree__ = select: {
if (@intFromPtr(current_tree.link.next) != @intFromPtr(c.NULL)) {
const next_link: *c.__MemListLink__ = current_tree.link.next;
break :select @fieldParentPtr("link", next_link);
} else if (@intFromPtr(current_tree.link.prev) != @intFromPtr(c.NULL)) {
const prev_link: *c.__MemListLink__ = current_tree.link.prev;
break :select @fieldParentPtr("link", prev_link);
} else {
c.__MemTree_getParent__(@ptrCast(&parent_tree), current_tree);
break :select parent_tree;
}
};
// move
c.__MemTree_pop__(current_tree);
c.__MemTree_pushPrev__(parent_tree, current_tree);
try __AppEditorViewsFolded_indentToCutie__(t, t.line);
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", next_tree);
t.line = line;
__AppEditor_changeStatus__("moved up");
__AppEditorViewsFolded_cursorMoveToCurrent__(t) catch {};
}
}
// # __AppEditorViewsFolded_moveBlockToMarkedInWithAddIndent__
fn __AppEditorViewsFolded_moveBlockToMarkedInWithAddIndent__(t: *c.__AppEditorViewsFolded__) !void {
const block = t.line;
try __AppEditorViewsFolded_moveBlockToMarkedIn__(t);
try __AppEditorViewsFolded_fixIndent__(t, block, 4);
}
// # __AppEditorViewsFolded_moveBlockToMarkedIn__
fn __AppEditorViewsFolded_moveBlockToMarkedIn__(t: *c.__AppEditorViewsFolded__) !void {
if (@intFromPtr(t.marked_line) != @intFromPtr(c.NULL)) {
const marked: *c.__AppEditorLine__ = @ptrCast(t.marked_line);
if (marked == t.line) return;
{ // check current block is not a parent of marked:
var parent_tree: *c.__MemTree__ = &marked.tree;
const line_tree: *c.__MemTree__ = &t.line.*.tree;
if (parent_tree == line_tree) return;
while (true) {
if (c.__MemTree_isChild__(parent_tree)) {
c.__MemTree_getParent__(@ptrCast(&parent_tree), parent_tree);
if (parent_tree == line_tree) return;
} else {
break;
}
}
}
// move
const next_line = blk: {
const last_line = t.line;
if (__AppEditorViewsFolded_Line_getNextLine__(t, last_line)) |ptr| {
break: blk ptr;
} else if (__AppEditorViewsFolded_Line_getPrevLine__(t, last_line)) |ptr| {
break: blk ptr;
} else if (__AppEditorViewsFolded_Line_getParentLine__(t, last_line)) |ptr| {
break: blk ptr;
} else return;
};
c.__MemTree_pop__(&t.line.*.tree);
c.__MemTree_pushChild__(&marked.tree, &t.line.*.tree);
// fix indent
var indent: usize = 0;
if (t.line.*.text_len > 0) {
const text = t.line.*.text[0.. t.line.*.text_len];
indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
}
var marked_indent: usize = 0;
if (marked.text_len > 0) {
const marked_text = marked.text[0..marked.text_len];
marked_indent = c.__TextAscii_countIndent__(marked_text.ptr, marked_text.len, 1);
}
const indent_delta: isize = @as(isize, @intCast(marked_indent)) - @as(isize, @intCast(indent));
try __AppEditorViewsFolded_fixIndent__(t, t.line, indent_delta);
t.line = next_line;
t.need_redraw = true;
__AppEditor_changeStatus__("block moved to in marked.");
__AppEditorViewsFolded_cursorMoveToCurrent__(t) catch {};
}
}
// # __AppEditorViewsFolded_moveBlockToMarkedOut__
fn __AppEditorViewsFolded_moveBlockToMarkedOut__(t: *c.__AppEditorViewsFolded__) !void {
const marked = t.marked_line orelse return;
if (marked == t.line) return;
{ // check block is not a parent of marked:
var parent_tree = &marked.*.tree;
const line_tree = &t.line.*.tree;
if (parent_tree == line_tree) return;
while (true) {
if (c.__MemTree_isChild__(parent_tree)) {
c.__MemTree_getParent__(@ptrCast(&parent_tree), parent_tree);
if (parent_tree == line_tree) return;
} else {
break;
}
}
}
// move
var next_tree: *c.__MemTree__ = undefined; {
const current_tree = &t.line.*.tree;
if (@intFromPtr(current_tree.link.next) != @intFromPtr(c.NULL)) {
const next_link: *c.__MemListLink__ = current_tree.link.next;
next_tree = @fieldParentPtr("link", next_link);
} else if (@intFromPtr(current_tree.link.prev) != @intFromPtr(c.NULL)) {
const prev_link: *c.__MemListLink__ = current_tree.link.prev;
next_tree = @fieldParentPtr("link", prev_link);
} else {
c.__MemTree_getParent__(@ptrCast(&next_tree), current_tree);
}
}
const line_tree = &t.line.*.tree;
c.__MemTree_pop__(line_tree);
c.__MemTree_pushPrev__(&marked.*.tree, line_tree);
try __AppEditorViewsFolded_indentToCutie__(t, t.line);
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", next_tree);
t.line = line;
t.need_redraw = true;
__AppEditor_changeStatus__("moved to marked.");
__AppEditorViewsFolded_cursorMoveToCurrent__(t) catch {};
}
// # __AppEditorViewsFolded_moveDownToSort__
fn __AppEditorViewsFolded_moveDownToSort__(t: *c.__AppEditorViewsFolded__) !void {
const cursor_pos_x = t.symbol;
const base_line = t.line;
const base_line_text = base_line.*.text_len;
if (cursor_pos_x <= base_line_text) {
const base_text = &base_line.*.text[cursor_pos_x];
const base_text_len = base_line_text - cursor_pos_x;
const base_end_of_word = c.__TextAscii_findBreakOfWord__(base_text, base_text_len);
if (base_end_of_word > 0) {
var iter_count: usize = 0;
var next_line_link: [*c]c.__MemListLink__ = base_line.*.tree.link.next;
while(next_line_link != 0) {
const next_line = next_line_link.*.next;
{
const line_tree: *c.__MemTree__ = @fieldParentPtr("link", @as(*c.__MemListLink__, @ptrCast(next_line_link)));
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", line_tree);
if (line.text_len >= cursor_pos_x) {
const line_text = &line.text[cursor_pos_x];
const line_text_len = line.text_len - cursor_pos_x;
const line_end_of_word = c.__TextAscii_findBreakOfWord__(line_text, line_text_len);
if (line_end_of_word > 0) {
const compare_size = if (base_end_of_word < line_end_of_word) base_end_of_word else line_end_of_word; // just min
const compare_result: i8 = @bitCast(c.__TextAscii_compare__(base_text, line_text, compare_size));
if (compare_result > 0) {
try __AppEditorViewsFolded_swapWithBottom__(t);
} else {
break;
}
} else {
break;
}
} else {
break;
}
}
iter_count+=1;
next_line_link = next_line;
}
while(iter_count > 0):(iter_count -= 1) {
__AppEditorViewsFolded_goToPrevLine__(t);
}
}
}
}
// # __AppEditorViewsFolded_moveUpToSort__
fn __AppEditorViewsFolded_moveUpToSort__(t: *c.__AppEditorViewsFolded__) !void {
const cursor_pos_x = t.symbol;
const base_line = t.line;
const base_line_text = base_line.*.text_len;
if (cursor_pos_x <= base_line_text) {
const base_text = &base_line.*.text[cursor_pos_x];
const base_text_len = base_line_text - cursor_pos_x;
const base_end_of_word = c.__TextAscii_findBreakOfWord__(base_text, base_text_len);
if (base_end_of_word > 0) {
var iter_count: usize = 0;
var next_line_link: [*c]c.__MemListLink__ = base_line.*.tree.link.prev;
while(next_line_link != 0) {
const prev_line = next_line_link.*.prev;
{
const line_tree: *c.__MemTree__ = @fieldParentPtr("link", @as(*c.__MemListLink__, @ptrCast(next_line_link)));
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", line_tree);
if (line.text_len >= cursor_pos_x) {
const line_text = &line.text[cursor_pos_x];
const line_text_len = line.text_len - cursor_pos_x;
const line_end_of_word = c.__TextAscii_findBreakOfWord__(line_text, line_text_len);
if (line_end_of_word > 0) {
const compare_size = if (base_end_of_word < line_end_of_word) base_end_of_word else line_end_of_word;
const compare_result: i8 = @bitCast(c.__TextAscii_compare__(base_text, line_text, compare_size));
if (compare_result < 0) {
try __AppEditorViewsFolded_swapWithUpper__(t);
} else {
break;
}
} else {
break;
}
} else {
break;
}
}
iter_count+=1;
next_line_link = prev_line;
}
while(iter_count > 0):(iter_count -= 1) {
__AppEditorViewsFolded_goToNextLine__(t);
}
}
}
}
// # __AppEditorViewsFolded_onKey__
fn __AppEditorViewsFolded_onKey__(t: *c.__AppEditorViewsFolded__, cik: c.__ConsoleAnsiInputKey__) callconv(.c) void {
__AppEditorViewsFolded_onkeyWrap__(t, cik) catch {};
}
// # __AppEditorViewsFolded_onkeyWrap__
fn __AppEditorViewsFolded_onkeyWrap__(t: *c.__AppEditorViewsFolded__, cik: c.__ConsoleAnsiInputKey__) !void {
switch (cik) {
c.__ConsoleAnsiInputKey_alt_w__ => __AppEditorViewsFolded_moveUpToSort__(t) catch {},
c.__ConsoleAnsiInputKey_alt_s__ => __AppEditorViewsFolded_moveDownToSort__(t) catch {},
c.__ConsoleAnsiInputKey_escape__ => __AppEditorViewsFolded_goToOut__(t),
c.__ConsoleAnsiInputKey_tab__ => __AppEditorViewsFolded_goToIn__(t),
c.__ConsoleAnsiInputKey_ctrl_e__ => try __AppEditorViewsFolded_unFold__(t),
c.__ConsoleAnsiInputKey_ctrl_q__ => c.__AppEditor_stop__(&c.__app__.editor),
c.__ConsoleAnsiInputKey_ctrl_s__ => __AppEditorViewsFolded_save__(t) catch {},
c.__ConsoleAnsiInputKey_ctrl_j__ => try __AppEditorViewsFolded_joinLines__(t),
c.__ConsoleAnsiInputKey_enter__ => __AppEditorViewsFolded_divide__(t) catch {},
c.__ConsoleAnsiInputKey_back_space__ => try __AppEditorViewsFolded_deletePrevSymbol__(t),
c.__ConsoleAnsiInputKey_ctrl_bs__ => try __AppEditorViewsFolded_deletePrevSymbol__(t),
c.__ConsoleAnsiInputKey_ctrl_d__ => try __AppEditorViewsFolded_duplicate__(t),
c.__ConsoleAnsiInputKey_ctrl_x__ => try __AppEditorViewsFolded_cut__(t),
c.__ConsoleAnsiInputKey_ctrl_c__ => try __AppEditorViewsFolded_duplicateAndCut__(t),
c.__ConsoleAnsiInputKey_ctrl_v__ => __AppEditorViewsFolded_pasteLine__(t) catch {},
c.__ConsoleAnsiInputKey_ctrl_t__ => __AppEditorViewsFolded_insertSymbol__(t, '\t') catch {},
c.__ConsoleAnsiInputKey_ctrl_w__ => try __AppEditorViewsFolded_deleteWord__(t),
c.__ConsoleAnsiInputKey_ctrl_z__ => try __AppEditorViewsFolded_restore__(t),
c.__ConsoleAnsiInputKey_ctrl_f__ => __AppEditorViewsFolded_toFind__(t) catch {},
c.__ConsoleAnsiInputKey_ctrl_g__ => __AppEditorViewsFolded_toGoTo__(t),
c.__ConsoleAnsiInputKey_up__ => __AppEditorViewsFolded_goToPrevLine__(t),
c.__ConsoleAnsiInputKey_down__ => __AppEditorViewsFolded_goToNextLine__(t),
c.__ConsoleAnsiInputKey_left__ => __AppEditorViewsFolded_goToPrevSymbol__(t),
c.__ConsoleAnsiInputKey_right__ => __AppEditorViewsFolded_goToNextSymbol__(t),
c.__ConsoleAnsiInputKey_ctrl_shift_left__ => __AppEditorViewsFolded_CtrlShiftLeft__(t),
c.__ConsoleAnsiInputKey_ctrl_shift_right__ => __AppEditorViewsFolded_CtrlShiftRight__(t),
c.__ConsoleAnsiInputKey_ctrl_left__ => __AppEditorViewsFolded_ctrlLeft__(t),
c.__ConsoleAnsiInputKey_ctrl_right__ => __AppEditorViewsFolded_ctrlRight__(t),
c.__ConsoleAnsiInputKey_ctrl_up__ => __AppEditorViewsFolded_goToFirstLine__(t),
c.__ConsoleAnsiInputKey_ctrl_down__ => __AppEditorViewsFolded_goToLastLine__(t),
c.__ConsoleAnsiInputKey_page_up__ => __AppEditorViewsFolded_pageUp__(t),
c.__ConsoleAnsiInputKey_page_down__ => __AppEditorViewsFolded_pageDown__(t),
c.__ConsoleAnsiInputKey_alt_e__ => try __AppEditorViewsFolded_easyMotionV__(t),
c.__ConsoleAnsiInputKey_alt_q__ => try __AppEditorViewsFolded_easyMotionH__(t),
c.__ConsoleAnsiInputKey_delete__ => __AppEditorViewsFolded_deleteSymbol__(t),
c.__ConsoleAnsiInputKey_shift_delete__ => __AppEditorViewsFolded_clearLine__(t),
c.__ConsoleAnsiInputKey_end__ => __AppEditorViewsFolded_goToEndOfLine__(t),
c.__ConsoleAnsiInputKey_home__ => __AppEditorViewsFolded_goToStartOfLine__(t),
c.__ConsoleAnsiInputKey_alt_up__ => try __AppEditorViewsFolded_swapWithUpper__(t),
c.__ConsoleAnsiInputKey_alt_down__ => try __AppEditorViewsFolded_swapWithBottom__(t),
c.__ConsoleAnsiInputKey_alt_1__ => try __AppEditorViewsFolded_copyWordToFind__(t),
c.__ConsoleAnsiInputKey_alt_2__ => __AppEditorViewsFolded_alt2__(t) catch {},
c.__ConsoleAnsiInputKey_alt_3__ => __AppEditorViewsFolded_alt3__(t) catch {},
c.__ConsoleAnsiInputKey_alt_4__ => try __AppEditorViewsFolded_insertFindedText__(t),
c.__ConsoleAnsiInputKey_alt_5__ => __AppEditorViewsFolded_toReplace__(t),
c.__ConsoleAnsiInputKey_alt_6__ => __AppEditorViewsFolded_replace__(t) catch {},
c.__ConsoleAnsiInputKey_alt_g__ => __AppEditorViewsFolded_goToMarked__(t),
c.__ConsoleAnsiInputKey_alt_m__ => try __AppEditorViewsFolded_markThisLine__(t),
c.__ConsoleAnsiInputKey_alt_o__ => try __AppEditorViewsFolded_moveBlockOutside__(t),
c.__ConsoleAnsiInputKey_alt_8__ => try __AppEditorViewsFolded_moveBlockToMarkedIn__(t),
c.__ConsoleAnsiInputKey_alt_9__ => try __AppEditorViewsFolded_moveBlockToMarkedInWithAddIndent__(t),
c.__ConsoleAnsiInputKey_alt_0__ => try __AppEditorViewsFolded_moveBlockToMarkedOut__(t),
c.__ConsoleAnsiInputKey_alt_c__ => __AppEditorViewsFolded_externalCopy__(t) catch {},
c.__ConsoleAnsiInputKey_alt_v__ => __AppEditorViewsFolded_externalPaste__(t) catch {},
c.__ConsoleAnsiInputKey_alt_z__ => try __AppEditorViewsFolded_deleteCutted__(t),
c.__ConsoleAnsiInputKey_ctrl_enter__ => try __AppEditorViewsFolded_joinLines__(t),
c.__ConsoleAnsiInputKey_alt_open_bracket__ => __AppEditorViewsFolded_goToPrevComment__(t),
c.__ConsoleAnsiInputKey_alt_close_bracket__ => __AppEditorViewsFolded_goToNextComment__(t),
c.__ConsoleAnsiInputKey_ctrl_triangular_open_quotation_mark__ => __AppEditorViewsFolded_manyIndent__(t) catch {},
c.__ConsoleAnsiInputKey_ctrl_triangular_close_quotation_mark__ => __AppEditorViewsFolded_addIndent__(t) catch {},
c.__ConsoleAnsiInputKey_alt_semicolon__ => try __AppEditorViewsFolded_goToPrevParagraph__(t),
c.__ConsoleAnsiInputKey_alt_apostrophe__ => try __AppEditorViewsFolded_goToNextParagraph__(t),
c.__ConsoleAnsiInputKey_f4__ => try __AppEditorViewsFolded_drawCountLineNum__(t),
else => {
if (cik > 255) return;
const byte: u8 = @truncate(cik);
__AppEditorViewsFolded_insertSymbol__(t, byte) catch {};
t.need_redraw = true;
},
}
}
// # __AppEditorViewsFolded_pageDown__
fn __AppEditorViewsFolded_pageDown__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
var pos: usize = 0;
while (pos < 10) : (pos += 1) {
__AppEditorViewsFolded_goToNextLine__(t);
}
}
// # __AppEditorViewsFolded_pageUp__
fn __AppEditorViewsFolded_pageUp__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
var pos: usize = 0;
while (pos < 10) : (pos += 1) {
__AppEditorViewsFolded_goToPrevLine__(t);
}
}
// # __AppEditorViewsFolded_pasteLine__
fn __AppEditorViewsFolded_pasteLine__(t: *c.__AppEditorViewsFolded__) !void {
const line_tree_link: *c.__MemListLink__ = t.cutted.childs.last orelse return;
const line_tree: *c.__MemTree__ = @fieldParentPtr("link", line_tree_link);
c.__MemTree_pop__(line_tree);
c.__MemTree_pushPrev__(&t.line.*.tree, line_tree);
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", line_tree);
try __AppEditorViewsFolded_indentToCutie__(t, line);
t.offset.y += 1;
__AppEditorViewsFolded_goToPrevLine__(t);
t.need_redraw = true;
}
// # __AppEditorViewsFolded_replace__
fn __AppEditorViewsFolded_replace__(t: *c.__AppEditorViewsFolded__) !void {
const find_line = &c.__app__.editor.views.find.line;
if (find_line.text_len > 0) {
const find_text = find_line.text[0..find_line.text_len];
const replace_line: *c.__AppEditorLine__ = &c.__app__.editor.views.replace.line;
const replace_text = replace_line.text[0..replace_line.text_len];
if (t.line.*.text_len - t.symbol < find_text.len) return;
const dest = t.line.*.text[t.symbol .. t.symbol + find_text.len];
if (std.mem.eql(u8, find_text, dest) == false) return;
// delete old text
for (find_text) |_| {
__AppEditorViewsFolded_deleteSymbol__(t);
}
for (replace_text) |rune| {
__AppEditorViewsFolded_insertSymbol__(t, rune) catch {};
}
t.need_redraw = true;
}
}
// # __AppEditorViewsFolded_restore__
fn __AppEditorViewsFolded_restore__(t: *c.__AppEditorViewsFolded__) !void {
const bakup_line = &t.bakup_line;
if (bakup_line.text_len > 0) {
const text = bakup_line.text[0..bakup_line.text_len];
c.__AppEditorLine_setText__(t.line, text.ptr, text.len);
t.need_redraw = true;
}
}
// # __AppEditorViewsFolded_saveTreeToFile__
fn __AppEditorViewsFolded_saveTreeToFile__(root: *c.__MemTree__, file_name: []const u8, root_skip: enum { not_skip_root, skip_root }) !void {
var ok: bool = true;
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_notification__, c.__AppEditorTheme_notification__.len); {
c.__ConsoleOutput_cursorHide__(&c.__app__.console.output);
__AppEditor_changeStatus__("saving file...");
var full_len: usize = 0;
{ // count full len
__AppEditor_changeStatus__("counting...");
var maybe_tree: ?*c.__MemTree__ = root; // tree in c.__AppEditorLine__.tree
if (root_skip == .skip_root) {
maybe_tree = c.__MemTree_traverse__(root);
}
if (maybe_tree) |first_tree| { // first line
const first_line: *c.__AppEditorLine__ = @fieldParentPtr("tree", first_tree);
if (first_line.text_len > 0) {
const first_line_text: []const u8 = first_line.text[0..first_line.text_len];
full_len += first_line_text.len;
}
maybe_tree = c.__MemTree_traverse__(first_tree); // go to next
while (maybe_tree) |tree| { // write any other lines with "\n" in start
full_len += c.__app__.editor.__AppEditor_endLine_len__;
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", tree);
if (line.text_len > 0) {
const text = line.text[0..line.text_len];
full_len += text.len;
}
maybe_tree = c.__MemTree_traverse__(tree);
} // end while
}
}
if (full_len > 0) { // write
__AppEditor_changeStatus__("allocating...");
var buffer: [*c]u8 = undefined;
if (c.__AlignedPtr_allocAny__(&buffer, 4, full_len)) { // use aligned just for speed
// save to buffer
__AppEditor_changeStatus__("defragmentation...");
var writed: usize = 0;
var maybe_tree: ?*c.__MemTree__ = root; // tree in c.__AppEditorLine__.tree
if (root_skip == .skip_root) {
maybe_tree = c.__MemTree_traverse__(root);
}
if (maybe_tree) |first_tree| { // just write first line
const first_line: *c.__AppEditorLine__ = @fieldParentPtr("tree", first_tree);
if (first_line.text_len > 0) {
const first_line_text: []const u8 = first_line.text[0..first_line.text_len];
c.__Mem_copy__(&buffer[writed], first_line_text.ptr, first_line_text.len);
writed += first_line_text.len;
}
maybe_tree = c.__MemTree_traverse__(first_tree); // go to next
while (maybe_tree) |tree| { // write any other lines with "\n" in start
c.__Mem_copy__(&buffer[writed], c.__app__.editor.__AppEditor_endLine__, c.__app__.editor.__AppEditor_endLine_len__);
writed += c.__app__.editor.__AppEditor_endLine_len__;
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", tree);
if (line.text_len > 0) {
const text = line.text[0..line.text_len];
c.__Mem_copy__(&buffer[writed], text.ptr, text.len);
writed += text.len;
}
maybe_tree = c.__MemTree_traverse__(tree);
} // end while
}
// writing
__AppEditor_changeStatus__("writing...");
if (c.__FileComplete_write__(file_name.ptr, file_name.len, buffer, writed)) {
} else { // file not writed
__AppEditor_changeStatus__("file not writed");
ok = false;
}
c.__AlignedPtr_freeAny__(buffer, full_len);
} else { // memory not allocated
__AppEditor_changeStatus__("memory not allocated");
ok = false;
}
} else { // clear
ok = c.__FileComplete_clear__(file_name.ptr, file_name.len);
}
__AppEditor_changeStatus__("file saved");
c.__Console_showCursor__(&c.__app__.console);
c.__Terminal_resetColors__(&c.__app__.terminal);
}
if (!ok) return error.Unexpected;
//return ok;
}
// # __AppEditorViewsFolded_save__
fn __AppEditorViewsFolded_save__(t: *c.__AppEditorViewsFolded__) !void {
{ // write text
const tt: []const u8 = "- - unfolding... - -";
c.__Terminal_writeToOutput__(&c.__app__.terminal, tt.ptr, tt.len);
}
try __AppEditorViewsFolded_unFold__(t);
const flat = &c.__app__.editor.views.flat;
try __AppEditorViewsFlat_save__(flat);
flat.need_redraw = true;
}
// # __AppEditorViewsFolded_setAsView__
fn __AppEditorViewsFolded_setAsView__(t: *c.__AppEditorViewsFolded__) !void {
c.__app__.editor.do_ptr = @ptrCast(&__AppEditorViewsFolded_do__);
c.__app__.editor.onKey_ptr = @ptrCast(&__AppEditorViewsFolded_onKey__);
c.__app__.editor.current_ctx = t;
c.__app__.editor.current_vtable = &c.__AppEditorViewsVtable_folded__;
__AppEditorViewsFolded_bakup__(t);
if (t.offset.y < 10) t.offset.y = 10;
try __AppEditorViewsFolded_draw__(t);
__AppEditor_changeStatus__("Views.Folded mode.");
}
// # __AppEditorViewsFolded_swapWithBottom__
fn __AppEditorViewsFolded_swapWithBottom__(t: *c.__AppEditorViewsFolded__) !void {
if (t.line.*.tree.link.next == null) {
return;
}
__AppEditorViewsFolded_goToNextLine__(t);
try __AppEditorViewsFolded_swapWithUpper__(t);
__AppEditorViewsFolded_goToNextLine__(t);
}
// # __AppEditorViewsFolded_swapWithUpper__
fn __AppEditorViewsFolded_swapWithUpper__(t: *c.__AppEditorViewsFolded__) !void {
if (t.line.*.tree.link.next == null) {
try __AppEditorViewsFolded_cut__(t);
try __AppEditorViewsFolded_pasteLine__(t);
} else {
try __AppEditorViewsFolded_cut__(t);
__AppEditorViewsFolded_goToPrevLine__(t);
try __AppEditorViewsFolded_pasteLine__(t);
}
t.need_redraw = true;
}
// # __AppEditorViewsFolded_toFind__
fn __AppEditorViewsFolded_toFind__(t: *c.__AppEditorViewsFolded__) !void {
__AppEditorViewsFind_setAsView__(&c.__app__.editor.views.find, t, &c.__AppEditorViewsVtable_folded__);
}
// # __AppEditorViewsFolded_toGoTo__
fn __AppEditorViewsFolded_toGoTo__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
__AppEditorViewsGoToLine_setAsView__(&c.__app__.editor.views.go_to_line, t, &c.__AppEditorViewsVtable_folded__);
}
// # __AppEditorViewsFolded_toReplace__
fn __AppEditorViewsFolded_toReplace__(t: *c.__AppEditorViewsFolded__) callconv(.c) void {
__AppEditorViewsReplace_setAsView__(&c.__app__.editor.views.replace, t, &c.__AppEditorViewsVtable_folded__);
}
// # __AppEditorViewsFolded_unFold__
fn __AppEditorViewsFolded_unFold__(t: *c.__AppEditorViewsFolded__) !void {
const vf = &c.__app__.editor.views.flat;
const lines = &vf.lines;
if (lines.count > 0) unreachable;
{ // move to flat (from tree to link)
const root: *c.__MemTree__ = &t.lines;
var tree: ?*c.__MemTree__ = c.__MemTree_traverse__(root); // skip root // maybe more skip?
while (tree) |tree_r| {
const line: *c.__AppEditorLine__ = @fieldParentPtr("tree", tree_r);
c.__MemList_pushLast__(&vf.lines, &line.link);
tree = c.__MemTree_traverse__(tree_r);
}
}
{ // pop all lines from tree
var link_r: *allowzero c.__MemListLink__ = lines.first;
while (@intFromPtr(link_r) != @intFromPtr(c.NULL)) {
const link: *c.__MemListLink__ = @ptrCast(link_r);
const line: *c.__AppEditorLine__ = @fieldParentPtr("link", link);
c.__MemTree_pop__(&line.tree);
link_r = link.next;
}
}
{ // change Views.Flat
vf.line = t.line;
vf.symbol = t.symbol;
vf.offset = t.offset;
vf.marked_line = t.marked_line;
try __AppEditorViewsFlat_setAsView__(vf);
}
}
// # __AppEditorViewsGoToLine_CtrlShiftLeft__
fn __AppEditorViewsGoToLine_CtrlShiftLeft__(t: *c.__AppEditorViewsGoToLine__) callconv(.c) void {
if (t.line.text_len > 0) {
const text = t.line.text[0..t.line.text_len];
const indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
if (t.symbol > indent) {
t.goToSymbol(indent);
} else t.goToStartOfLine();
} else t.goToStartOfLine();
t.need_redraw = true;
}
// # __AppEditorViewsGoToLine_CtrlShiftRight__
fn __AppEditorViewsGoToLine_CtrlShiftRight__(t: *c.__AppEditorViewsGoToLine__) callconv(.c) void {
if (t.line.text_len > 0) {
const text = t.line.text[0..t.line.text_len];
const indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
if (t.symbol < indent) t.goToSymbol(indent) else t.goToEndOfLine();
t.need_redraw = true;
}
}
// # __AppEditorViewsGoToLine_cancel__
fn __AppEditorViewsGoToLine_cancel__(t: *c.__AppEditorViewsGoToLine__) !void {
t.context_vtable.*.setAsView.?(t.context);
}
// # __AppEditorViewsGoToLine_clearLine__
fn __AppEditorViewsGoToLine_clearLine__(t: *c.__AppEditorViewsGoToLine__) callconv(.c) void {
t.line.text_len = 0;
__AppEditorViewsGoToLine_goToStartOfText__(t);
t.need_redraw = true;
}
// # __AppEditorViewsGoToLine_correctOffset__
fn __AppEditorViewsGoToLine_correctOffset__(t: *c.__AppEditorViewsGoToLine__) callconv(.c) void {
const predel = (c.__app__.terminal.output.size.y >> 1) - (c.__app__.terminal.output.size.y >> 4);
if (t.symbol >= predel) t.offset.x = predel;
}
// # __AppEditorViewsGoToLine_ctrlLeft__
fn __AppEditorViewsGoToLine_ctrlLeft__(t: *c.__AppEditorViewsGoToLine__) callconv(.c) void {
__AppEditorViewsGoToLine_goToSymbol__(t, 0);
t.need_redraw = true;
}
// # __AppEditorViewsGoToLine_ctrlRight__
fn __AppEditorViewsGoToLine_ctrlRight__(t: *c.__AppEditorViewsGoToLine__) callconv(.c) void {
if (t.line.text_len > 0) {
const full_text = t.line.text[0..t.line.text_len];
__AppEditorViewsGoToLine_goToSymbol__(t, full_text.len);
t.need_redraw = true;
}
}
// # __AppEditorViewsGoToLine_cursorMoveToCurrent__
fn __AppEditorViewsGoToLine_cursorMoveToCurrent__(t: *c.__AppEditorViewsGoToLine__) !void {
c.__Terminal_cursorMove__(&c.__app__.terminal, t.offset.x, t.offset.y);
}
// # __AppEditorViewsGoToLine_deletePrevSymbol__
fn __AppEditorViewsGoToLine_deletePrevSymbol__(t: *c.__AppEditorViewsGoToLine__) !void {
if (t.symbol == 0) {
return;
} else if (t.symbol > t.line.text_len) {
__AppEditorViewsGoToLine_goToPrevSymbol__(t);
} else {
if (t.line.text_len == 0) return;
__AppEditorViewsGoToLine_goToPrevSymbol__(t);
__AppEditorViewsGoToLine_deleteSymbol__(t);
}
t.need_redraw = true;
}
// # __AppEditorViewsGoToLine_deleteSymbol__
fn __AppEditorViewsGoToLine_deleteSymbol__(t: *c.__AppEditorViewsGoToLine__) callconv(.c) void {
if (t.line.text_len == 0) return;
if (c.__Buffer_pop_check__(t.line.text_len, t.symbol)) {
_=c.__Buffer_pop__(&t.line.text[0], &t.line.text_len, t.symbol);
}
t.need_redraw = true;
}
// # __AppEditorViewsGoToLine_deleteWord__
fn __AppEditorViewsGoToLine_deleteWord__(t: *c.__AppEditorViewsGoToLine__) !void {
if (t.symbol > t.line.text_len) {
return;
}
while (true) { // delete current symbol
if (t.symbol == t.line.text_len) {
break;
}
const next_symbol = t.line.text[t.symbol];
if (c.__TextAscii_isLetter__(next_symbol)) {
t.deleteSymbol();
} else {
break;
}
}
while (true) { // delete prev symbol
if (t.symbol == 0) {
break;
}
const prev_symbol = t.line.text[t.symbol - 1];
if (c.__TextAscii_isLetter__(prev_symbol)) {
try t.deletePrevSymbol();
} else {
break;
}
}
t.need_redraw = true;
}
// # __AppEditorViewsGoToLine_do__
fn __AppEditorViewsGoToLine_do__(ctx: *anyopaque) callconv(.c) void {
const t = __AppEditorViewsGoToLine_getModel__(ctx);
if (t.need_redraw == true) {
t.need_redraw = false;
__AppEditorViewsGoToLine_draw__(t) catch unreachable;
__AppEditorViewsGoToLine_cursorMoveToCurrent__(t) catch unreachable;
}
}
// # __AppEditorViewsGoToLine_drawEditedLine__
fn __AppEditorViewsGoToLine_drawEditedLine__(t: *c.__AppEditorViewsGoToLine__) !void {
// change color
c.__Terminal_resetColors__(&c.__app__.terminal);
if (t.line.text_len > 0) {
const text = t.line.text[0..t.line.text_len];
// draw left-to-right from first visible rune
c.__Terminal_moveCursorToStartOfLine__(&c.__app__.terminal);
var pos: usize = t.symbol - t.offset.x;
var offset_x: usize = 0;
// left arrow
if (pos > 0) { // draw '<'
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_arrows__, c.__AppEditorTheme_arrows__.len);
_=__writeTextToWriteFnVoid__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, "<");
pos += 1;
offset_x += 1;
}
// left symbols
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_current__, c.__AppEditorTheme_current__.len);
while (true) {
if (offset_x >= t.offset.x) break;
if (offset_x >= c.__app__.terminal.output.size.x - 1) break;
if (pos >= text.len) break;
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[pos], 1);
pos += 1;
offset_x += 1;
}
// current symbol. maybe inverse cursour?
if (offset_x >= c.__app__.terminal.output.size.x - 2) return;
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_current_rune__, c.__AppEditorTheme_current_rune__.len);
if (pos < text.len) {
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[pos], 1);
}
pos += 1;
offset_x += 1;
// right symbols
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_current__, c.__AppEditorTheme_current__.len);
while (true) {
if (offset_x >= c.__app__.terminal.output.size.x - 2) break;
if (pos >= text.len) break;
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[pos], 1);
pos += 1;
offset_x += 1;
}
// right arrow
if (pos < text.len) { // draw '>'
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_arrows__, c.__AppEditorTheme_arrows__.len);
_=__writeTextToWriteFnVoid__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, ">");
} else {
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_to_end_line__, 0);
}
} else {
c.__Console_clearLine__(&c.__app__.console);
}
}
// # __AppEditorViewsGoToLine_draw__
fn __AppEditorViewsGoToLine_draw__(t: *c.__AppEditorViewsGoToLine__) !void {
defer {
__AppEditorViewsGoToLine_cursorMoveToCurrent__(t) catch {};
}
__AppEditorViewsGoToLine_correctOffset__(t);
if (t.offset.x >= c.__app__.terminal.output.size.x) t.offset.x = 0;
if (t.offset.y >= c.__app__.terminal.output.size.y) t.offset.y = 0;
if (t.symbol < t.offset.x) { // unexpected
t.offset.x = 0;
t.symbol = 0;
}
c.__ConsoleOutput_cursorHide__(&c.__app__.console.output);
defer c.__Console_showCursor__(&c.__app__.console);
t.offset.y = 1;
{ // draw banner
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, 0);
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_headers__, c.__AppEditorTheme_headers__.len);
const tt = "enter the line you want to jump to:";
_=c.__Terminal_writeToOutput__(&c.__app__.terminal, tt.ptr, tt.len);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_to_end_line__, 0);
}
{ // draw edit line
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, 1);
try __AppEditorViewsGoToLine_drawEditedLine__(t);
}
var pos_y: usize = 2;
while (true) { // clear other downer lines
if (pos_y >= c.__app__.terminal.output.size.y) return;
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, pos_y);
c.__Console_clearLine__(&c.__app__.console);
pos_y += 1;
}
}
// # __AppEditorViewsGoToLine_getModel__
fn __AppEditorViewsGoToLine_getModel__(ptr: *anyopaque) callconv(.c) *c.__AppEditorViewsGoToLine__ {
return @alignCast(@ptrCast(ptr));
}
// # __AppEditorViewsGoToLine_goToEndOfLine__
fn __AppEditorViewsGoToLine_goToEndOfLine__(t: *c.__AppEditorViewsGoToLine__) callconv(.c) void {
t.symbol = t.line.text_len;
if (t.symbol > c.__app__.terminal.output.size.x - 2) {
t.offset.x = c.__app__.terminal.output.size.x - 2;
} else {
t.offset.x = t.symbol;
}
t.need_redraw = true;
}
// # __AppEditorViewsGoToLine_goToLineFromInput__
fn __AppEditorViewsGoToLine_goToLineFromInput__(t: *c.__AppEditorViewsGoToLine__) !void {
var ok: bool = true;
if (t.line.text_len > 0) {
if (t.line.text_len > 0) {
const text = t.line.text[0..t.line.text_len];
if (true
and text.len > 0
and text.len <= c.__u64FromTextDec_maxLen__
) {
const num: usize = @truncate(c.__u64FromTextDec__(text.ptr, text.len));
t.context_vtable.*.goToLineFromNumber.?(t.context, num);
try __AppEditorViewsGoToLine_cancel__(t);
} else {
ok = false;
}
} else {
ok = false;
}
} else {
ok = false;
}
if (!ok) {
t.context_vtable.*.goToLineFromNumber.?(t.context, 0);
try __AppEditorViewsGoToLine_cancel__(t);
return error.Unexpected;
}
}
// # __AppEditorViewsGoToLine_goToNextSymbol__
fn __AppEditorViewsGoToLine_goToNextSymbol__(t: *c.__AppEditorViewsGoToLine__) callconv(.c) void {
const used = t.line.text_len;
if (t.symbol >= used) {
if (true) return;
if (t.line.next) |_| {
t.goToNextLine();
t.goToStartOfText();
}
return;
}
if (t.symbol < c.__AppEditorLineLen_max__ - 1) t.symbol += 1;
if (used - t.symbol >= 10) {
if (t.offset.x < c.__app__.terminal.output.size.x - 12) t.offset.x += 1;
} else {
if (t.offset.x < c.__app__.terminal.output.size.x - 2) t.offset.x += 1;
}
t.need_redraw = true;
}
// # __AppEditorViewsGoToLine_goToPrevSymbol__
fn __AppEditorViewsGoToLine_goToPrevSymbol__(t: *c.__AppEditorViewsGoToLine__) callconv(.c) void {
const used = t.line.text_len;
if (t.symbol == 0) {
if (true) return;
if (t.line.prev) |_| {
t.goToPrevLine();
t.goToEndOfLine();
}
return;
}
if (t.symbol > used) {
t.symbol = used;
if (used < c.__app__.terminal.output.size.x - 1) t.offset.x = t.line.text_len;
t.need_redraw = true;
return;
}
if (t.symbol > 0) t.symbol -= 1;
if (t.symbol >= 10) {
if (t.offset.x > 10) {
t.offset.x -= 1;
}
} else {
if (t.offset.x > 0) t.offset.x -= 1;
}
t.need_redraw = true;
}
// # __AppEditorViewsGoToLine_goToStartOfLine__
fn __AppEditorViewsGoToLine_goToStartOfLine__(t: *c.__AppEditorViewsGoToLine__) callconv(.c) void {
t.symbol = 0;
t.offset.x = 0;
t.need_redraw = true;
}
// # __AppEditorViewsGoToLine_goToStartOfText__
fn __AppEditorViewsGoToLine_goToStartOfText__(t: *c.__AppEditorViewsGoToLine__) callconv(.c) void {
if (t.line.text_len > 0) {
const text = t.line.text[0..t.line.text_len];
const indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
__AppEditorViewsGoToLine_goToSymbol__(t, indent);
} else __AppEditorViewsGoToLine_goToSymbol__(t, 0);
}
// # __AppEditorViewsGoToLine_goToSymbol__
fn __AppEditorViewsGoToLine_goToSymbol__(t: *c.__AppEditorViewsGoToLine__, pos: usize) callconv(.c) void {
t.symbol = pos;
if (t.symbol > c.__app__.terminal.output.size.x - 3) {
t.offset.x = 8;
} else {
t.offset.x = t.symbol;
}
t.need_redraw = true;
}
// # __AppEditorViewsGoToLine_init__
fn __AppEditorViewsGoToLine_init__(t: *c.__AppEditorViewsGoToLine__) !void {
t.need_redraw = true;
t.offset.x = 0;
t.offset.y = 3;
t.symbol = 0;
c.__AppEditorLine_init__(&t.line);
}
// # __AppEditorViewsGoToLine_insertSymbol__
fn __AppEditorViewsGoToLine_insertSymbol__(t: *c.__AppEditorViewsGoToLine__, rune: u8) !void {
if (t.symbol > t.line.text_len) __AppEditorViewsGoToLine_goToSymbol__(t, t.line.text_len);
if (t.line.text_len < c.__AppEditorLineLen_max__) {
c.__Buffer_push__(&t.line.text[0], &t.line.text_len, t.symbol, rune);
__AppEditorViewsGoToLine_goToNextSymbol__(t);
}
t.need_redraw = true;
}
// # __AppEditorViewsGoToLine_onKey__
fn __AppEditorViewsGoToLine_onKey__(ctx: ?*anyopaque, cik: c.__ConsoleAnsiInputKey__) callconv(.c) void {
__AppEditorViewsGoToLine_onkeyWrap__(ctx, cik) catch {};
}
// # __AppEditorViewsGoToLine_onkeyWrap__
fn __AppEditorViewsGoToLine_onkeyWrap__(ctx: ?*anyopaque, cik: c.__ConsoleAnsiInputKey__) !void {
const t = __AppEditorViewsGoToLine_getModel__(ctx.?);
switch (cik) {
c.__ConsoleAnsiInputKey_ctrl_left__ => __AppEditorViewsGoToLine_ctrlLeft__(t),
c.__ConsoleAnsiInputKey_ctrl_right__ => __AppEditorViewsGoToLine_ctrlRight__(t),
c.__ConsoleAnsiInputKey_delete__ => __AppEditorViewsGoToLine_deleteSymbol__(t),
c.__ConsoleAnsiInputKey_shift_delete__ => __AppEditorViewsGoToLine_clearLine__(t),
c.__ConsoleAnsiInputKey_ctrl_w__ => __AppEditorViewsGoToLine_clearLine__(t),
c.__ConsoleAnsiInputKey_left__ => __AppEditorViewsGoToLine_goToPrevSymbol__(t),
c.__ConsoleAnsiInputKey_right__ => __AppEditorViewsGoToLine_goToNextSymbol__(t),
c.__ConsoleAnsiInputKey_escape__ => try __AppEditorViewsGoToLine_cancel__(t),
c.__ConsoleAnsiInputKey_ctrl_q__ => try __AppEditorViewsGoToLine_cancel__(t),
c.__ConsoleAnsiInputKey_back_space__ => try __AppEditorViewsGoToLine_deletePrevSymbol__(t),
c.__ConsoleAnsiInputKey_ctrl_bs__ => try __AppEditorViewsGoToLine_deletePrevSymbol__(t),
c.__ConsoleAnsiInputKey_ctrl_j__ => try __AppEditorViewsGoToLine_goToLineFromInput__(t),
c.__ConsoleAnsiInputKey_enter__ => try __AppEditorViewsGoToLine_goToLineFromInput__(t),
else => {
const byte: u8 = @truncate(cik);
switch (byte) {
'0'...'9' => __AppEditorViewsGoToLine_insertSymbol__(t, byte) catch {},
else => {},
}
},
}
}
// # __AppEditorViewsGoToLine_setAsView__
fn __AppEditorViewsGoToLine_setAsView__(t: *c.__AppEditorViewsGoToLine__, last_context: *anyopaque, last_vtable: *const c.__AppEditorViewsVTable__) callconv(.c) void {
t.context = last_context;
t.context_vtable = last_vtable;
c.__app__.editor.do_ptr = @ptrCast(&__AppEditorViewsGoToLine_do__);
c.__app__.editor.onKey_ptr = &__AppEditorViewsGoToLine_onKey__;
c.__app__.editor.current_ctx = t;
t.need_redraw = true;
}
// # __AppEditorViewsReplace_CtrlShiftLeft__
fn __AppEditorViewsReplace_CtrlShiftLeft__(t: *c.__AppEditorViewsReplace__) callconv(.c) void {
if (t.line.text_len > 0) {
const text = t.line.text[0..t.line.text_len];
const indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
if (t.symbol > indent) {
t.goToSymbol(indent);
} else t.goToStartOfLine();
} else t.goToSymbol(0);
t.need_redraw = true;
}
// # __AppEditorViewsReplace_CtrlShiftRight__
fn __AppEditorViewsReplace_CtrlShiftRight__(t: *c.__AppEditorViewsReplace__) callconv(.c) void {
if (t.line.text_len > 0) {
const text = t.line.text[0..t.line.text_len];
const indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
if (t.symbol < indent) t.goToSymbol(indent) else t.goToEndOfLine();
} else t.goToSymbol(0);
t.need_redraw = true;
}
// # __AppEditorViewsReplace_cancel__
fn __AppEditorViewsReplace_cancel__(t: *c.__AppEditorViewsReplace__) !void {
t.context_vtable.*.setAsView.?(t.context);
}
// # __AppEditorViewsReplace_clearLine__
fn __AppEditorViewsReplace_clearLine__(t: *c.__AppEditorViewsReplace__) callconv(.c) void {
t.line.text_len = 0;
__AppEditorViewsReplace_goToStartOfText__(t);
t.need_redraw = true;
}
// # __AppEditorViewsReplace_correctOffset__
fn __AppEditorViewsReplace_correctOffset__(t: *c.__AppEditorViewsReplace__) callconv(.c) void {
const predel = (c.__app__.terminal.output.size.y >> 1) - (c.__app__.terminal.output.size.y >> 4);
if (t.symbol >= predel) t.offset.x = predel;
}
// # __AppEditorViewsReplace_ctrlLeft__
fn __AppEditorViewsReplace_ctrlLeft__(t: *c.__AppEditorViewsReplace__) callconv(.c) void {
__AppEditorViewsReplace_goToPrevSymbol__(t);
if (t.symbol > 0) {
var jump_symbol: usize = 0;
const line: *c.__AppEditorLine__ = &t.line;
if (line.text_len > 0) {
const full_text = line.text[0..line.text_len];
const text = full_text[0 .. t.symbol];
const spaces = c.__TextAscii_countIndentReverse__(text.ptr, text.len, 1);
if (spaces > 0) {
__AppEditorViewsReplace_goToSymbol__(t, t.symbol - spaces);
t.need_redraw = true;
return;
}
const dest_pos = c.__TextAscii_findBreakOfWordReverse__(text.ptr, text.len) + 1;
jump_symbol = dest_pos;
}
__AppEditorViewsReplace_goToSymbol__(t, jump_symbol);
t.need_redraw = true;
}
}
// # __AppEditorViewsReplace_ctrlRight__
fn __AppEditorViewsReplace_ctrlRight__(t: *c.__AppEditorViewsReplace__) callconv(.c) void {
__AppEditorViewsReplace_goToNextSymbol__(t);
if (t.line.text_len > 0) {
const full_text = t.line.text[0..t.line.text_len];
if (t.symbol >= full_text.len) return;
const text = full_text[t.symbol..];
const indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
if (indent > 0) {
__AppEditorViewsReplace_goToSymbol__(t, t.symbol + indent);
t.need_redraw = true;
return;
}
__AppEditorViewsReplace_goToSymbol__(t, c.__TextAscii_findBreakOfWord__(text.ptr, text.len) + t.symbol);
t.need_redraw = true;
}
}
// # __AppEditorViewsReplace_cursorMoveToCurrent__
fn __AppEditorViewsReplace_cursorMoveToCurrent__(t: *c.__AppEditorViewsReplace__) !void {
c.__Terminal_cursorMove__(&c.__app__.terminal, t.offset.x, t.offset.y);
}
// # __AppEditorViewsReplace_deletePrevSymbol__
fn __AppEditorViewsReplace_deletePrevSymbol__(t: *c.__AppEditorViewsReplace__) !void {
if (t.symbol == 0) {
return;
} else if (t.symbol > t.line.text_len) {
__AppEditorViewsReplace_goToPrevSymbol__(t);
} else {
if (t.line.text_len == 0) return;
__AppEditorViewsReplace_goToPrevSymbol__(t);
__AppEditorViewsReplace_deleteSymbol__(t);
}
t.need_redraw = true;
}
// # __AppEditorViewsReplace_deleteSymbol__
fn __AppEditorViewsReplace_deleteSymbol__(t: *c.__AppEditorViewsReplace__) callconv(.c) void {
if (t.line.text_len == 0) return;
if (c.__Buffer_pop_check__(t.line.text_len, t.symbol)) {
_=c.__Buffer_pop__(&t.line.text[0], &t.line.text_len, t.symbol);
}
t.need_redraw = true;
}
// # __AppEditorViewsReplace_deleteWord__
fn __AppEditorViewsReplace_deleteWord__(t: *c.__AppEditorViewsReplace__) !void {
if (t.symbol > t.line.text_len) {
return;
}
while (true) { // delete current symbol
if (t.symbol == t.line.text_len) {
break;
}
const next_symbol = t.line.text[t.symbol];
if (c.__TextAscii_isLetter__(next_symbol)) {
__AppEditorViewsReplace_deleteSymbol__(t);
} else {
break;
}
}
while (true) { // delete prev symbol
if (t.symbol == 0) {
break;
}
const prev_symbol = t.line.text[t.symbol - 1];
if (c.__TextAscii_isLetter__(prev_symbol)) {
try __AppEditorViewsReplace_deletePrevSymbol__(t);
} else {
break;
}
}
t.need_redraw = true;
}
// # __AppEditorViewsReplace_do__
fn __AppEditorViewsReplace_do__(ctx: *anyopaque) callconv(.c) void {
const t = __AppEditorViewsReplace_getModel__(ctx);
if (t.need_redraw == true) {
t.need_redraw = false;
__AppEditorViewsReplace_draw__(t) catch unreachable;
__AppEditorViewsReplace_cursorMoveToCurrent__(t) catch unreachable;
}
}
// # __AppEditorViewsReplace_drawEditedLine__
fn __AppEditorViewsReplace_drawEditedLine__(t: *c.__AppEditorViewsReplace__) !void {
if (t.line.text_len > 0) {
const text = t.line.text[0..t.line.text_len];
c.__Terminal_moveCursorToStartOfLine__(&c.__app__.terminal);
// change color
c.__Terminal_resetColors__(&c.__app__.terminal);
const text_color: [*]const u8 = c.__AppEditorTheme_current__;
const text_color_len: usize = c.__AppEditorTheme_current__.len;
// draw left-to-right from first visible rune
var pos: usize = t.symbol - t.offset.x;
var offset_x: usize = 0;
// left arrow
if (pos > 0) { // draw '<'
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_arrows__, c.__AppEditorTheme_arrows__.len);
_=__writeTextToWriteFnVoid__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, "<");
pos += 1;
offset_x += 1;
}
// left symbols
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, text_color, text_color_len);
while (true) {
if (offset_x >= t.offset.x) break;
if (offset_x >= c.__app__.terminal.output.size.x - 1) break;
if (pos >= text.len) break;
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[pos], 1);
pos += 1;
offset_x += 1;
}
// current symbol. maybe inverse cursour?
if (offset_x >= c.__app__.terminal.output.size.x - 2) return;
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_current_rune__, c.__AppEditorTheme_current_rune__.len);
if (pos < text.len) {
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[pos], 1);
}
pos += 1;
offset_x += 1;
// right symbols
c.__Terminal_setFontStyle__(&c.__app__.terminal, text_color, text_color_len);
while (true) {
if (offset_x >= c.__app__.terminal.output.size.x - 2) break;
if (pos >= text.len) break;
c.__Terminal_writeToOutput__(&c.__app__.terminal, &text[pos], 1);
pos += 1;
offset_x += 1;
}
// right arrow
if (pos < text.len) { // draw '>'
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_arrows__, c.__AppEditorTheme_arrows__.len);
const tt: []const u8 = ">";
_=c.__Terminal_writeToOutput__(&c.__app__.terminal, tt.ptr, tt.len);
} else {
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_to_end_line__, 0);
}
} else {
c.__Terminal_resetColors__(&c.__app__.terminal);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_line__, 0);
}
}
// # __AppEditorViewsReplace_draw__
fn __AppEditorViewsReplace_draw__(t: *c.__AppEditorViewsReplace__) !void {
defer __AppEditorViewsReplace_cursorMoveToCurrent__(t) catch {};
__AppEditorViewsReplace_correctOffset__(t);
if (t.offset.x >= c.__app__.terminal.output.size.x) t.offset.x = 0;
if (t.offset.y >= c.__app__.terminal.output.size.y) t.offset.y = 0;
if (t.symbol < t.offset.x) { // unexpected
t.offset.x = 0;
t.symbol = 0;
}
c.__ConsoleOutput_cursorHide__(&c.__app__.console.output);
defer c.__Console_showCursor__(&c.__app__.console);
t.offset.y = 1;
{ // draw banner
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, 0);
c.__Terminal_setFontStyle__(&c.__app__.terminal, c.__AppEditorTheme_headers__, c.__AppEditorTheme_headers__.len);
_=__writeTextToWriteFnVoid__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, "text for replace:");
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_to_end_line__, 0);
}
{ // draw edit line
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, 1);
defer __AppEditorViewsReplace_cursorMoveToCurrent__(t) catch {};
try __AppEditorViewsReplace_drawEditedLine__(t);
}
var pos_y: usize = 2;
while (true) { // clear other downer lines
if (pos_y >= c.__app__.terminal.output.size.y) return;
c.__Terminal_cursorMove__(&c.__app__.terminal, 0, pos_y);
c.__Console_clearLine__(&c.__app__.console);
pos_y += 1;
}
}
// # __AppEditorViewsReplace_find__
fn __AppEditorViewsReplace_find__(t: *c.__AppEditorViewsReplace__) !void {
_ = t;
const view = &c.__app__.editor.views.flat;
try view.setAsView();
try view.findNext();
}
// # __AppEditorViewsReplace_getModel__
fn __AppEditorViewsReplace_getModel__(ptr: *anyopaque) callconv(.c) *c.__AppEditorViewsReplace__ {
return @alignCast(@ptrCast(ptr));
}
// # __AppEditorViewsReplace_get__
fn __AppEditorViewsReplace_get__(t: *c.__AppEditorViewsReplace__) callconv(.c) []const u8 {
return t.line.text[0 .. t.line.text_len];
}
// # __AppEditorViewsReplace_goToEndOfLine__
fn __AppEditorViewsReplace_goToEndOfLine__(t: *c.__AppEditorViewsReplace__) callconv(.c) void {
t.symbol = t.line.text_len;
if (t.symbol > c.__app__.terminal.output.size.x - 2) {
t.offset.x = c.__app__.terminal.output.size.x - 2;
} else {
t.offset.x = t.symbol;
}
t.need_redraw = true;
}
// # __AppEditorViewsReplace_goToNextSymbol__
fn __AppEditorViewsReplace_goToNextSymbol__(t: *c.__AppEditorViewsReplace__) callconv(.c) void {
const used = t.line.text_len;
if (t.symbol >= used) {
if (true) return;
if (t.line.next) |_| {
t.goToNextLine();
t.goToStartOfText();
}
return;
}
if (t.symbol < c.__AppEditorLineLen_max__ - 1) t.symbol += 1;
if (used - t.symbol >= 10) {
if (t.offset.x < c.__app__.terminal.output.size.x - 12) t.offset.x += 1;
} else {
if (t.offset.x < c.__app__.terminal.output.size.x - 2) t.offset.x += 1;
}
t.need_redraw = true;
}
// # __AppEditorViewsReplace_goToPrevSymbol__
fn __AppEditorViewsReplace_goToPrevSymbol__(t: *c.__AppEditorViewsReplace__) callconv(.c) void {
const used = t.line.text_len;
if (t.symbol == 0) {
if (true) return;
if (t.line.prev) |_| {
t.goToPrevLine();
t.goToEndOfLine();
}
return;
}
if (t.symbol > used) {
t.symbol = used;
if (used < c.__app__.terminal.output.size.x - 1) t.offset.x = t.line.text_len;
t.need_redraw = true;
return;
}
if (t.symbol > 0) t.symbol -= 1;
if (t.symbol >= 10) {
if (t.offset.x > 10) {
t.offset.x -= 1;
}
} else {
if (t.offset.x > 0) t.offset.x -= 1;
}
t.need_redraw = true;
}
// # __AppEditorViewsReplace_goToStartOfLine__
fn __AppEditorViewsReplace_goToStartOfLine__(t: *c.__AppEditorViewsReplace__) callconv(.c) void {
t.symbol = 0;
t.offset.x = 0;
t.need_redraw = true;
}
// # __AppEditorViewsReplace_goToStartOfText__
fn __AppEditorViewsReplace_goToStartOfText__(t: *c.__AppEditorViewsReplace__) callconv(.c) void {
if (t.line.text_len > 0) {
const text = t.line.text[0..t.line.text_len];
const indent = c.__TextAscii_countIndent__(text.ptr, text.len, 1);
__AppEditorViewsReplace_goToSymbol__(t, indent);
} else __AppEditorViewsReplace_goToSymbol__(t, 0);
}
// # __AppEditorViewsReplace_goToSymbol__
fn __AppEditorViewsReplace_goToSymbol__(t: *c.__AppEditorViewsReplace__, pos: usize) callconv(.c) void {
t.symbol = pos;
if (t.symbol > c.__app__.terminal.output.size.x - 3) {
t.offset.x = 8;
} else {
t.offset.x = t.symbol;
}
t.need_redraw = true;
}
// # __AppEditorViewsReplace_init__
fn __AppEditorViewsReplace_init__(t: *c.__AppEditorViewsReplace__) !void {
t.offset.x = 0;
t.offset.y = 3;
t.symbol = 0;
t.need_redraw = true;
c.__AppEditorLine_init__(&t.line);
}
// # __AppEditorViewsReplace_insertFindedText__
fn __AppEditorViewsReplace_insertFindedText__(t: *c.__AppEditorViewsReplace__) !void {
const text: []const u8 = __AppEditorViewsFind_get__(&c.__app__.editor.views.find) orelse return;
for (text) |rune| {
__AppEditorViewsReplace_insertSymbol__(t, rune) catch {};
}
t.need_redraw = true;
}
// # __AppEditorViewsReplace_insertSymbol__
fn __AppEditorViewsReplace_insertSymbol__(t: *c.__AppEditorViewsReplace__, rune: u8) !void {
if (t.symbol > t.line.text_len) __AppEditorViewsReplace_goToSymbol__(t, t.line.text_len);
if (t.line.text_len < c.__AppEditorLineLen_max__) {
c.__Buffer_push__(&t.line.text[0], &t.line.text_len, t.symbol, rune);
__AppEditorViewsReplace_goToNextSymbol__(t);
}
t.need_redraw = true;
}
// # __AppEditorViewsReplace_onKey__
fn __AppEditorViewsReplace_onKey__(ctx: ?*anyopaque, cik: c.__ConsoleAnsiInputKey__) callconv(.c) void {
__AppEditorViewsReplace_onkeyWrap__(ctx, cik) catch {};
}
// # __AppEditorViewsReplace_onkeyWrap__
fn __AppEditorViewsReplace_onkeyWrap__(ctx: ?*anyopaque, cik: c.__ConsoleAnsiInputKey__) !void {
const t: *c.__AppEditorViewsReplace__ = @ptrCast(@alignCast(ctx));
switch (cik) {
c.__ConsoleAnsiInputKey_ctrl_left__ => __AppEditorViewsReplace_ctrlLeft__(t),
c.__ConsoleAnsiInputKey_ctrl_right__ => __AppEditorViewsReplace_ctrlRight__(t),
c.__ConsoleAnsiInputKey_delete__ => __AppEditorViewsReplace_deleteSymbol__(t),
c.__ConsoleAnsiInputKey_shift_delete__ => __AppEditorViewsReplace_clearLine__(t),
c.__ConsoleAnsiInputKey_left__ => __AppEditorViewsReplace_goToPrevSymbol__(t),
c.__ConsoleAnsiInputKey_right__ => __AppEditorViewsReplace_goToNextSymbol__(t),
c.__ConsoleAnsiInputKey_escape__ => try __AppEditorViewsReplace_cancel__(t),
c.__ConsoleAnsiInputKey_ctrl_w__ => try __AppEditorViewsReplace_deleteWord__(t),
c.__ConsoleAnsiInputKey_back_space__ => try __AppEditorViewsReplace_deletePrevSymbol__(t),
c.__ConsoleAnsiInputKey_ctrl_bs__ => try __AppEditorViewsReplace_deletePrevSymbol__(t),
c.__ConsoleAnsiInputKey_ctrl_j__ => try __AppEditorViewsReplace_cancel__(t),
c.__ConsoleAnsiInputKey_ctrl_q__ => try __AppEditorViewsReplace_cancel__(t),
c.__ConsoleAnsiInputKey_enter__ => try __AppEditorViewsReplace_cancel__(t),
c.__ConsoleAnsiInputKey_alt_4__ => try __AppEditorViewsReplace_insertFindedText__(t),
else => {
const byte: u8 = @truncate(cik);
__AppEditorViewsReplace_insertSymbol__(t, byte) catch {};
},
}
}
// # __AppEditorViewsReplace_setAsView__
fn __AppEditorViewsReplace_setAsView__(t: *c.__AppEditorViewsReplace__, last_context: *anyopaque, last_vtable: *const c.__AppEditorViewsVTable__) callconv(.c) void {
t.context = last_context;
t.context_vtable = last_vtable;
c.__app__.editor.do_ptr = @ptrCast(&__AppEditorViewsReplace_do__);
c.__app__.editor.onKey_ptr = &__AppEditorViewsReplace_onKey__;
c.__app__.editor.current_ctx = t;
t.need_redraw = true;
}
// # __AppEditorViews_deinit__
fn __AppEditorViews_deinit__(t: *c.__AppEditorViews__) callconv(.c) void {
__zig_fuck__(t);
//t.find.deinit(); // todo
//t.go_to_line.deinit();
//t.replace.deinit();
//t.folded.deinit();
//t.flat.deinit();
}
// # __AppEditorViews_init__
fn __AppEditorViews_init__(views: *c.__AppEditorViews__) !void {
try __AppEditorViewsFlat_init__ (&views.flat);
try __AppEditorViewsFolded_init__(&views.folded);
try __AppEditorViewsGoToLine_init__(&views.go_to_line);
try __AppEditorViewsReplace_init__(&views.replace);
try __AppEditorViewsFind_init__(&views.find);
}
// # __AppEditor_changeStatus__
fn __AppEditor_changeStatus__(text: []const u8) void {
c.__AppEditor_changeStatus__(text.ptr, text.len);
}
// # __AppEditor_deinit__
fn __AppEditor_deinit__(t: *c.__AppEditor__) callconv(.c) void {
if (t.inited == false) return;
__AppEditorViews_deinit__(&t.views);
}
// # __AppEditor_do__
fn __AppEditor_do__(t: *c.__AppEditor__) !bool {
if (t.do_ptr) |do_ptr| do_ptr(t.current_ctx.?);
if (t.working == false) return false;
return true;
}
// # __AppEditor_init__
fn __AppEditor_init__(t: *c.__AppEditor__) !void {
__AppEditorViewsFlatVtable_init__(&c.__AppEditorViewsVtable_flat__);
__AppEditorViewsFoldedVtable_init__(&c.__AppEditorViewsVtable_folded__);
t.do_ptr = null;
t.onKey_ptr = null;
t.current_ctx = &t.views.flat;
t.current_vtable = &c.__AppEditorViewsVtable_flat__;
t.working = true;
t.__AppEditor_endLine__ = "\n";
t.__AppEditor_endLine_len__ = "\n".len;
t.lines_drawing = 0;
c.__MemList_init__(&t.history);
t.start_record_link = @alignCast(@ptrCast(c.NULL));
t.stop_record_link = @alignCast(@ptrCast(c.NULL));
t.recording_macro = false;
try __AppEditor_updatePathToClipboard__(t);
try __AppEditorViews_init__(&t.views);
t.inited = true;
}
// # __AppEditor_onKey__
fn __AppEditor_onKey__(t: *c.__AppEditor__, key: c.__ConsoleAnsiInputKey__) callconv(.c) void {
__AppEditor_onKeyWrap__(t, key) catch {};
}
fn __AppEditor_onKeyWrap__(t: *c.__AppEditor__, key: c.__ConsoleAnsiInputKey__) !void {
switch (key) {
c.__ConsoleAnsiInputKey_f1__ => _=c.__AppEditor_startRecordMacro__(t),
c.__ConsoleAnsiInputKey_f2__ => _=c.__AppEditor_stopRecordMacro__(t), // ignore error
c.__ConsoleAnsiInputKey_f3__ => try __AppEditor_playMacro__(t),
else => {
if (c.__AppEditor_addKeyToHistory__(t, key)) {
const on_key = t.onKey_ptr orelse return;
on_key(t.current_ctx, key);
} else {
return error.Unexpected;
}
},
}
}
// # __AppEditor_parse_text_to_lines__
fn __AppEditor_parse_text_to_lines__(
t: *c.__AppEditor__,
list: *c.__MemList__, // list for store c.__AppEditorLine__.link
text_ptr: [*]const u8,
text_len: usize
) !void {
var ok: bool = true;
var line_num: usize = 0;
var unparsed_len: usize = text_len;
while (ok and unparsed_len > 0) {
line_num += 1;
const line_pos: usize = text_len - unparsed_len;
var line_text_len: usize = 0;
if (unparsed_len > "\n".len and c.__Mem_findFast__(&line_text_len, text_ptr[line_pos..], unparsed_len, "\n", 1)) {
unparsed_len -= line_text_len + "\n".len;
const line_text: []const u8 = text_ptr[line_pos .. line_pos + line_text_len];
if (line_text_len > 0 and line_text[line_text_len - 1] == '\r') {
t.__AppEditor_endLine__ = "\r\n";
t.__AppEditor_endLine_len__ = "\r\n".len;
line_text_len -= "\r".len;
}
} else {
line_text_len = unparsed_len;
unparsed_len = 0;
}
const line_text: []const u8 = text_ptr[line_pos .. line_pos + line_text_len];
if (line_text_len < c.__AppEditorLineLen_max__) {
var line: *c.__AppEditorLine__ = undefined;
if ( c.__AppEditorLine_alloc__(@ptrCast(&line)) ) {
c.__AppEditorLine_init__(line);
line.text_len = line_text_len;
c.__Mem_copy__(&line.text[0], line_text.ptr, line_text_len);
c.__MemList_pushLast__(list, &line.link);
if (!ok) {
const link: *c.__MemListLink__ = list.last.?;
c.__MemList_pop__(list, link);
}
//if (!ok) c.__AppEditorLine_free__(line);
} else {
_=c.printf("%d, line not allocated", @src().line, line_num);
ok = false;
}
} else {
_=c.printf("%d, line %d is too long", @src().line, line_num);
ok = false;
}
}
if (!ok) {
while(list.count > 0) { // deallocating lines
const link: *c.__MemListLink__ = list.first.?;
c.__MemList_pop__(list, link);
const line: *c.__AppEditorLine__ = @fieldParentPtr("link", link);
c.__AppEditorLine_free__(line);
}
}
if (!ok) return error.Unexpected;
return; // ok;
}
// # __AppEditor_playMacro__
fn __AppEditor_playMacro__(t: *c.__AppEditor__) !void {
if (t.recording_macro != true) {
if ( true
and (@intFromPtr(t.start_record_link) != @intFromPtr(c.NULL))
and (@intFromPtr(t.stop_record_link) != @intFromPtr(c.NULL))
) {
const sr: *c.__MemListLink__ = @ptrCast(t.start_record_link);
// const lr: *c.__MemListLink__ = @ptrCast(t.stop_record_link);
var next_link: *allowzero c.__MemListLink__ = sr.next; // skipped start recording itself
while ( true
and ( @intFromPtr(next_link) != @intFromPtr(c.NULL) )
and (next_link != t.stop_record_link)
) {
const next_r: *c.__MemListLink__ = @ptrCast(next_link);
const history_note: *c.__AppEditorHistoryNote__ = @alignCast(@fieldParentPtr("link", next_r));
const key: c.__ConsoleAnsiInputKey__ = history_note.key;
__AppEditor_onKey__(t, key);
next_link = next_r.next;
}
} else {
__AppEditor_changeStatus__("macro not recorded.");
}
} else {
__AppEditor_changeStatus__("not aviable while recording");
}
}
// # __AppEditor_updatePathToClipboard__
fn __AppEditor_updatePathToClipboard__(t: *c.__AppEditor__) !void {
var ok: bool = true;
// full path: "{HOME}/clipboard.tmp"
var writed: usize = 0;
const buffer: [*c]u8 = &t.__AppEditor_pathToClipboard__[0];
const home_len = c.__OsEnvHome_getLen__();
if (home_len < c.__OsFilePathLen_max__) {
c.__OsEnvHome_write__(&buffer[writed]);
writed += home_len;
if ((@as(usize, c.__OsFilePathLen_max__) - writed) > c.__OsFilePath_separator__.len) {
c.__Mem_copy__(&buffer[writed], c.__OsFilePath_separator__.ptr, c.__OsFilePath_separator__.len);
writed += c.__OsFilePath_separator__.len;
const t2: []const u8 = "clipboard.tmp";
if ((@as(usize, c.__OsFilePathLen_max__) - writed) > t2.len) {
c.__Mem_copy__(&buffer[writed], t2.ptr, t2.len);
writed += t2.len;
t.__AppEditor_pathToClipboard_len__ = writed;
} else {
ok = false;
}
} else {
ok = false;
}
} else {
ok = false;
}
if (!ok) return error.NotOk;
}
// # __App_deinit__
fn __App_deinit__(app: *c.__App__) callconv(.c) bool {
var ok: bool = true;
__AppEditor_deinit__(&app.editor);
if (c.__Terminal_deinit__(&app.terminal)) {
c.__OsHelper_deinit__(&app.__App_osHelper__);
} else {ok = false;}
return ok;
}
// # __App_init__
fn __App_init__(app: *c.__App__) callconv(.c) bool {
var ok: bool = true;
if(c.__OsHelper_init__(&app.__App_osHelper__)) {
c.__Console_init__(&app.console, app.__App_osHelper__.console_input_handle, app.__App_osHelper__.console_output_handle);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, c.__ConsoleAnsi_output_clear_line__, 0);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, "\r", 0);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, "- - - OwO - - -", 0);
const flat = &app.editor.views.flat;
const folded = &app.editor.views.folded;
if (c.__Terminal_init__(&app.terminal, &app.console)) {
if (__AppEditor_init__(&app.editor)) {
if (__App_parseArgsAndDo__(app)) {
if (__AppEditorViewsFlat_setAsView__(flat)){
if (__AppEditorViewsFlat_fold__(flat)) {
if (__AppEditorViewsFolded_markThisLine__(folded)) {
app.working = true;
} else |_| {
ok = false;
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " fail markThisLine\r\n", 0);
}
} else |_| {
ok = false;
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " fail flat.fold\r\n", 0);
}
} else |_| {
ok = false;
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " fail flat.setAsView\r\n", 0);
}
} else |_| {
ok = false;
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " fail parse args\r\n", 0);
}
if (!ok) __AppEditor_deinit__(&app.editor);
} else |_| {
ok = false;
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " fail __AppEditor_init__\r\n", 0);
}
if (!ok) {
if (c.__Terminal_deinit__(&app.terminal)) {
} else {
ok = false;
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " fail c.__Terminal_deinit__\r\n", 0);
}
}
} else {
ok = false;
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " fail c.__Terminal_init__\r\n", 0);
}
if (!ok) c.__OsHelper_deinit__(&app.__App_osHelper__);
} else {
ok = false;
_=c.__Text_formatU64__(@ptrCast(&c.__OsFallbackConsole_write__), null, @src().line, 1);
_=c.__ZText_writeToWriteFn__(@ptrCast(&c.__OsFallbackConsole_write__), null, " fail App_Os_Helper_init...\r\n".ptr);
}
return ok;
}
// # __App_loop__
fn __App_loop__(app: *c.__App__) !void {
app.tick = std.time.milliTimestamp();
while (app.working) {
// app.__App_osHelper__
c.__OsHelper_process__(&app.__App_osHelper__);
if (app.working == false) break;
// update terminal
c.__Terminal_updateOutputSize__(&app.terminal);
// terminal keyboard
while(true) {
c.__Terminal_updateInputBuffer__(&app.terminal);
var key: c.__ConsoleAnsiInputKey__ = undefined;
if (c.__TerminalInput_grab__(&key, &app.terminal.input)) {
__AppEditor_onKey__(&app.editor, key); // todo rename to onConsoleKey
} else {
break;
}
}
const editor_result = try __AppEditor_do__(&app.editor);
if (editor_result != true) break;
// sleep to next frame
const expected_frame_end_time = app.tick + c.__Time_msPerS__ / c.__App_expectedFps__;
const resulting_frame_end_time = std.time.milliTimestamp();
const delay_sleep = if (resulting_frame_end_time < expected_frame_end_time) expected_frame_end_time - resulting_frame_end_time else 1;
c.__Os_sleep__(@intCast(delay_sleep));
app.tick = resulting_frame_end_time + delay_sleep;
}
}
// # __App_parseArgsAndDo__
fn __App_parseArgsAndDo__(t: *c.__App__) !void {
var ok: bool = true;
var argIterator = std.process.ArgIteratorPosix.init();
_ = argIterator.skip(); // skip name of programm
if (argIterator.next()) |name_arg| { // first arg: file name
c.__Console_clearLine__(&c.__app__.console);
c.__Terminal_moveCursorToStartOfLine__(&t.terminal);
// print("opening file {name_arg}");
_=__writeTextToWriteFnVoid__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, "opening file ");
c.__Terminal_writeToOutput__(&c.__app__.terminal, name_arg.ptr, name_arg.len);
if (name_arg.len < c.__OsFilePathLen_max__) {
c.__Mem_copy__(&t.editor.__AppEditor_fileName__[0], name_arg.ptr, name_arg.len);
t.editor.__AppEditor_fileName_len__ = name_arg.len;
if (c.__OsFile_exist__(name_arg.ptr, name_arg.len)) {
var file: c.__OsFileHandle__ = undefined;
if (c.__OsFile_open__(&file, name_arg.ptr, name_arg.len)) {
const file_size: usize = c.__OsFile_getSize__(file);
if (file_size < c.__MemSize_gb__) {
c.__Console_clearLine__(&c.__app__.console);
c.__Terminal_moveCursorToStartOfLine__(&t.terminal);
_=__writeTextToWriteFnVoid__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, "file opened... ");
var text_ptr: [*c]u8 = undefined;
if (c.__OsMem_allocAny__(&text_ptr, file_size)) {
c.__Console_clearLine__(&c.__app__.console);
c.__Terminal_moveCursorToStartOfLine__(&t.terminal);
_=__writeTextToWriteFnVoid__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, "memory allocated... ");
if (c.__OsFile_readToBuffer__(file, text_ptr, file_size, 0)) {
c.__Console_clearLine__(&c.__app__.console);
c.__Terminal_moveCursorToStartOfLine__(&t.terminal);
_=__writeTextToWriteFnVoid__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, "readed to memory... ");
if (__AppEditor_parse_text_to_lines__(&t.editor, &t.editor.views.flat.lines, text_ptr, file_size)) {
c.__Console_clearLine__(&c.__app__.console);
c.__Terminal_moveCursorToStartOfLine__(&t.terminal);
_=__writeTextToWriteFnVoid__(@ptrCast(&c.__Terminal_writeToOutput__), &c.__app__.terminal, "parsed to lines... ");
const fll: *c.__MemListLink__ = t.editor.views.flat.lines.first;
if (@intFromPtr(fll) != @intFromPtr(c.NULL)) {
const line: *c.__AppEditorLine__ = @fieldParentPtr("link", fll);
t.editor.views.flat.line = line;
} else {
var line: *c.__AppEditorLine__ = undefined;
if (c.__AppEditorLine_alloc__( @ptrCast(&line) ) ) {
t.editor.views.flat.line = line;
c.__AppEditorLine_init__(line);
c.__MemList_pushLast__(&t.editor.views.flat.lines, &t.editor.views.flat.line.*.link);
if (!ok) c.__AppEditorLine_free__(line);
}
}
if (ok) { // second arg: line number
if (argIterator.next()) |number_arg| {
// write to go_to_line.line
const line: *c.__AppEditorLine__ = &t.editor.views.go_to_line.line;
line.text_len = number_arg.len;
c.__Mem_copy__(&line.text[0], number_arg.ptr, number_arg.len);
if (number_arg.len > 0 and number_arg.len <= c.__u64FromTextDec_maxLen__) {
const line_number = c.__u64FromTextDec__(number_arg.ptr, number_arg.len);
__AppEditorViewsFlat_goToLineFromNumber__(&t.editor.views.flat, @intCast(line_number));
} else {
ok = false;
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " \r\n", 0);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " second argument used only for set LINE_NUMBER\r\n", 0);
}
}
}
} else |err| {
ok = false;
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " \r\n", 0);
_=c.printf(" error: {%s}\r\n", @errorName(err).ptr);
_=c.printf(" line num: {%d}\r\n", t.editor.views.flat.lines.count);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " \r\n", 0);
}
if (!ok) { // free editor lines
const list_lines: *c.__MemList__ = &t.editor.views.flat.lines;
while (list_lines.count > 0) {
const link: *c.__MemListLink__ = list_lines.first orelse unreachable;
c.__MemList_pop__(list_lines, link);
const line: *c.__AppEditorLine__ = @fieldParentPtr("link", link);
c.__AppEditorLine_free__(line);
}
}
} else {
ok = false;
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " \r\n", 0);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " ScalpiEditor not have super cow power.\r\n", 0);
}
c.__OsMem_freeAny__(text_ptr);
} else {
ok = false;
}
} else {
ok = false;
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " \r\n", 0);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " error: file is too large\r\n", 0);
}
c.__OsFile_close__(file);
} else {
ok = false;
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " \r\n", 0);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " error: file not opened\r\n", 0);
}
} else {
ok = false;
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " \r\n", 0);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " error: file not exist.\r\n", 0);
}
} else {
ok = false;
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " \r\n", 0);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " error: strange file path\r\n", 0);
}
} else {
ok = false;
}
if (!ok) {
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " \r\n", 0);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " usage: $ ScalpiEditor FILE_NAME LINE_NUMBER\r\n", 0);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " Insert coin and try again!\r\n", 0);
_=c.__OsConsoleOutput_write__(&c.__app__.console.output, " \r\n", 0);
}
if (!ok) return error.Unexpected;
}
// # __writeTextToWriteFnVoid__
fn __writeTextToWriteFnVoid__(write: c.__WriteFnPtrVoid__, context: *anyopaque, text: []const u8) usize {
// use callconv(.c) for target function
write.?(context, text.ptr, text.len);
return text.len;
}
// # __zig_fuck__
fn __zig_fuck__(whom: anytype) void {
_ = whom;
}
// # __zig_writeToBuffer__
fn __zig_writeToBuffer__(buffer: [*c]u8, text: []const u8) usize {
c.__Mem_copy__(buffer, text.ptr, text.len);
return text.len;
}
// # main
pub fn main() u8 {
@setRuntimeSafety(false);
const ok: bool = real_main();
if (ok) {return 0;}
return 1;
}
// # real_main
fn real_main() callconv(.c) bool {
var ok: bool = true;
_=c.__Text_formatU64__(@ptrCast(&c.__OsFallbackConsole_write__), null, @src().line, 1);
_=c.__ZText_writeToWriteFn__(@ptrCast(&c.__OsFallbackConsole_write__), null, " testing...\r".ptr);
if (c.tests()) {
if (__App_init__(&c.__app__)) {
__App_loop__(&c.__app__) catch return;
if (__App_deinit__(&c.__app__)) {
} else {
ok = false;
// print("%d: app_deinit failed \r\n", @src().line);
_=c.__Text_formatU64__(@ptrCast(&c.__OsFallbackConsole_write__), null, @src().line, 1);
_=c.__ZText_writeToWriteFn__(@ptrCast(&c.__OsFallbackConsole_write__), null, " app deinit failed...\r\n".ptr);
}
} else {
ok = false;
// c.printf("%d: fail __App_init__\r\n", @src().line);
_=c.__Text_formatU64__(@ptrCast(&c.__OsFallbackConsole_write__), null, @src().line, 1);
_=c.__ZText_writeToWriteFn__(@ptrCast(&c.__OsFallbackConsole_write__), null, " fail __App_init__\r\n".ptr);
}
} else {
ok = false;
// _=c.printf("%d: tests failed \r\n", @src().line);
_=c.__Text_formatU64__(@ptrCast(&c.__OsFallbackConsole_write__), null, @src().line, 1);
_=c.__ZText_writeToWriteFn__(@ptrCast(&c.__OsFallbackConsole_write__), null, " tests fail\r\n".ptr);
}
return ok;
}
|
Deleted src/Glyph.zig.
|
| < < < < < < < < |
Deleted src/Line.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/LinkedLine.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/Rune.zig.
|
| < < < < < < < < < < < < < |
Deleted src/ScalpiEditor.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/TODO.txt.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/Text.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/View.zig.bak.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/ViewEasyMotionH.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/ViewEasyMotionV.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/ViewFind.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/ViewFlat.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/ViewGoTo.zig.
|
| < < |
Deleted src/ViewRunes.zig.
|
| < < |
Deleted src/ViewTreeByBrackets.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/ViewTreeByIndent.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Console/build.zig.
|
| < < < < < < < < < < < |
Deleted src/external/Console/src/Cursor.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Console/src/Flags.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Console/src/Input.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Console/src/external/ansi/README.md.
|
| < < |
Deleted src/external/Console/src/external/ansi/build.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Console/src/external/ansi/src/ansi.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Console/src/external/ansi/src/main.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Console/src/external/lib/build.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Console/src/external/lib/src/lib.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Console/src/external/lib/src/main.zig.
|
| < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Console/src/lib.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Console/src/main.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Coor2u.zig.
|
| < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/LinkedList/build.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/LinkedList/src/Iterator.zig.
|
| < < < < < < < < < |
Deleted src/external/LinkedList/src/IteratorReversed.zig.
|
| < < < < < < < < < |
Deleted src/external/LinkedList/src/Link.zig.
|
| < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/LinkedList/src/LinkedList.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/LinkedList/src/Sample.zig.
|
| < < < < < < < < < < < |
Deleted src/external/LinkedList/src/Samples.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/LinkedList/src/linkedList.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/LinkedList/src/main.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Ranges/build.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Ranges/src/RangeU.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Ranges/src/main.zig.
|
| < < < < < < < < < < < < < < < |
Deleted src/external/Tree/build.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Tree/src/LinkedList/build.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Tree/src/LinkedList/src/Iterator.zig.
|
| < < < < < < < < < |
Deleted src/external/Tree/src/LinkedList/src/IteratorReversed.zig.
|
| < < < < < < < < < |
Deleted src/external/Tree/src/LinkedList/src/Link.zig.
|
| < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Tree/src/LinkedList/src/LinkedList.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Tree/src/LinkedList/src/Sample.zig.
|
| < < < < < < < < < < < |
Deleted src/external/Tree/src/LinkedList/src/Samples.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Tree/src/LinkedList/src/main.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Tree/src/Sample.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Tree/src/Tree.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/Tree/src/Walker.zig.
|
| < < < < < < < < < < < < < < < < < < |
Deleted src/external/Tree/src/main.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/lib/build.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/lib/src/lib.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/lib/src/main.zig.
|
| < < < < < < < < < < < < < < < < < < < |
Deleted src/external/linkedBufferedAllocator.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/textLib/build.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/textLib/src/CharsDecFromI64.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/textLib/src/CharsDecFromU64.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/textLib/src/external/Ranges/build.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/textLib/src/external/Ranges/src/RangeU.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/textLib/src/external/Ranges/src/main.zig.
|
| < < < < < < < < < < < < < < < |
Deleted src/external/textLib/src/main.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/external/textLib/src/textLib.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/help.txt.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/main.zig.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/main.zig.bak.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |