File: lua_api.txt

package info (click to toggle)
termit 2.9.4-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 464 kB
  • sloc: ansic: 3,599; sh: 55; makefile: 6
file content (245 lines) | stat: -rw-r--r-- 6,678 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
h4. Functions

*activateTab(_tab_index_)* - Activates tab by index.
_tab_index_ - index of tab to activate. Index of the first tab is 1.


*addMenu(_menu_)* - Adds menu in menubar.
_menu_ - table of TermitMenuItem type.


*addPopupMenu(_menu_)* - Adds menu in popup menu, similar to addMenu.
_menu_ - table of TermitMenuItem type.


*bindKey(_keys_, _luaFunction_)* - Sets new keybinding. If luaFunction is nil removes keybinding.
_keys_ - string with keybinding. Available modifiers are Alt Ctrl Shift Meta Super Hyper.
_luaFunction_ - callback function

pre. Example: don't close tab with Ctrl-w, use CtrlShift-w
    bindKey('Ctrl-w', nil)
    bindKey('CtrlShift-w', closeTab)


*bindMouse(_event_, _luaFunction_)* - Sets new mouse-binding. If luaFunction is nil removes mouse-binding.
_event_ - string with one of those values: DoubleClick
_luaFunction_ - callback function


*closeTab()* - Closes active tab.


*copy()* - Copies selection into tab's buffer.


*currentTab()* - Returns current tab of TermitTabInfo.


*currentTabIndex()* - Returns current tab index.


*feed(data)* - Interprets data as if it were data received from a terminal process.


*feedChild(data)* - Sends a data to the terminal as if it were data entered by the user at the keyboard. 


*findDlg()* - Opens find entry. (Enabled when build with vte version >= 0.26)


*findNext()* - Searches the next string matching search regex. (Enabled when build with vte version >= 0.26)


*findPrev()* - Searches the previous string matching search regex. (Enabled when build with vte version >= 0.26)


*forEachRow(_func_)* - For each terminal row in entire scrollback buffer executes function passing row as argument.
_func_ - function to be called.


*forEachVisibleRow(_func_)* - For each visible terminal row executes function passing row as argument.
_func_ - function to be called.


*loadSessionDlg()* - Displays "Load session" dialog.


*nextTab()* - Activates next tab.


*openTab(_tabInfo_)* - Opens new tab.
_tabinfo_ - table of TermitTabInfo with tab settings.

pre. Example:
    tabInfo = {}
    tabInfo.title = 'Zsh tab'
    tabInfo.command = 'zsh'
    tabInfo.encoding = 'UTF-8'
    tabInfo.workingDir = '/tmp'
    openTab(tabInfo)


*paste()* - Pastes tab's buffer.


*preferencesDlg()* - Displays "Preferences" dialog.


*prevTab()* - Activates previous tab.


*quit()* - Quit.


*reconfigure()* - Sets all configurable variables to defaults and forces rereading rc.lua.


*saveSessionDlg()* - Displays "Save session" dialog.


*selection()* - Returns selected text from current tab.


*setColormap(_colormap_)* - Changes colormap for active tab.
_colormap_ - array with 8 or 16 or 24 colors.


*setEncoding(_encoding_)* - Changes encoding for active tab.
_encoding_ - string with encoding name.

pre. Example:
    setEncoding('UTF-8')


*setKbPolicy(_kb_policy_)* - Sets keyuboard policy for shortcuts.
_kb_policy_ - string with one of those values:

* keycode - use hardware keyboard codes (XkbLayout-independent)
* keysym - use keysym values (XkbLayout-dependent)

pre. Example: treat keys via current XkbLayout
    setKbPolicy('keysym')

*setOptions(_opts_)* - Changes default options.
_opts_ - table of TermitOptions type with new options:


*setTabBackgroundColor(_color_)* - Changes background color for active tab.
_color_ - string with new color.


*setTabFont(_font_)* - Changes font for active tab.
_font_ - string with new font.


*setTabForegroundColor(_color_)* - Changes foreground (e.g. font) color for active tab.
_color_ - string with new color.


*setTabTitle(_tabTitle_)* - Changes title for active tab.
_tabTitle_ - string with new tab title.


*setTabTitleDlg()* - Displays "Set tab title" dialog.


*setWindowTitle(_title_)* - Changes termit window title.
_title_ - string with new title.


*spawn(_command_) - Spawns command (works via shell).
_command_ - string with command and arguments.

*toggleMenubar()* - Displays or hides menubar.

*toggleTabbar()* - Displays or hides tabbar.

h4. Types

*TermitEraseBinding* - one of those string values:

* Auto - VTE_ERASE_AUTO
* AsciiBksp - VTE_ERASE_ASCII_BACKSPACE
* AsciiDel - VTE_ERASE_ASCII_DELETE
* EraseDel - VTE_ERASE_DELETE_SEQUENCE
* EraseTty - VTE_ERASE_TTY

For detailed description look into Vte docs.

*TermitKeybindings* - table with predefined keybindings.

* closeTab - 'Ctrl-w'
* copy - 'Ctrl-Insert'
* nextTab - 'Alt-Right'
* openTab - 'Ctrl-t'
* paste - 'Shift-Insert'
* prevTab - 'Alt-Left'

pre. Example: enable Gnome-like tab switching
    keys = {}
    keys.nextTab = 'Ctrl-Page_Down'
    keys.prevTab = 'Ctrl-Page_Up'
    setKeys(keys)


*TermitMenuItem* - table for menuitems.

* accel - accelerator for menuitem. String with keybinding
* action - lua-function to execute when item activated
* name - name for menuitem


*TermitOptions* - table with termit options.

* allowChangingTitle - auto change title (similar to xterm)
* audibleBell - enables audible bell
* backgroundColor - background color
* backspaceBinding - reaction on backspace key (one of TermitEraseBinding)
* colormap - array with 8 or 16 or 24 colors
* deleteBinding - reaction on delete key (one of TermitEraseBinding)
* encoding - default encoding
* fillTabbar - expand tabs' titles to fill whole tabbar
* font - font name
* foregroundColor - foreground color
* geometry - cols x rows to start with
* getTabTitle - lua function to generate new tab title
* getWindowTitle - lua function to generate new window title
* hideMenubar - hide menubar
* hideTabbar - hide tabbar
* hideSingleTab - hide menubar when only 1 tab present
* imageFile - path to image to be set on the background
* matches - table with items of TermitMatch type
* scrollbackLines - the length of scrollback buffer
* setStatusbar - lua function to generate new statusbar message
* showScrollbar - display scrollbar
* tabName - default tab name
* tabs - table with items of TermitTabInfo type
* transparency - use transparency level [0,1]
* visibleBell - enables visible bell
* urgencyOnBell - set WM-hint 'urgent' on termit window when bell
* wordChars - word characters (double click selects word)


*TermitTabInfo* - table with tab settings:

* command
* encoding
* font - font string
* fontSize - font size
* pid - process id
* title
* workingDir


h4. Globals

*tabs* - Readonly table with tab settings, access specific tabs by index.


h4. Bugs

After start sometimes there is black screen. Resizing termit window helps.

In options table 'tabs' field should be the last one. When loading all settings are applied in the same order as they are set in options table. So if you set tabs and only then colormap, these tabs would have default colormap.