annotate NOTES @ 0:dff751fb985c

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