spywhere [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=62375 pim: vim-like editor for Pico-8 <p> <table><tr><td> <a href="/bbs/?pid=105855#p"> <img src="/bbs/thumbs/pico8_pim-4.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=105855#p"> pim v0.3.1</a><br><br> by <a href="/bbs/?uid=62375"> spywhere</a> <br><br><br> <a href="/bbs/?pid=105855#p"> [Click to Play]</a> </td></tr></table> </p> <h1>pim</h1> <p>This is my attempt to bring vim into Pico-8. It leveraging Serial IO and debugging logs as a mean of reading / writing files.</p> <p><strong>Heads up!</strong></p> <ul> <li>This is a very early releases of the cart, some functionalities might break under certain cases</li> <li>Line wrap is not implemented, so text insertion pass the limit would resulted in unexpected behaviour <ul> <li>As line wrap is not implemented, so is horizontal scrolling</li> </ul></li> </ul> <h2>Reading and Writing file</h2> <p>pim supports reading and writing file through Serial IO and debugging logs.</p> <h3>Reading Files</h3> <p>To read a file, simply drag and drop the file onto the Pico-8 with pim running. pim will notify through the message that file is available to read.</p> <p>Once file is available to read, simply using <code>:e [filename]</code> to read a file as <code>[filename].p8l</code>.</p> <h3>Writing Files</h3> <p>To write a file, simply using <code>:w [filename]</code> to write a file. This will always saved as <code>[filename].p8l</code> as pim is using <code>printh</code> to write the content to file.</p> <p><strong>Heads up!</strong> Be careful, pim will always overwrite the target file as Pico-8 does not provide an API for file systems.</p> <h2>Keymap</h2> <p>Currently, pim supports 2 input types, devkit and a regular keypad / controller.</p> <p>To switch between input types, use the Pause menu by either physically pause Pico-8 or use <code>:q</code>.</p> <h3>DevKit Input</h3> <p>As there is a limitation on Pico-8 key interception, here are alternative keys for vim functionality.</p> <p><code>C-c</code> (Control-C) as an escape key<br /> <code>Tab</code> (Tab) as a return key</p> <p>For some of the normal mode operator, you can prefixed it with a count. For example, to move down 5 lines, you can use <code>5j</code>.</p> <h3>Normal Mode</h3> <h4>DevKit</h4> <ul> <li><code>C-c</code>: Clear pending operator</li> <li><code>:</code>: Enter command line mode</li> <li><code>v</code>/<code>V</code>/<code>c-v</code>: Enter visual / visual line / visual block mode</li> <li><code>i</code>/<code>a</code>: Enter insert mode (at / after cursor position)</li> <li><code>I</code>/<code>A</code>: Enter insert mode (at the start / end of a line)</li> <li><code>C-e</code>/<code>C-y</code>: Scroll the buffer up / down by one line</li> <li><code>o</code>: Open a new line below a current line</li> <li><code>O</code>: Open a new line above a current line</li> </ul> <h4>Keypad</h4> <ul> <li>1st <code>O</code>: Enter command line mode</li> <li>1st <code>X</code>: Enter insert mode at cursor position</li> <li>2nd <code>O</code>: Enter visual mode</li> <li>2nd <code>X</code>: Enter insert mode after cursor position</li> </ul> <h3>Insert Mode</h3> <h4>DevKit</h4> <ul> <li><code>C-c</code>: Exit to normal mode</li> <li><code>Left</code>/<code>Down</code>/<code>Up</code>/<code>Right</code>: Move the cursor to the left/down/up/right</li> </ul> <h4>Keypad</h4> <ul> <li>1st <code>O</code>: Backspace</li> <li>1st <code>X</code>: Line feed</li> <li>2nd <code>O</code>: Exit to normal mode</li> <li><code>Left</code>/<code>Right</code>: Move the cursor to the left/right</li> <li><code>Up</code>/<code>Down</code>: Iterate a character at cursor position up/down</li> </ul> <p><strong>Heads up!</strong> Currently, there is no way to delete a line when using keypad input.</p> <h3>Visual Mode</h3> <h4>DevKit</h4> <ul> <li><code>C-c</code>: Clear pending operator</li> <li><code>:</code>: Enter command line mode</li> <li><code>v</code>/<code>V</code>/<code>c-v</code>: Enter visual / visual line / visual block mode or exit to normal mode if mode is matched</li> <li><code>o</code>/<code>O</code>: Swap cursor and cursor's anchor point</li> </ul> <h4>Keypad</h4> <ul> <li>1st <code>O</code>: Exit to normal mode</li> <li>2nd <code>X</code>: Enter command line mode</li> </ul> <h3>Command-line Mode</h3> <h4>DevKit</h4> <ul> <li><code>C-c</code>: Exit to normal mode</li> <li><code>Left</code>/<code>Right</code>: Move the cursor to the left/right</li> <li><code>Up</code>/<code>Down</code>: Iterate backward/forward through a command-line history</li> </ul> <h4>Keypad</h4> <ul> <li>1st <code>O</code>: Exit to normal mode</li> <li>1st <code>X</code>: Accept a command line</li> <li><code>Left</code>/<code>Right</code>: Move the cursor to the left/right</li> <li><code>Up</code>/<code>Down</code>: Iterate a character at cursor position up/down</li> </ul> <h3>Motions</h3> <ul> <li><code>g_</code>: The end of the line including a new line</li> <li><code>h</code>/<code>j</code>/<code>k</code>/<code>l</code>/<code>Left</code>/<code>Down</code>/<code>Up</code>/<code>Right</code>: Character to the left / down / up / right</li> <li><code>0</code>/<code>$</code>: Move the cursor to the first / last character of the line</li> <li><code>gg</code>/<code>G</code>: The top / bottom of the buffer</li> <li><code>C-b</code>/<code>C-f</code>: The buffer up / down by a page</li> <li><code>C-u</code>/<code>C-d</code>: The buffer up / down by half a page</li> <li><code>w</code>/<code>W</code>: The beginning of the next word / WORD</li> </ul> <p><code>word</code>: A word consists of a sequence of letters, digits and underscores, or a sequence of other non-blank characters, separated with white space (spaces, tabs, EOL). This can be changed with the 'iskeyword' option. An empty line is also considered to be a word.<br /> <code>WORD</code>: A WORD consists of a sequence of non-blank characters, separated with white space. An empty line is also considered to be a WORD.</p> <h2>Options</h2> <p>You can set the option through command line mode by using <code>set</code> command.</p> <ul> <li><code>number</code> / <code>nu</code>: Show line number</li> <li><code>relativenumber</code> / <code>rnu</code>: Show relative line number</li> <li><code>scrolloff</code> / <code>so</code>: Set a scroll-off buffer limit</li> <li><code>timeoutlen</code> / <code>tm</code>: Set a timeout duration to reset the key sequence</li> <li><code>iskeyword</code> / <code>isk</code>: Set a set of characters to be considered as a part of <code>word</code></li> <li><code>history</code> / <code>hi</code>: Set a command-line history limit</li> </ul> <p>You can also prefixed the option name with <code>no</code> to disable the option.</p> <p>To view the current option's value, suffixed the option name with <code>?</code> to view it.</p> <p>For option that accept value, you would need to pass the value (e.g. <code>set scrolloff=3</code>) in order to set the limit. Otherwise, it would just show the current limit.</p> <img style="margin-bottom:16px" border=0 src="/media/62375/5_pim_0.gif" alt="" /> <h2>Release notes</h2> <p>v0.3.1 - 07 May 2022</p> <ul> <li>fix broken motion keymaps</li> </ul> <p>v0.3.0 - 07 May 2022</p> <ul> <li>word motions (<code>w</code>/<code>W</code>)</li> <li>command-line history</li> <li>keypad input support</li> </ul> <p>v0.2.0 - 31 Jan 2022</p> <ul> <li><code>set</code> command now support setting a string value</li> <li>file reading and writing through Serial IO and debugging logs</li> <li>initial mouse support</li> <li>internal project improvement</li> </ul> <p>v0.1.0 - 30 Jan 2022</p> <ul> <li>pause menu has been override with a <code>:quit</code> command instead</li> <li>Enter/Return key can be used instead of Tab</li> <li>fix broken open line (<code>o</code>/<code>O</code>)</li> <li>cursor position should be more predictable</li> <li>use a proper table insertion / deletion for faster performance</li> <li><code>timeoutlen</code> option and <code>:quit</code> command has been added</li> <li>bang command is now handled (but not in used)</li> <li>add quit help message</li> <li>add <code>A</code>/<code>I</code> normal command</li> <li>add motion keymap</li> <li>visual / visual line / visual block mode supported</li> </ul> <p>v0.0.1 - 28 Jan 2022</p> <ul> <li>Initial release</li> </ul> https://www.lexaloffle.com/bbs/?tid=46356 https://www.lexaloffle.com/bbs/?tid=46356 Fri, 28 Jan 2022 22:35:53 UTC