File: help_window.ml

package info (click to toggle)
prooftree 0.13-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid, stretch
  • size: 592 kB
  • ctags: 668
  • sloc: ml: 4,462; sh: 117; makefile: 111
file content (341 lines) | stat: -rw-r--r-- 13,592 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
(* 
 * prooftree --- proof tree display for Proof General
 * 
 * Copyright (C) 2011 - 2016 Hendrik Tews
 * 
 * This file is part of "prooftree".
 * 
 * "prooftree" is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * "prooftree" is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License in file COPYING in this or one of the parent
 * directories for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with "prooftree". If not, see <http://www.gnu.org/licenses/>.
 * 
 * $Id: help_window.ml,v 1.24 2016/01/23 12:57:14 tews Exp $
 *)


(** Creation and display of the help window *)

(** {2 General remarks}

    The help text is formatted inside a GText.buffer, which is
    displayed in a GText.view. The help text needs some basic markup
    (colors, italic, bold). The markup system for Gdk text buffers is
    rather heavy weight and there is apparently no simple way to use
    some basic markup.

    The help text uses therefore its own rudimentary markup system.
    The help text itself is a list of pairs, where each pair consists
    of a style-tag and a string. The string is the help text and the
    style-tag (of type {!tags_symbols} determines the markup. To
    create the help text, one iterates over the list, translates the
    style-tags into appropriate {xref lablgtk class GText.tag}'s and
    inserts the text.
*)


open Configuration


(** {2 Module contents} *)


(** Style-tags for the help text *)
type tags_symbols =
  | Default				(** Default, no style *)
  | Color of Gdk.color			(** Foreground color *)
  | Background of Gdk.color		(** Background color *)
  | Italic				(** Set in italic *)
  | Bold				(** Set in bold *)
  | Heading                             (** bold and large *)


(** The help text *)
let help_text = 
  let bold_proof_tree = (Bold, "Prooftree") in
  let bold_proof_general = (Bold, "Proof General")
  in
  (**************************************************************************)
  (***************************** Colors *************************************)
  (**************************************************************************)
  [(Heading, "Colors");
   (Default, "\n\nThe meaning of the colors in the proof tree is as follows: ");
   (Color !proved_complete_gdk_color, 
    "completely proved branches (green by default), ");
   (Color !proved_incomplete_gdk_color,
    "proved branches with some not (yet) instantiated existential variables \
(cyan by default), ");
   (Color !proved_partial_gdk_color,
    "proved branches with all their own existential variables instantiated \
that nevertheless depend on some not (yet) instantiated existential variable \
(dark green by default), ");
   (Color !current_gdk_color, "branch to the current goal (blue by default), ");
   (Default, "currently open branches (default foreground color) and ");
   (Color !cheated_gdk_color, 
    "branches terminated with a cheating command such as admit");
   (Default, ". Colors as well as many ");
   bold_proof_tree;
   (Default, " parameters \
can be changed in the configuration dialog.\n\
\n");
   (*************************************************************************)
   (***************************** Navigation ********************************)
   (*************************************************************************)
   (Heading, "Navigation");
   (Default, "\n\n\
In addition to scroll bars and the usual keys one can move the proof \
tree by dragging with mouse button 1 pressed. By default, dragging \
moves the viewport (i.e., the proof tree underneath moves in the \
opposite direction). After setting a negative value for ");
   (Italic, "Drag acceleration");
   (Default, " in the Configuration dialog, dragging will move \
the proof tree instead (i.e, the proof tree moves in the same \
direction as the mouse).\n\
\n");
   (*************************************************************************)
   (***************************** Sequent window ****************************)
   (*************************************************************************)
   (Heading, "The sequent window and additional displays");
   (Default, "\n\n\
The sequent display below the proof tree \
normally shows the ancestor sequent of the current \
goal. With a single left mouse click one can display any goal or proof command \
in the sequent display. A single click outside the proof tree will switch \
back to default behavior. The initial size of the sequent display can \
be set in the configuration dialog. A value of 0 hides the sequent display.\n\
\n\
A double click or a shift-click displays any goal or proof command \
in an additional window. These additional windows are automatically updated, \
for instance, if an existential variable is instantiated. For additional \
sequent displays one can browse the instantiation history of the sequent \
using the forward and backward buttons. These additional windows can be ");
   (Italic, "detached");
   (Default, " from the proof tree. A detached \
display is neither automatically updated nor automatically deleted.\n\
\n\
");
   (*************************************************************************)
   (***************************** Tooltips **********************************)
   (*************************************************************************)
   (Heading, "Tooltips");
   (Default, "\n\n\
If turnstile tool tips are switched on, the complete sequent text is \
displayed as toop tip when the mouse stays above a sequent symbol in the \
proof tree display. Similar for command tool tips and proof commands.\n\
\n\
Long proof commands are truncated with \226\128\166 in the display. The \
length at which truncation happens can be set in the configuration dialog. \
Any truncated proof command is displayed in full length as tool tip if the \
mouse stays long enough above it (and if command tool tips are enabled).\n\
\n");
   (*************************************************************************)
   (***************************** Existentials ******************************)
   (*************************************************************************)
   (Heading, "Existential variables");
   (Default, "\n\
\n");
   bold_proof_tree;
   (Default, " keeps track of existential variables, whether they \
have been instantiated and whether they depend on some other, \
not (yet) instantiated existential. \
It uses different colors for proved branches that contain non-instantiated \
existential variables and branches that only depend on some not instantiated \
existential. Displays with sequents \
or proof commands (in tool-tips and in additional windows) list those \
existential variables that are currently not (yet) instantiated.\n\
\n\
The menu item ");
   (Italic, "Existentials");
   (Default, " opens the dialog for existential variables, which contains \
a table with all existential variables of the current proof and their \
dependencies. \
For each existential variable, the table contains a ");
   (Italic, "Mark");
   (Default, " button, which marks the proof command that introduced \
this variable ");
   (Background !existential_create_gdk_color,
    "(with yellow background, by default)");
   (Default, " and, if present, the proof command that instantiated \
this variable ");
   (Background !existential_instantiate_gdk_color,
    "(with orange background, by default)");
   (Default, " in the proof-tree display.\n\
\n\
With ");
   (Bold, "Coq");
   (Default, " >= 8.5, existential variables are severely broken in ");
   bold_proof_tree;
   (Default, " because ");
   (Bold, "Coq");
   (Default, " does not provide the necessary information, see ");
   (Bold, "Coq");
   (Default, " bug 4504.\n\
\n");
   (*************************************************************************)
   (***************************** Menus *************************************)
   (*************************************************************************)
   (Heading, "Menus");
   (Default, "\n\n\
The menu button opens the main menu. A right click opens the context menu, \
which contains some additional items. \n\
\n\
The item ");
   (Italic, "Undo to point");
   (Default, ", which is only active over a sequent node in the proof \
tree display, sends an appropriate retract command to ");
   bold_proof_general;
   (Default, ".\n\
\n\
The items ");
   (Italic, "Insert command");
   (Default, " and ");
   (Italic, "Insert subtree");
   (Default, " cause ");
   bold_proof_general;
   (Default, " to insert, respectively, the selected proof command or all \
proof commands of the selected subtree, at point in the selected buffer.\n\
\n\
The ");
   (Italic, "Clone");
   (Default, " menu item clones the current proof tree in a separate \
proof tree window. This cloned proof tree is not connected with ");
   bold_proof_general;
   (Default, " and won't be updated when the proof is changed.\n\
\n\
The ");
   (Italic, "Show current");
   (Default, " and ");
   (Italic, "Show selected");
   (Default, " menu items reposition the proof tree such that the \
current proof goal or, respectively, the selected node is visible.\n\
\n\
The item ");
   (Italic, "Existentials");
   (Default, " opens the dialog for existential variables, see above.\n\
\n\
The ");
   (Italic, "Configuration");
   (Default, " item displays the configuration dialog. Changes in this dialog \
immediately take effect. In this dialog, the ");
   (Italic, "Save");
   (Default, " button stores the current configuration values \
              in the file ");
   (Italic, config_file_location);
   (Default, ", which overwrites the build-in default configuration \
at start up. The ");
   (Italic, "Cancel");
   (Default, " button closes the dialog and resets the configuration to \
the state before starting the configuration dialog.\n\
\n\
The ");
   (Italic, "Exit");
   (Default, " item terminates ");
   bold_proof_tree;
   (Default, " and closes all proof windows. (Closing all windows does ");
   (Italic, "not");
   (Default, " terminate ");
   bold_proof_tree;
   (Default, ".)\n\
\n");
   (*************************************************************************)
   (***************************** Customization *****************************)
   (*************************************************************************)
   (Heading, "Customization");
   (Default, "\n\n\
A major part of the proof visualization task is done by ");
   bold_proof_general;
   (Default, ". Therefore, certain aspects can only be configured \
inside ");
   bold_proof_general;
   (Default, " in the customization groups ");
   (Italic, "proof-tree");
   (Default, " and ");
   (Italic, "proof-tree-internals. ");
   (Default, "For instance, ");
   bold_proof_tree;
   (Default, " command line arguments or the regular expressions for \
navigation and cheating commands can be configured there. \
To visit a customization group, type ");
   (Italic, "M-x customize-group");
   (Default, " followed by the name of the customization group inside ");
   bold_proof_general;
  ]


(** Format {!help_text} and insert it into the given buffer. The
    style-tags are translated into appropriate {xref lablgtk type
    GText.tag_property}, which are used to create {xref lablgtk class
    GText.tag}'s, which in turn are used to insert the help text.
*)
let fill_help_buffer (buffer : GText.buffer) =
  let heading_tag = buffer#create_tag [`SCALE `LARGE; `FONT "bold"] in
  let i_tag = buffer#create_tag [`FONT "italic"] in
  let bold_tag = buffer#create_tag [`FONT "bold"] in
  let get_tags = function
    | Default -> []
    | Color gdk_color -> [buffer#create_tag [`FOREGROUND_GDK gdk_color]]
    | Background gdk_color -> [buffer#create_tag [`BACKGROUND_GDK gdk_color]]
    | Italic -> [i_tag]
    | Bold -> [bold_tag]
    | Heading -> [heading_tag]
  in
  List.iter
    (fun (tag_sym, text) -> buffer#insert ~tags:(get_tags tag_sym) text)
    help_text


(** Flag for option [-help]. *)
let start_help_dialog = ref false


(** Create and display a new help window. This function creates a new
    {xref lablgtk class GWindow.dialog} that contains the formatted
    help text inside a {xref lablgtk class GText.view}.
*)
let show_help_window () =
  let help_win = 
    GWindow.dialog
      ~no_separator:true
      ~title:"Prooftree Help"
      ~resizable:true
      ()
  in
  let close_fun _ =
    help_win#destroy ();
    if !start_help_dialog then exit 0
  in
  help_win#add_button_stock `CLOSE `CLOSE;
  let _help_title =
    GMisc.label
      ~markup:"<big><b>Prooftree Help</b></big>"
      ~selectable:true ~xpad:10 ~ypad:10
      ~packing:help_win#vbox#pack ()
  in
  let help_scrolling = 
    GBin.scrolled_window ~hpolicy:`AUTOMATIC ~vpolicy:`AUTOMATIC
      ~packing:(help_win#vbox#pack ~expand:true) () 
  in
  let help_view =
    GText.view 
      ~border_width:2
      ~editable:false 
      ~cursor_visible:false
      ~wrap_mode:`WORD
      ~packing:help_scrolling#add ()
  in
  fill_help_buffer help_view#buffer;
  ignore(help_win#connect#destroy ~callback:close_fun);
  ignore(help_win#connect#response ~callback:close_fun);
  help_win#set_default_size ~width:400 ~height:300;
  (* help_win#set_default_size ~width:800 ~height:800; *)
  help_win#show ()