Code Monkey home page Code Monkey logo

cursed's Introduction

The CURSED Package

The cursed package adds a subclass of the output-pane element in LispWorks' CAPI. It's designed to allow for simple, console-style display of text, but within a graphical pane.

Quickstart

You can immediately start using the cursed-pane by just containing one.

CL-USER > (setf c (capi:contain (make-instance 'cursed-pane)))
#<CURSED-PANE  21C83D3B>

Initial pane with cursor visible

Once the pane is up, you can use all of the Common Lisp printing and formatting functions to render text to the pane (it is a character output stream also!).

CL-USER > (princ "Hello, world!" c)
"Hello, world!"

CL-USER > (force-output c)
NIL

With obligatory example

You can use the cursed-pane-cursor-x and cursed-pane-cursor-y accessor methods to setf the cursor position. You can also use the Common Lisp file-position function.

CL-USER > (file-position c)
(13 0)

CL-USER > (file-position c '(20 10))

CL-USER > (format c "[~{~a~^, ~}]" '(this is a test))
NIL

CL-USER > (force-output c)
NIL

Rendering text elsewhere...

The cursor can also be toggled on and off with the cursed-pane-cursor-visible-p accessor.

You can use the with-output-to-cursed-pane macro to quickly position the cursor, render, and force output. The macro will also allow you to temporarily change the foreground and background colors of the pane as well.

CL-USER > (with-output-to-cursed-pane (c :x 0 :y 20 :foreground :yellow :background :blue)
            (loop for i from 1 to 10 do (print (* i i))))
NIL

Scrolling

The above example shows that the cursed pane will also scroll. There is no history, however. You can force the pane to scroll a single line using cursed-pane-scroll.

It is also possible to completely clear the pane with cursed-pane-clear. This will also re-position the cursor back to <0,0>.

It is possible to use the mouse when cursed-pane-selection-visible-p is set the T to select regions of the pane. The selection can also be inspected and adjusted with cursed-pane-selection-start and cursed-pane-selection-end (both are setf-able). These are set similarly to file-position.

Selection

The selection can be copied to the clipboard with cursed-pane-copy. Note, however, that newlines are not tracked so a block of text is what will be in the clipboard.

Text from the clipboard can be pasted into the pane with cursed-pane-paste.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.