\. This is a demonstration program that implements some simple cursor editing. The way we show the cursor in this example is suitable for use with the video display, but not with the X display: We make the cursor blink by redrawing the entire display -- a pain for the X display. Graphic editing is intended to be done using the spread display, and cursor movement is within cells as well as between them. In this demonstration, the cursor is located at the center of the screen: you toggle its visibility using the "*" key, and use the arrow keys to move the center in the direction that you desire. You use emacs editing keys (^N, ^P, ^F, ^B) to move the cursor around, and ^X to toggle a bit under the cursor. We provide a key ("=") for printing the current position of the cursor, relative to the original image coordinates; we also provide a key ("@") to recenter the image as it was when loaded. .\ X 2* constant bit-cursor-x Y 2* constant bit-cursor-y : cursor-x bit-cursor-x 4 / ; : cursor-y bit-cursor-y 4 / ; : read-cursor (s -- value ) begin-line-io cursor-x cursor-y read-point end-line-io ; : write-cursor (s value -- ) begin-line-io cursor-x cursor-y write-point end-line-io ; : cursor-mask (s -- mask ) 1 bit-cursor-y 4 mod 4* bit-cursor-x 4 mod + << ; : complement-cursor begin-line-io cursor-x cursor-y read-point cursor-mask xor cursor-x cursor-y write-point end-line-io ; variable cursor-visible cursor-visible off : show-cursor begin complement-cursor show complement-cursor show 5 0 do idle-frame key? ?leave loop key? until ; \* The key-interpreter program will execute the defered word "while-stopped" whenever it is not running steps, and no key has been pressed. *\ : ?show-cursor cursor-visible @ if show-cursor then ; this is while-stopped \ ****************** Key definitions: ***************** cr : Toggle-cursor cursor-visible @ not dup cursor-visible ! .on/off ; press * "Toggle cursor visibility on and off" : Cursor-previous bit-cursor-y 1- is bit-cursor-y ; press ^P "Move cursor up (previous line)" : Cursor-next bit-cursor-y 1+ is bit-cursor-y ; press ^N "Move cursor down (next line)" : Cursor-back bit-cursor-x 1- is bit-cursor-x ; press ^B "Move cursor left (back 1 position)" : Cursor-forward bit-cursor-x 1+ is bit-cursor-x ; press ^F "Move cursor right (forward 1 position)" : Toggle-bit complement-cursor show ; press ^X "Complement bit under cursor" : Print.position cr ." Cursor (x,y) = (" cursor-x (.) type ." ," cursor-y (.) type ." ) at bit #" bit-cursor-y 4 mod 4 * bit-cursor-x 4 mod + . ; press = "Print current coordinates of cursor." : Recenter.image net-x-shift @ negate net-y-shift @ negate #dim @ 2 ?do 0 loop shift-space show net-x-shift off net-y-shift off ; press @ "Recenter the image as it was when loaded." show-state ' cboard-smap is smap cboard-flag on ?send-smap regen show