Monday, December 31, 2018

A cursor manager snippet

The easiest method to get comfortable input from the user is to write a separate cursor manager which accepts commands from Console and executes them in xchars. Then we have separated the rectangle input controls from xcars almost completely. The cursor manager can run the message loop with xcb.

This is the best set up, it allows swappable method for command line editing, and keeps xchars as a strictly font to rectangle machine. And, it allows simple testing, my favorite. Cursor snippet can run on its own thread.

Cursor manager is smart and has a high speed symbol table, like xchars; they talk packed char. SO it has commands with xchar style semantics:

NewCuror conn mygc mycursor; // Cursor receives this
SetGC mygc mycursor; // Issues this

Cursor manage knows how to erase the cursor at one position and redraw it. It knows the line editing controls and reads the chars, it echos chars under mode control, and it collects a line of input and returns to Console loop, which requested it. And so forth, strictly working the current input rectangle.

Most of all, cursor manager can keep a great command list control for automatic expansion, command line history, and the rest. It echos what it think is a command format, then console lloop executes, including any macro expansion.  The actual line of input remainsthe original string, the source , syntax engine insures.

It keeps the links between cursors and connections.  It requires the syntax engine above make sure variable names are properly synchronized, once again, not at this layer..


No comments: