Log In  

Cart #picoterm_v1-12 | 2024-03-21 | Code ▽ | Embed ▽ | No License
7


PicoTerm is a PICO-8 CLI template. It can be used as a basis for command-line games and programs.

See tab 3 for the functions that are called whenever a character or line is entered. See tab 2 for functions to call to interact with the terminal.

Pressing ctrl-u or ctrl-l will clear the current line of input or the screen, respectively. The up and down arrows allow you to scroll through input history.

If you use this in a project please follow the license terms at the bottom of the post. I would also appreciate being notified, however that is not mandatory.

If you do not use a feature in your project you can modify this remove it to have more tokens.

Known Issues:

  • Pressing ctrl-u does not clear the line from the input history.

Changelog:


1.10

  • Added ctrl-u and ctrl-l keyboard shortcuts for clearing the current line of input and screen, respectively
  • Added init_hook() and moved editable globals to default_init_hook()
  • Added arrow_hook() with input history traversal in default_arrow_hook()
  • Fixed max_lines being inaccurate for values over 19
  • Fixed cursor position breaking with max_lines being too large

1.9

  • Fixed bug where pressing backspace on an empty line would briefly move the cursor backwards
  • Rewrote a lot of code
  • Other various bug fixes
  • Added character hooks

1.8

  • Fixed bug where cpu usage would skyrocket with enough lines

1.7

  • Fixed bug where line wrapping wouldn't work if a previous line had been wrapped

1.6

  • Major line wrapping bug fixed
  • Fixed pressing ESC sometimes printing a dot

1.5

  • Fixed bug where the cursor would persist at the start of a line after pressing return

1.4

  • Added blinking cursor

1.3

  • Prohibited glyph characters in input to prevent doublewide characters from messing up the screen scrolling

1.2

  • Made it so that the prompt is mixed in with the log rather than being stuck at the bottom of the screen

1.1

  • Made it so pressing ESC won't print a character

1.0

  • Released

License:
BSD 3-Clause


Copyright 2024 DivergentClouds

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

P#93811 2021-06-21 17:28 ( Edited 2024-03-22 16:50)

1

May use this for a future project -- neat!

P#93833 2021-06-21 22:30

epicccc

P#99290 2021-10-28 23:10

Cursor ?

P#99298 2021-10-29 04:16

@dw817 unfortunately, a moveable cursor wouldn't be easy to implement into the existing codebase, however, you are free to modify this as long as you credit and link back here.

P#99460 2021-11-01 11:46
1

You are using some advanced programming in here that I'm not familiar with, @flowinglily. The FOREACH for instance. I have your cursor, it's just kinna clumsy the way I did it.

Cart #pegeruweyi-0 | 2021-11-01 | Code ▽ | Embed ▽ | No License
1

Is there a way to have:

foreach(log,ycursor=ycursor+1)

?

P#99473 2021-11-01 18:02

@dw817, sorry, I just saw this, I misunderstood what you meant by "cursor", I thought you wanted to be able to move the cursor with the arrow keys, I'll try and implement one soon.

P#109875 2022-04-07 19:52

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 11:31:14 | 0.077s | Q:31