0
|
1 Current terminal widget: |
|
2 |
|
3 * Run Octave in a separate thread. On unixy, interact through pty. |
|
4 On Windows systems, use hidden console and mirror contents in Qt |
|
5 widget. |
|
6 |
|
7 Octave interpreter sees input directly, same as for normal |
|
8 terminal application. Good, because no change in the way Octave |
|
9 accepts and parses input. Bad because GUI is not in control of |
|
10 input and must arrange to communicate across threads. |
|
11 |
|
12 Terminal window can (in theory) be used to run other applications |
|
13 started from the system command (for example). This feature works |
|
14 well enough for us to use less running as a separate process to |
|
15 handle paging output, but it doesn't work for all applications. |
|
16 For example, I am not able to run editors like Emacs or vi in the |
|
17 GUI terminal window. |
|
18 |
|
19 To make less work as the pager on Unixy systems, the Octave must |
|
20 fork, call setsid in the child to detach from the controlling |
|
21 terminal, and then exec the GUI. |
|
22 |
|
23 GUI must deal with threads when communicating with the |
|
24 interpreter. |
|
25 |
|
26 Proposal: |
|
27 |
|
28 * GUI terminal widget is in control of input. |
|
29 |
|
30 Use callback interface for readline to handle command line |
|
31 editing. |
|
32 |
|
33 Use push parser to parse lines as they become available. Push |
|
34 parser will return status of parse, either complete or needing |
|
35 more input. |
|
36 |
|
37 Uses the following readline callbacks to manage input and update |
|
38 the display. We may need more in the future to handle other |
|
39 features. |
|
40 |
|
41 rl_getc_function |
|
42 rl_redisplay_function |
|
43 rl_completion_display_matches_hook |
|
44 |
|
45 rl_prep_term_function (do nothing) |
|
46 rl_deprep_term_function (do nothing) |
|
47 |
|
48 Call rl_callback_handler_install to setup readlines |
|
49 callback mode. This sets the initial prompt and provides a pointer |
|
50 to a function that readline should call when a complete line of |
|
51 input is available. |
|
52 |
|
53 Call rl_callback_read_char when a character is available for |
|
54 readline to handle. We currently store the character to read in a |
|
55 global value, then rl_get_function returns that character to |
|
56 readline. |
|
57 |
|
58 Call rl_callback_handler_remove when shutting down. |
|
59 |
|
60 To avoid global variables, it would be helpful if we could use |
|
61 lambda functions/functors as callbacks instead of plain C function |
|
62 pointers. |
|
63 |
|
64 Questions: |
|
65 |
|
66 * With this arrangement, would the interpreter have to run in a |
|
67 separtae thread? |
|
68 |
|
69 * Example parser currently computes results |
|
70 immediately. How do we deal with parsing multiple expressions and |
|
71 statements with this method? |
|
72 |
|
73 * Do we need text position markers to keep track of the prompt position |
|
74 (beginning of current line) when inserting or clearing text? |