Mercurial > jwe > qt-gui-with-push-parser
view NOTES @ 0:dff751fb985c
initial revision
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 13 May 2019 09:48:06 -0500 |
parents | |
children | 52c033864347 |
line wrap: on
line source
Current terminal widget: * Run Octave in a separate thread. On unixy, interact through pty. On Windows systems, use hidden console and mirror contents in Qt widget. Octave interpreter sees input directly, same as for normal terminal application. Good, because no change in the way Octave accepts and parses input. Bad because GUI is not in control of input and must arrange to communicate across threads. Terminal window can (in theory) be used to run other applications started from the system command (for example). This feature works well enough for us to use less running as a separate process to handle paging output, but it doesn't work for all applications. For example, I am not able to run editors like Emacs or vi in the GUI terminal window. To make less work as the pager on Unixy systems, the Octave must fork, call setsid in the child to detach from the controlling terminal, and then exec the GUI. GUI must deal with threads when communicating with the interpreter. Proposal: * GUI terminal widget is in control of input. Use callback interface for readline to handle command line editing. Use push parser to parse lines as they become available. Push parser will return status of parse, either complete or needing more input. Uses the following readline callbacks to manage input and update the display. We may need more in the future to handle other features. rl_getc_function rl_redisplay_function rl_completion_display_matches_hook rl_prep_term_function (do nothing) rl_deprep_term_function (do nothing) Call rl_callback_handler_install to setup readlines callback mode. This sets the initial prompt and provides a pointer to a function that readline should call when a complete line of input is available. Call rl_callback_read_char when a character is available for readline to handle. We currently store the character to read in a global value, then rl_get_function returns that character to readline. Call rl_callback_handler_remove when shutting down. To avoid global variables, it would be helpful if we could use lambda functions/functors as callbacks instead of plain C function pointers. Questions: * With this arrangement, would the interpreter have to run in a separtae thread? * Example parser currently computes results immediately. How do we deal with parsing multiple expressions and statements with this method? * Do we need text position markers to keep track of the prompt position (beginning of current line) when inserting or clearing text?