Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 82 lines (60 sloc) 3.34 kB
ceb6a35 snapshot save
megaannum authored
1 # Code Structure
2
3 To create a Form, one starts with the Function that will encapsulate the code:
4
5 function! forms#tutorial#do_nothing_form#Make()
6 " form code
7 endfunction
8
9 The Function is defined so that it can be reloaded using the '!'
10 character at the end of 'function'. This is useful during development
11 so that you can reload the code without having to exit/re-enter Vim.
12
13 It is also possible to do the same by explicitly deleting the
14 function using 'delfunction' and then re-sourcing the file.
15
16 A Form Glyph is a Viewer Glyph which, in turn, is a Mono Glyph, so
17 the Form Glyph during construction must be passed a child Glyph. In this
18 case, we will pass it the Null Glyph. The Null Glyph does nothing; it
19 is a Leaf Glyph with no size and draw nothing in the window,
20
21 function! forms#tutorial#do_nothing_form#Make()
22 let body = forms#newNullGlyph({})
23 " more form code
24 endfunction
25
26 An empty Dictionary is passed as the argument to create the Null Glyph
27 since it has no attributes (strictly speaking, the Null Glyph does
28 have the attributes that any Self object has, such as a 'tag', but
29 it has no attributes that actually are needed to define its
30 behavior - it has none, or its display - it has none).
31
32 This body Glyph is then passed into the Form constructor as its
33 child Glyph:
34
35 function! forms#tutorial#do_nothing_form#Make()
36 let body = forms#newNullGlyph({})
37 let form = forms#newForm({'body': body})
38 " more form code
39 endfunction
40
41 Once a Form is create, its 'run()' method must be called in order for it
42 to be displayed and handle user input:
43
44 function! forms#tutorial#do_nothing_form#Make()
45 let body = forms#newNullGlyph({})
46 let form = forms#newForm({'body': body})
47 call form.run()
48 endfunction
49
50 So, the Form is running. Of course, since its body is a Null Glyph,
51 nothing is displayed.
52
53 The fact that the Null Glyph handles no Events, its a non-interactive
54 Glyph, can not get (Event) focus, does not mean that all user input
55 is ignored by the Form. There are some user character/mouse inputs
56 that the Form its self responses to.
57
58 One such character, in particular, is very relevant for this Form and that
9e930f0 seventh tutorial snapshot save
megaannum authored
59 is the <Esc> character. To stop this Form from running, since it has
60 no explicit 'close' or 'submit' Button, is to press the <Esc> key.
ceb6a35 snapshot save
megaannum authored
61
9e930f0 seventh tutorial snapshot save
megaannum authored
62 The <Cntl-H> keyboard entry is also handled by the Form. It the way of
ceb6a35 snapshot save
megaannum authored
63 invoking context-sensitive-help from the keyboard. Any 'purpose' information
64 associated with the Form will be displayed in an information dialog.
65
9e930f0 seventh tutorial snapshot save
megaannum authored
66 Additionally, the Form responds to a <RightMouse> click. Like the keyboard
67 <Cntl-H>, this will display Form context-sensitive-help. If
ceb6a35 snapshot save
megaannum authored
68 the mouse click was over an interactive Glyph, a Glyph that can have
69 focus, then, both Glyph usage Help is displayed and any purpose Help
70 associated with the Glyph is also displayed.
71 In this case, since the do-nothing Form has no footprint in the window,
72 it has now width or height, it can not be the target of a mouse click.
73
74 The full code for this do-nothing Form can be found in: [Do Nothing Form](https://github.com/megaannum/forms/blob/master/autoload/forms/tutorial/do_nothing_form.vim)
75
76 This do-nothing Form can be run by entering:
77
78 :call forms#tutorial#do_nothing_form#Make()
79
80 on the command line.
81
Something went wrong with that request. Please try again.