kbe.lua - a Vi-like Keyboard Editor for Golly

For scripts to aid with computation or simulation in cellular automata.
Post Reply
User avatar
Posts: 428
Joined: May 14th, 2018, 3:57 am

kbe.lua - a Vi-like Keyboard Editor for Golly

Post by Redstoneboi » December 16th, 2022, 6:17 am

Introducing kbe.lua, a KeyBoard Editor for Golly.
*May be slow when pasting patterns. But this seems to be an issue with my Golly as a whole. Pasting patterns even with just Ctrl+V isn't fast anymore either.
The keybinds are inspired by the Vim text editor. You may customize them inside the lua file, which contains a bit of documentation.
  • Move cursor Left/Down/Up/Right: H/J/K/L
  • Pan: Alt+H/J/K/L
  • Center Camera: Alt+V
  • Zoom in/out: A/Z
  • Select prev/next state: Q/E
  • Pick state: S
  • Select state: <number> Shift+S
  • Place cell: Space (hold while moving to draw lines)
  • Selection manipulation:
    • Reset selection: V (try Shift+V and Alt+Shift+V)
    • Copy: Y
    • Delete: X
    • Cut: D
    • Paste OR: P
    • Paste COPY: C
    • Rotate CW: R, Rotate CCW: Alt+R, preserve selection with Shift
    • Flip X: F, Flip Y: Alt+F
  • Type numbers to set "Repetition" (Backspace supported)
  • Reset Repetition: Semicolon;
  • Enter TEXT MODE: i

Code: Select all

download kbe.lua
put it in your preferred scripts folder, possibly just Golly/Scripts/Lua/kbe.lua
open Golly
press Comma (,)

the Preferences window should pop up

go to the Keyboard tab
select the Key Combination box
type a Colon (:)

select the Action menu
scroll all the way up to Open Chosen File
Choose file

a file open dialog should pop up
find and select kbe.lua
Ok :)

try running kbe using Colon (:)
you should see some text show up in the top left corner of your screen
type Colon again to close the script

Done :D
Edit mode tutorial:

Code: Select all

open up a fresh golly pattern with nothing in it
set the algorithm to JvN so we can demonstrate having a lot of states

run kbe with Colon
type 10 to set repetition
press Shift+S to set cursor cell state to 10, this also resets repetition

type 12 to set repetition
hold Space, this places a cell at your cursor
while holding, press J, this draws 12 cells downward
still holding, press L, this draws 12 cells rightward
release Space

hold Shift, press H and K, this will select the shape you have just drawn
you may release Shift
press Y to copy this shape

press Semicolon; this resets your repetition
type 16 to set repetition
hold C, now press LLL

read this carefully and execute quickly: type Shift+RHHH, this should rotate your patterns
if you were too slow, your keyboard repeat rate would have rotated the first pattern a couple times

press Alt+LL to pan right twice
press Z to zoom out
type a Colon: (a.k.a Shift+Semicolon;) to quit the script
You should be left with this pattern, selecting the leftmost object:

Code: Select all

x = 61, y = 13, rule = JvN29
Text mode tutorial:

Code: Select all

run the script again
notice it actually remembers your last selection
reset it with V
type Alt+V to center your screen
[Exercise] move somewhere away from your previous pattern

press i to enter TEXT MODE
type anything on a standard QWERTY keyboard (lowercase is not supported)
press Ctrl+Q/E to change state, a.k.a "font color" (Cmd also works)
press [Enter], this will create a newline
type a couple things
press [Backspace] until you delete the newline

type Ctrl+3, this will set repetition
type stuff
press backspace a couple times
type Ctrl+Semicolon; this resets the repetitions to normal

move somewhere else with Ctrl+HJKL
(NOTE: the moment you move in text mode, what you have typed will now "solidify", meaning you can no longer edit it as "text", which makes backspace not work properly with it)
type some text somewhere else, maybe test your ASCII symbols
type Ctrl+Enter to exit text mode

[Exercise] move and pan around to view your text
now press VV to make the selection box disappear
press S to pick the cell under your now-invisible cursor
quit the script
Very cool, I'd say!
This is 「Fluffy」
「Fluffy」is my sutando.
「Fluffy」has the ability to engineer r e p l i c a t o r s.
「Fluffy」likes to watch spaceship guns in Golly.
「Fluffy」knows Natsuki best girl.

Post Reply