Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 80 lines (71 sloc) 2.666 kb
4c5e6d4 first commit
megaannum authored
1
2 " ------------------------------------------------------------
3 " forms#dialog#info#Make:
4 " A form that display information.
5 " The form has:
6 " Text
7 " Close Button
8 " Example:
9 " ┌────────────────────────────┐
10 " │Changing Fonts not supported│
11 " │────────────────────────────│
12 " │ Close│
13 " └────────────────────────────┘
14 "
15 " parameters:
16 " texlines : List of static text to be displayed
17 " or String with text separated by '\n'
18 " ------------------------------------------------------------
19 " forms#dialog#info#Make: {{{1
20 function! forms#dialog#info#Make(textlines)
21 " call forms#log("forms#dialog#info#Make")
22 if type(a:textlines) == g:self#LIST_TYPE
23 let textlines = a:textlines
24 elseif type(a:textlines) == g:self#STRING_TYPE
25 let textlines = split(a:textlines, '\n')
26 else
27 throw "forms#dialog#info#Make: textlines parameter must be List of text: " . string(a:textlines)
28 endif
29
30 let text = forms#newText({'textlines': textlines })
31 let size = 20
32 for line in textlines
33 let len = len(line)
34 if len > size
35 let size = len
36 endif
37 endfor
38
39 let char = (&encoding == 'utf-8')
40 \ ? b:forms_BDLightHorizontal
41 \ : b:forms_horz
42 let hline = forms#newHLine({'char': char})
43
44
45 let label = forms#newLabel({'text': "Close"})
46 let closebutton = forms#newButton({
47 \ 'tag': 'exit',
48 \ 'body': label,
49 \ 'action': g:forms#exitAction})
50
51 function! closebutton.purpose() dict
52 return [
53 \ "Close the information dialog."
54 \ ]
55 endfunction
56 let vpoly = forms#newVPoly({ 'children': [text, hline, closebutton], 'alignment': 'R' })
57 let b = forms#newBox({ 'body': vpoly })
58 let bg = forms#newBackground({ 'body': b} )
59 let form = forms#newForm({'body': bg })
60 function! form.purpose() dict
61 return [
62 \ "Provide information to the user."
63 \ ]
64 endfunction
65 call form.run()
66 " call forms#log("forms#dialog#info#Make: bottom")
67 endfunction
68
ee21b40 Better support for both 'light' and 'dard' backgrounds.
megaannum authored
69 " forms#dialog#info#MakeTest: {{{1
70 function! forms#dialog#info#MakeTest()
71 call forms#AppendInput({'type': 'Sleep', 'time': 5})
72 call forms#AppendInput({'type': 'Exit'})
73 let textlines = "Display some information.\nText can be on multiple lines."
74 call forms#dialog#info#Make(textlines)
75 endfunction
76
4c5e6d4 first commit
megaannum authored
77 " Modelines: {{{1
78 " ================
79 " vim: ts=4 fdm=marker
Something went wrong with that request. Please try again.