about summary refs log tree commit diff stats
path: root/src/local/client.nim
Commit message (Expand)AuthorAgeFilesLines
* sandbox: seccomp support on Linuxbptato2024-04-181-0/+4
* Update code stylebptato2024-04-171-28/+26
* Add capsicum supportbptato2024-03-281-2/+5
* config: improve input systembptato2024-03-261-8/+10
* client, forkserver: remove useless codebptato2024-03-241-1/+0
* buffer: fix clonebptato2024-03-241-3/+3
* io: derive DynStream from RootObj (not Stream)bptato2024-03-241-26/+29
* io: add bufreaderbptato2024-03-211-1/+1
* buffer: also buffer input readsbptato2024-03-211-1/+5
* client: fix dump detectionbptato2024-03-201-7/+7
* pager: add "save link", "save source"; change & document some keybindingsbptato2024-03-201-2/+2
* client: refactor inputbptato2024-03-181-114/+26
* config: parse mime.types/mailcap/urimethodmap inside parseConfigbptato2024-03-181-1/+1
* pager: remove useless codebptato2024-03-181-1/+1
* config: clean up/simplifybptato2024-03-171-6/+8
* client: fix "Hit any key" bug on load failurebptato2024-03-171-5/+16
* io: add BuferedWriterbptato2024-03-161-2/+3
* client, pager: various file saving fixesbptato2024-03-161-1/+3
* config: add start.console-buffer optionbptato2024-03-161-2/+3
* Clean up BufferConfigbptato2024-03-151-2/+1
* client: check if container was found before deleting itbptato2024-03-141-2/+2
* pager: unregister containers properly when headers are pendingbptato2024-03-141-6/+14
* Move around some modulesbptato2024-03-141-4/+4
* pager: add "open in editor" keybinding (sE)bptato2024-03-141-2/+3
* client: fix blocking reads on container connectionbptato2024-03-121-32/+16
* loader: remove applyHeadersbptato2024-03-121-2/+3
* pager: fix replacement logicbptato2024-03-121-0/+1
* io: add dynstreambptato2024-03-121-1/+1
* loader: rework process modelbptato2024-03-111-42/+72
* client: fix thumb button confusionbptato2024-03-111-18/+18
* client: bind middle button to discardBuffer, use button5/6 as scrollbptato2024-03-111-4/+13
* client: only accept "press" input type for scroll wheelbptato2024-03-111-2/+6
* buffer: improve/fix onload return valuesbptato2024-03-031-5/+4
* quickjs: reduce diff with upstreambptato2024-03-021-2/+3
* buffer, client: fix deadlock with send() callsbptato2024-02-291-1/+16
* Add mouse supportbptato2024-02-291-8/+138
* buffer: clean up onload, fix console updatebptato2024-02-261-2/+1
* term: improve pixels-per-column/line detectionbptato2024-02-251-5/+2
* Separate ANSI text decoding from main binarybptato2024-02-251-6/+6
* Replace Chakasu with Chagashibptato2024-02-221-1/+1
* client: fix EOF error for estreambptato2024-02-181-0/+2
* Various refactorings & fixesbptato2024-02-141-17/+28
* Remove CLONE BufferSource; cache document sources in tmpdirbptato2024-02-121-3/+0
* Get rid of LOAD_PIPE BufferSourcebptato2024-02-111-3/+3
* forkserver: clean upbptato2024-01-291-4/+2
* client: stop entire process group on suspend()bptato2024-01-291-1/+1
* Remove std/terminal dependencybptato2024-01-171-1/+0
* js: merge some type modules into jstypesbptato2024-01-111-1/+1
* Use std/* imports everywherebptato2024-01-071-11/+11
* Set cgiDir for client loader processbptato2024-01-061-1/+3
: 'save' - writes string to a file</span> <span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span> RESTORE<span class="Delimiter">,</span> <span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span> Recipe_ordinal[<span class="Constant">&quot;restore&quot;</span>] = RESTORE<span class="Delimiter">;</span> <span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span> case RESTORE: <span class="Delimiter">{</span> if <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> raise &lt;&lt; current_recipe_name<span class="Delimiter">()</span> &lt;&lt; <span class="Constant">&quot;: 'restore' requires exactly one ingredient, but got &quot;</span> &lt;&lt; current_instruction<span class="Delimiter">().</span>to_string<span class="Delimiter">()</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> string filename<span class="Delimiter">;</span> if <span class="Delimiter">(</span>is_literal_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> filename = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">;</span> <span class="Delimiter">}</span> else if <span class="Delimiter">(</span>is_mu_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> filename = read_mu_string<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> <span class="Delimiter">}</span> else <span class="Delimiter">{</span> raise &lt;&lt; current_recipe_name<span class="Delimiter">()</span> &lt;&lt; <span class="Constant">&quot;: first ingredient of 'restore' should be a string, but got &quot;</span> &lt;&lt; current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>to_string<span class="Delimiter">()</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> if <span class="Delimiter">(</span>Current_scenario<span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// do nothing in tests</span> string contents = slurp<span class="Delimiter">(</span><span class="Constant">&quot;lesson/&quot;</span>+filename<span class="Delimiter">);</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> if <span class="Delimiter">(</span>contents<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> else products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>new_mu_string<span class="Delimiter">(</span>contents<span class="Delimiter">));</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> string slurp<span class="Delimiter">(</span>const string&amp; filename<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="CommentedCode">//? cerr &lt;&lt; filename &lt;&lt; '\n'; //? 1</span> ostringstream result<span class="Delimiter">;</span> ifstream fin<span class="Delimiter">(</span>filename<span class="Delimiter">.</span>c_str<span class="Delimiter">());</span> fin<span class="Delimiter">.</span>peek<span class="Delimiter">();</span> if <span class="Delimiter">(</span>!fin<span class="Delimiter">)</span> <span class="Identifier">return</span> result<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span class="Comment">// don't bother checking errno</span> const int N = <span class="Constant">1024</span><span class="Delimiter">;</span> char buf[N]<span class="Delimiter">;</span> while <span class="Delimiter">(</span>!fin<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Delimiter">{</span> bzero<span class="Delimiter">(</span>buf<span class="Delimiter">,</span> N<span class="Delimiter">);</span> fin<span class="Delimiter">.</span>read<span class="Delimiter">(</span>buf<span class="Delimiter">,</span> N-<span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// leave at least one null</span> result &lt;&lt; buf<span class="Delimiter">;</span> <span class="Delimiter">}</span> fin<span class="Delimiter">.</span>close<span class="Delimiter">();</span> <span class="CommentedCode">//? cerr &lt;&lt; &quot;=&gt; &quot; &lt;&lt; result.str(); //? 1</span> <span class="Identifier">return</span> result<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span> SAVE<span class="Delimiter">,</span> <span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span> Recipe_ordinal[<span class="Constant">&quot;save&quot;</span>] = SAVE<span class="Delimiter">;</span> <span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span> case SAVE: <span class="Delimiter">{</span> if <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> raise &lt;&lt; current_recipe_name<span class="Delimiter">()</span> &lt;&lt; <span class="Constant">&quot;: 'save' requires exactly two ingredients, but got &quot;</span> &lt;&lt; current_instruction<span class="Delimiter">().</span>to_string<span class="Delimiter">()</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> if <span class="Delimiter">(</span>Current_scenario<span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// do nothing in tests</span> string filename<span class="Delimiter">;</span> if <span class="Delimiter">(</span>is_literal_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> filename = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">;</span> <span class="Delimiter">}</span> else if <span class="Delimiter">(</span>is_mu_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> filename = read_mu_string<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> <span class="Delimiter">}</span> else <span class="Delimiter">{</span> raise &lt;&lt; current_recipe_name<span class="Delimiter">()</span> &lt;&lt; <span class="Constant">&quot;: first ingredient of 'save' should be a string, but got &quot;</span> &lt;&lt; current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>to_string<span class="Delimiter">()</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> if <span class="Delimiter">(</span>!scalar<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> raise &lt;&lt; current_recipe_name<span class="Delimiter">()</span> &lt;&lt; <span class="Constant">&quot;: second ingredient of 'save' should be an address:array:character, but got &quot;</span> &lt;&lt; current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>to_string<span class="Delimiter">()</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> ofstream fout<span class="Delimiter">((</span><span class="Constant">&quot;lesson/&quot;</span>+filename<span class="Delimiter">).</span>c_str<span class="Delimiter">());</span> string contents = read_mu_string<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> fout &lt;&lt; contents<span class="Delimiter">;</span> fout<span class="Delimiter">.</span>close<span class="Delimiter">();</span> if <span class="Delimiter">(</span>!exists<span class="Delimiter">(</span><span class="Constant">&quot;lesson/.git&quot;</span><span class="Delimiter">))</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// bug in git: git diff -q messes up --exit-code</span> <span class="Comment">// explicitly say '--all' for git 1.9</span> int status = system<span class="Delimiter">(</span><span class="Constant">&quot;cd lesson; git add --all .; git diff HEAD --exit-code &gt;/dev/null || git commit -a -m . &gt;/dev/null&quot;</span><span class="Delimiter">);</span> if <span class="Delimiter">(</span>status != <span class="Constant">0</span><span class="Delimiter">)</span> raise &lt;&lt; <span class="Constant">&quot;error in commit: contents &quot;</span> &lt;&lt; contents &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> bool exists<span class="Delimiter">(</span>const string&amp; filename<span class="Delimiter">)</span> <span class="Delimiter">{</span> struct stat dummy<span class="Delimiter">;</span> <span class="Identifier">return</span> <span class="Constant">0</span> == stat<span class="Delimiter">(</span>filename<span class="Delimiter">.</span>c_str<span class="Delimiter">(),</span> &amp;dummy<span class="Delimiter">);</span> <span class="Delimiter">}</span> string to_string<span class="Delimiter">(</span>long long int x<span class="Delimiter">)</span> <span class="Delimiter">{</span> ostringstream tmp<span class="Delimiter">;</span> tmp &lt;&lt; x<span class="Delimiter">;</span> <span class="Identifier">return</span> tmp<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Delimiter">:(before &quot;End Includes&quot;)</span> <span class="PreProc">#include</span><span class="Constant">&lt;sys/stat.h&gt;</span> </pre> </body> </html> <!-- vim: set foldmethod=manual : -->