1 | #!/usr/bin/env node
|
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 | "use strict" ;
|
29 |
|
30 |
|
31 |
|
32 | var termkit = require( '../..' ) ;
|
33 | var term = termkit.terminal ;
|
34 |
|
35 |
|
36 |
|
37 | term.clear() ;
|
38 |
|
39 | var document = term.createDocument() ;
|
40 |
|
41 |
|
42 |
|
43 | var columnMenuMulti = new termkit.ColumnMenuMulti( {
|
44 | parent: document ,
|
45 | x: 0 ,
|
46 | y: 5 ,
|
47 | width: 20 ,
|
48 | pageMaxHeight: 5 ,
|
49 | blurLeftPadding: ' ' ,
|
50 | focusLeftPadding: '^R> ' ,
|
51 | disabledLeftPadding: ' ' ,
|
52 | paddingHasMarkup: true ,
|
53 | multiLineItems: true ,
|
54 |
|
55 | value: {
|
56 | view: true ,
|
57 | file: true
|
58 | } ,
|
59 | items: [
|
60 | {
|
61 | content: 'File' ,
|
62 | key: 'file'
|
63 | } ,
|
64 | {
|
65 |
|
66 | content: '^REdit' , markup: true ,
|
67 | key: 'edit'
|
68 | } ,
|
69 | {
|
70 | content: 'View' ,
|
71 | key: 'view'
|
72 | } ,
|
73 | {
|
74 | content: 'History' ,
|
75 | key: 'history'
|
76 | } ,
|
77 | {
|
78 | content: 'Bookmarks' ,
|
79 | key: 'bookmarks'
|
80 | } ,
|
81 | {
|
82 | content: 'Tools' ,
|
83 | key: 'tools'
|
84 | } ,
|
85 | {
|
86 | content: 'Help' ,
|
87 | key: 'help'
|
88 | } ,
|
89 | {
|
90 | content: 'Disabled button' ,
|
91 | disabled: true ,
|
92 | key: 'disabled'
|
93 | } ,
|
94 | {
|
95 |
|
96 | content: 'Very long, very long, very ^rlong, very long, very long, very long, very ^blong, very long, very long, very long' , markup: true ,
|
97 | key: 'very long'
|
98 | } ,
|
99 | {
|
100 | content: 'Not long' ,
|
101 | key: 'not long'
|
102 | } ,
|
103 | ]
|
104 | } ) ;
|
105 |
|
106 |
|
107 |
|
108 | columnMenuMulti.on( 'submit' , onSubmit ) ;
|
109 |
|
110 | var counter = 0 ;
|
111 |
|
112 | function onSubmit( buttonValue ) {
|
113 | term.saveCursor() ;
|
114 | term.moveTo.styleReset.eraseLine( 1 , 22 , 'Submitted #%i: %J\n' , counter ++ , buttonValue ) ;
|
115 | term.restoreCursor() ;
|
116 | }
|
117 |
|
118 |
|
119 |
|
120 | document.giveFocusTo( columnMenuMulti ) ;
|
121 |
|
122 | term.on( 'key' , function( key ) {
|
123 | switch( key )
|
124 | {
|
125 | case 'CTRL_C' :
|
126 | term.grabInput( false ) ;
|
127 | term.hideCursor( false ) ;
|
128 | term.styleReset() ;
|
129 | term.clear() ;
|
130 | process.exit() ;
|
131 | break ;
|
132 | }
|
133 | } ) ;
|
134 |
|