1import cudatext_api as ct
2
3MB_OK               = 0x00
4MB_OKCANCEL         = 0x01
5MB_ABORTRETRYIGNORE = 0x02
6MB_YESNOCANCEL      = 0x03
7MB_YESNO            = 0x04
8MB_RETRYCANCEL      = 0x05
9MB_ICONERROR        = 0x10
10MB_ICONQUESTION     = 0x20
11MB_ICONWARNING      = 0x30
12MB_ICONINFO         = 0x40
13
14ID_OK     = 1
15ID_CANCEL = 2
16ID_ABORT  = 3
17ID_RETRY  = 4
18ID_IGNORE = 5
19ID_YES    = 6
20ID_NO     = 7
21
22SEL_NORMAL = 0
23SEL_COLUMN = 1
24
25CARET_SET_ONE    = 0
26CARET_ADD        = 1
27CARET_DELETE_ALL = 2
28CARET_SET_INDEX  = 100
29CARET_DELETE_INDEX = 2000000
30
31CARET_OPTION_NO_SCROLL = 1
32CARET_OPTION_UNFOLD = 2
33
34APP_DIR_EXE             = 0
35APP_DIR_SETTINGS        = 1
36APP_DIR_DATA            = 2
37APP_DIR_PY              = 3
38APP_FILE_SESSION        = 4
39APP_DIR_INSTALLED_ADDON = 5
40APP_FILE_RECENTS        = 6
41APP_DIR_SETTINGS_DEF    = 7
42
43CONVERT_CHAR_TO_COL         = 0
44CONVERT_COL_TO_CHAR         = 1
45CONVERT_LINE_TABS_TO_SPACES = 2
46CONVERT_OFFSET_TO_CARET     = 3
47CONVERT_CARET_TO_OFFSET     = 4
48CONVERT_SCREEN_TO_LOCAL     = 5
49CONVERT_LOCAL_TO_SCREEN     = 6
50CONVERT_PIXELS_TO_CARET     = 7
51CONVERT_CARET_TO_PIXELS     = 8
52
53TOKEN_GET_KIND = 1
54TOKEN_LIST     = 2
55TOKEN_LIST_SUB = 3
56
57LINESTATE_NORMAL  = 0
58LINESTATE_CHANGED = 1
59LINESTATE_ADDED   = 2
60LINESTATE_SAVED   = 3
61
62LINENUM_ALL    = 0
63LINENUM_NONE   = 1
64LINENUM_EACH10 = 2
65LINENUM_EACH5  = 3
66
67COLOR_NONE = 0x1FFFFFFF
68COLOR_DEFAULT = 0x20000000
69
70WRAP_OFF       = 0
71WRAP_ON_WINDOW = 1
72WRAP_ON_MARGIN = 2
73
74#dlg_menu
75DMENU_LIST          = 0
76DMENU_LIST_ALT      = 1
77DMENU_NO_FUZZY      = 16
78DMENU_NO_FULLFILTER = 32
79DMENU_CENTERED      = 64
80DMENU_EDITORFONT    = 128
81
82CLIP_NONE   = 0
83CLIP_LEFT   = 1
84CLIP_MIDDLE = 2
85CLIP_RIGHT  = 3
86
87#menu_proc
88MENU_CLEAR         = 0
89MENU_ENUM          = 1
90MENU_ADD           = 2
91MENU_REMOVE        = 3
92MENU_SET_CAPTION   = 4
93MENU_SET_VISIBLE   = 5
94MENU_SET_ENABLED   = 6
95MENU_SET_CHECKED   = 7
96MENU_SET_RADIOITEM = 8
97MENU_SET_HOTKEY    = 9
98MENU_CREATE        = 10
99MENU_SHOW          = 12
100MENU_GET_PROP      = 14
101MENU_SET_IMAGELIST = 20
102MENU_SET_IMAGEINDEX = 21
103
104BOOKMARK_SET         = 1
105BOOKMARK_CLEAR       = 2
106BOOKMARK_CLEAR_ALL   = 3
107BOOKMARK_SETUP       = 4
108BOOKMARK_GET_LIST    = 5
109BOOKMARK_GET_ALL     = 6
110BOOKMARK_GET_PROP      = 7
111BOOKMARK_DELETE_BY_TAG = 8
112
113BOOKMARK2_SET         = 11
114BOOKMARK2_CLEAR       = 12
115BOOKMARK2_CLEAR_ALL   = 13
116BOOKMARK2_GET_ALL     = 16
117BOOKMARK2_GET_PROP      = 17
118BOOKMARK2_DELETE_BY_TAG = 18
119
120MARKERS_GET           = 0
121MARKERS_ADD           = 1
122MARKERS_DELETE_ALL    = 2
123MARKERS_DELETE_LAST   = 3
124MARKERS_DELETE_BY_TAG = 4
125MARKERS_DELETE_BY_INDEX = 5
126MARKERS_ADD_MANY      = 6
127MARKERS_GET_DICT      = 7
128
129TIMER_START     = 0
130TIMER_START_ONE = 1
131TIMER_STOP      = 2
132TIMER_DELETE    = 3
133
134LOG_CLEAR           = 0
135LOG_ADD             = 1
136LOG_SET_REGEX       = 3
137LOG_SET_LINE_ID     = 4
138LOG_SET_COL_ID      = 5
139LOG_SET_NAME_ID     = 6
140LOG_SET_FILENAME    = 7
141LOG_SET_ZEROBASE    = 8
142LOG_GET_LINEINDEX   = 10
143LOG_SET_LINEINDEX   = 11
144LOG_GET_LINES_LIST  = 12
145LOG_CONSOLE_CLEAR   = 20
146LOG_CONSOLE_ADD     = 21
147LOG_CONSOLE_GET_COMBO_LINES = 24
148LOG_CONSOLE_GET_MEMO_LINES  = 25
149
150LOG_PANEL_OUTPUT   = "0"
151LOG_PANEL_VALIDATE = "1"
152
153PROP_GUTTER_ALL     = -1
154PROP_GUTTER_STATES  = 0
155PROP_GUTTER_NUM     = 1
156PROP_GUTTER_FOLD    = 2
157PROP_GUTTER_BM      = 3
158PROP_WRAP           = 5
159PROP_RO             = 6
160PROP_TAB_SPACES     = 7
161PROP_TAB_SIZE       = 8
162PROP_MARGIN         = 9
163PROP_MARGIN_STRING  = 10
164PROP_INSERT         = 11
165PROP_MODIFIED       = 12
166PROP_RULER          = 13
167PROP_LINE_STATE     = 14
168PROP_COLOR          = 15
169PROP_LINE_TOP       = 16
170PROP_ENC            = 17
171PROP_TAB_TITLE      = 18
172PROP_TAB_COLOR      = 19
173PROP_LEXER_FILE     = 20
174PROP_LEXER_POS      = 21
175PROP_LEXER_CARET    = 22
176PROP_INDEX_GROUP    = 23
177PROP_INDEX_TAB      = 24
178PROP_TAG            = 25
179PROP_CARET_VIEW           = 26
180PROP_CARET_VIEW_OVR       = 27
181PROP_CARET_VIEW_RO        = 28
182PROP_CARET_VIRTUAL         = 29
183PROP_UNPRINTED_SHOW        = 30
184PROP_UNPRINTED_SPACES      = 31
185PROP_UNPRINTED_ENDS        = 32
186PROP_UNPRINTED_END_DETAILS = 33
187PROP_TAB_ICON              = 34
188PROP_TAB_COLLECT_MARKERS   = 35
189PROP_MACRO_REC             = 36
190PROP_TAB_PINNED            = 37
191PROP_MARKED_RANGE          = 38
192PROP_LINE_NUMBERS          = 39
193PROP_VISIBLE_LINES         = 40
194PROP_VISIBLE_COLUMNS       = 41
195PROP_LINE_BOTTOM           = 42
196PROP_PICTURE               = 43
197PROP_MINIMAP               = 44
198PROP_MICROMAP              = 45
199PROP_LINK_AT_POS           = 46
200PROP_MODIFIED_VERSION      = 47
201PROP_TAB_ID                = 48
202PROP_IN_SESSION            = 49
203PROP_COORDS                = 50
204PROP_ONE_LINE              = 51
205PROP_SCROLL_VERT           = 52
206PROP_SCROLL_HORZ           = 53
207PROP_CODETREE              = 54
208PROP_EDITORS_LINKED        = 55
209PROP_IN_HISTORY            = 56
210PROP_SCROLL_VERT_SMOOTH    = 57
211PROP_SCROLL_HORZ_SMOOTH    = 58
212PROP_KIND                  = 59
213PROP_V_MODE                = 60
214PROP_V_POS                 = 61
215PROP_V_SEL_START           = 62
216PROP_V_SEL_LEN             = 63
217PROP_V_WIDTH               = 64
218PROP_NEWLINE               = 65
219PROP_SCROLL_VERT_INFO      = 66
220PROP_SCROLL_HORZ_INFO      = 67
221PROP_SCALE_FONT            = 68
222PROP_ENC_RELOAD            = 69
223PROP_CELL_SIZE             = 70
224PROP_INDENT_SIZE           = 71
225PROP_INDENT_KEEP_ALIGN     = 72
226PROP_INDENT_AUTO           = 73
227PROP_INDENT_KIND           = 74
228PROP_LAST_LINE_ON_TOP      = 75
229PROP_UNPRINTED_SPACES_TRAILING = 76
230PROP_HILITE_CUR_COL            = 77
231PROP_HILITE_CUR_LINE           = 78
232PROP_HILITE_CUR_LINE_MINIMAL   = 79
233PROP_HILITE_CUR_LINE_IF_FOCUS  = 80
234PROP_CARET_STOP_UNFOCUSED      = 81
235PROP_ACTIVATION_TIME           = 82
236PROP_FOCUSED                   = 83
237PROP_MODERN_SCROLLBAR          = 85
238PROP_SAVE_HISTORY              = 86
239PROP_PREVIEW                   = 87
240PROP_UNDO_GROUPED              = 88
241PROP_UNDO_LIMIT                = 89
242PROP_UNDO_DATA                 = 90
243PROP_REDO_DATA                 = 91
244PROP_SPLIT                     = 92
245PROP_SAVING_FORCE_FINAL_EOL    = 93
246PROP_SAVING_TRIM_SPACES        = 94
247PROP_SAVING_TRIM_FINAL_EMPTY_LINES = 95
248PROP_ZEBRA                     = 96
249PROP_ZEBRA_STEP                = 97
250PROP_TAB_UI_SHOW               = 98
251PROP_LINE_STATES               = 99
252PROP_LINE_STATES_UPDATED       = 100
253PROP_FOLD_TOOLTIP_SHOW         = 101
254PROP_FOLD_ALWAYS               = 102
255PROP_FOLD_ICONS                = 103
256PROP_SCROLLSTYLE_HORZ          = 104
257PROP_SCROLLSTYLE_VERT          = 105
258PROP_LINKS_SHOW                = 106
259PROP_LINKS_REGEX               = 107
260PROP_LINKS_CLICKS              = 108
261PROP_HANDLE_SELF        = 110
262PROP_HANDLE_PRIMARY     = 111
263PROP_HANDLE_SECONDARY   = 112
264PROP_HANDLE_PARENT      = 113
265PROP_RECT_CLIENT        = 115
266PROP_RECT_TEXT          = 116
267PROP_THEMED             = 118
268PROP_COMBO_ITEMS        = 119
269PROP_CODETREE_MODIFIED_VERSION = 120
270PROP_CODETREE_SUBLEXER         = 121
271PROP_FONT                      = 122
272PROP_FONT_B                    = 123
273PROP_FONT_I                    = 124
274PROP_FONT_BI                   = 125
275PROP_RECT_GUTTER      = 130
276#PROP_RECT_GUTTER_NUMS = 131
277#PROP_RECT_GUTTER_FOLD = 132
278#PROP_RECT_GUTTER_BM   = 133
279PROP_RECT_MINIMAP     = 135
280PROP_RECT_MICROMAP    = 136
281PROP_RECT_RULER       = 137
282#PROP_RECT_SCROLL_HORZ = 138
283#PROP_RECT_SCROLL_VERT = 139
284PROP_V_WIDTH_HEX        = 140
285PROP_V_WIDTH_UHEX       = 141
286PROP_MASKCHAR           = 150
287PROP_MASKCHAR_USED      = 151
288PROP_NUMBERS_ONLY       = 153
289PROP_NUMBERS_NEGATIVE   = 154
290PROP_COMMAND_LOG        = 155
291PROP_COMMAND_LOG_LIMIT  = 156
292
293SPLITTER_SIDE    = 0
294SPLITTER_BOTTOM  = 1
295SPLITTER_G1      = 5
296SPLITTER_G2      = 6
297SPLITTER_G3      = 7
298SPLITTER_G4      = 8
299SPLITTER_G5      = 9
300
301PROC_SET_CLIP_ALT        = -1
302PROC_GET_CLIP            = 0
303PROC_SET_CLIP            = 1
304PROC_GET_OS_SUFFIX       = 2
305PROC_SAVE_SESSION        = 3
306PROC_LOAD_SESSION        = 4
307PROC_SET_SESSION         = 5
308PROC_SET_FOLDER          = 7
309PROC_GET_COMMANDS        = 8
310PROC_SET_EVENTS          = 10
311PROC_GET_LAST_PLUGIN     = 11
312PROC_GET_GROUPING        = 12
313PROC_SET_GROUPING        = 13
314PROC_EXEC_PYTHON         = 14
315PROC_EXEC_PLUGIN         = 15
316PROC_SET_SUBCOMMANDS     = 16
317PROC_GET_ESCAPE          = 17
318PROC_SET_ESCAPE          = 18
319PROC_PARSE_COMMAND_LINE  = 19
320#
321PROC_SIDEPANEL_ACTIVATE    = 25
322PROC_SIDEPANEL_ENUM        = 26
323PROC_SIDEPANEL_GET_CONTROL = 27
324PROC_SIDEPANEL_ENUM_ALL    = 28
325PROC_SIDEPANEL_REMOVE      = 29
326PROC_SIDEPANEL_ADD_DIALOG  = 30
327PROC_SIDEPANEL_GET         = 31
328PROC_SIDEPANEL_SET_PROP    = 32
329PROC_SIDEPANEL_GET_IMAGELIST = 33
330#
331PROC_GET_FINDER_PROP   = 36
332PROC_SET_FINDER_PROP   = 37
333PROC_SPLITTER_GET      = 38
334PROC_SPLITTER_SET      = 39
335#
336PROC_GET_LANG          = 40
337PROC_GET_HOTKEY        = 41
338PROC_SET_HOTKEY        = 42
339PROC_GET_KEYSTATE      = 43
340PROC_GET_FIND_STRINGS  = 44
341PROC_GET_GUI_HEIGHT    = 45
342PROC_THEME_UI_GET      = 46
343PROC_THEME_UI_SET      = 47
344PROC_THEME_SYNTAX_GET  = 48
345PROC_THEME_SYNTAX_SET  = 49
346PROC_GET_SYSTEM_PPI    = 50
347PROC_PROGRESSBAR       = 51
348PROC_GET_TAB_IMAGELIST = 52
349PROC_GET_MOUSE_POS     = 53
350PROC_GET_CONSOLE_FORM  = 55
351PROC_GET_CODETREE = 56
352PROC_WINDOW_TOPMOST_GET = 57
353PROC_WINDOW_TOPMOST_SET = 58
354PROC_HOTKEY_INT_TO_STR = 60
355PROC_HOTKEY_STR_TO_INT = 61
356PROC_THEME_UI_DICT_GET     = 62
357PROC_THEME_SYNTAX_DICT_GET = 63
358PROC_GET_OUTPUT_FORM   = 64
359PROC_GET_VALIDATE_FORM = 65
360PROC_GET_MAIN_TOOLBAR   = 66
361PROC_GET_MAIN_STATUSBAR = 67
362#
363PROC_BOTTOMPANEL_ACTIVATE    = 81
364PROC_BOTTOMPANEL_ENUM        = 82
365PROC_BOTTOMPANEL_GET_CONTROL = 83
366PROC_BOTTOMPANEL_REMOVE      = 84
367PROC_BOTTOMPANEL_ADD_DIALOG  = 85
368PROC_BOTTOMPANEL_GET         = 86
369PROC_BOTTOMPANEL_SET_PROP    = 87
370PROC_BOTTOMPANEL_ENUM_ALL    = 88
371#
372PROC_CLIP_ENUM            = 90
373PROC_CLIP_SAVE_PIC        = 91
374PROC_SHOW_STATUSBAR_GET   = 100
375PROC_SHOW_STATUSBAR_SET   = 101
376PROC_SHOW_TOOLBAR_GET     = 102
377PROC_SHOW_TOOLBAR_SET     = 103
378PROC_SHOW_SIDEPANEL_GET   = 104
379PROC_SHOW_SIDEPANEL_SET   = 105
380PROC_SHOW_BOTTOMPANEL_GET = 106
381PROC_SHOW_BOTTOMPANEL_SET = 107
382PROC_SHOW_TABS_GET        = 108
383PROC_SHOW_TABS_SET        = 109
384PROC_SHOW_SIDEBAR_GET     = 110
385PROC_SHOW_SIDEBAR_SET     = 111
386PROC_SHOW_FLOATGROUP1_GET = 112
387PROC_SHOW_FLOATGROUP1_SET = 113
388PROC_SHOW_FLOATGROUP2_GET = 114
389PROC_SHOW_FLOATGROUP2_SET = 115
390PROC_SHOW_FLOATGROUP3_GET = 116
391PROC_SHOW_FLOATGROUP3_SET = 117
392PROC_SHOW_TREEFILTER_GET  = 118
393PROC_SHOW_TREEFILTER_SET  = 119
394#
395PROC_FLOAT_SIDE_GET       = 120
396PROC_FLOAT_SIDE_SET       = 121
397PROC_FLOAT_BOTTOM_GET     = 122
398PROC_FLOAT_BOTTOM_SET     = 123
399#
400PROC_COORD_WINDOW_GET = 140
401PROC_COORD_WINDOW_SET = 141
402PROC_COORD_DESKTOP    = 142
403PROC_COORD_MONITOR    = 143
404PROC_COORD_MONITOR0   = 144
405PROC_COORD_MONITOR1   = 145
406PROC_COORD_MONITOR2   = 146
407PROC_COORD_MONITOR3   = 147
408#
409PROC_SET_PROJECT      = 158
410PROC_GET_UNIQUE_TAG   = 159
411PROC_ENUM_FONTS       = 160
412PROC_SEND_MESSAGE     = 161
413
414PROC_CONFIG_READ           = 169
415PROC_CONFIG_NEWDOC_EOL_GET = 170
416PROC_CONFIG_NEWDOC_EOL_SET = 171
417PROC_CONFIG_NEWDOC_ENC_GET = 172
418PROC_CONFIG_NEWDOC_ENC_SET = 173
419PROC_CONFIG_SCALE_GET      = 175
420PROC_CONFIG_SCALE_SET      = 176
421
422TREE_ITEM_ENUM_EX          = 0
423TREE_ITEM_ENUM             = 1
424TREE_ITEM_ADD              = 2
425TREE_ITEM_DELETE           = 3
426TREE_ITEM_SET_TEXT         = 4
427TREE_ITEM_SET_ICON         = 5
428TREE_ITEM_SELECT           = 6
429TREE_ITEM_FOLD             = 7
430TREE_ITEM_FOLD_DEEP        = 8
431TREE_ITEM_UNFOLD           = 9
432TREE_ITEM_UNFOLD_DEEP      = 10
433TREE_ITEM_GET_SELECTED     = 11
434TREE_ITEM_SET_RANGE        = 13
435TREE_ITEM_GET_RANGE        = 14
436TREE_ITEM_FOLD_LEVEL       = 15
437TREE_ITEM_SHOW             = 16
438TREE_ITEM_GET_PROPS        = 17
439TREE_FIND_FOR_TEXT_POS     = 24
440TREE_GET_IMAGELIST         = 25
441TREE_SET_IMAGELIST         = 26
442TREE_PROP_SHOW_ROOT        = 30
443TREE_LOCK                  = 31
444TREE_UNLOCK                = 32
445TREE_THEME                 = 33
446
447LISTBOX_GET_COUNT    = 0
448LISTBOX_ADD          = 1
449LISTBOX_DELETE       = 2
450LISTBOX_DELETE_ALL   = 3
451LISTBOX_GET_ITEM     = 4
452LISTBOX_SET_ITEM     = 5
453LISTBOX_GET_HOTTRACK = 6
454LISTBOX_SET_HOTTRACK = 7
455LISTBOX_GET_ITEM_PROP = 8
456LISTBOX_SET_ITEM_PROP = 9
457LISTBOX_GET_SEL      = 10
458LISTBOX_SET_SEL      = 11
459LISTBOX_ADD_PROP     = 12
460LISTBOX_GET_TOP      = 14
461LISTBOX_SET_TOP      = 15
462LISTBOX_GET_ITEM_H   = 16
463LISTBOX_SET_ITEM_H   = 17
464LISTBOX_GET_DRAWN    = 18
465LISTBOX_SET_DRAWN    = 19
466LISTBOX_THEME        = 20
467LISTBOX_GET_COLUMN_SEP = 22
468LISTBOX_SET_COLUMN_SEP = 23
469LISTBOX_GET_COLUMNS = 24
470LISTBOX_SET_COLUMNS = 25
471LISTBOX_GET_SHOW_X  = 26
472LISTBOX_SET_SHOW_X  = 27
473LISTBOX_GET_SCROLLPOS_HORZ = 30
474LISTBOX_SET_SCROLLPOS_HORZ = 31
475LISTBOX_GET_SCROLLSTYLE_HORZ = 32
476LISTBOX_SET_SCROLLSTYLE_HORZ = 33
477LISTBOX_GET_SCROLLSTYLE_VERT = 34
478LISTBOX_SET_SCROLLSTYLE_VERT = 35
479LISTBOX_GET_HEADER  = 36
480LISTBOX_SET_HEADER  = 37
481LISTBOX_GET_HEADER_IMAGELIST = 38
482LISTBOX_SET_HEADER_IMAGELIST = 39
483LISTBOX_GET_HEADER_IMAGEINDEXES = 40
484LISTBOX_SET_HEADER_IMAGEINDEXES = 41
485
486SCROLLSTYLE_HIDE = 0
487SCROLLSTYLE_SHOW = 1
488SCROLLSTYLE_AUTO = 2
489
490LEXER_GET_LEXERS     = 0
491LEXER_GET_PROP       = 1
492LEXER_DETECT         = 2
493LEXER_REREAD_LIB     = 3
494LEXER_GET_STYLES     = 4
495LEXER_ADD_VIRTUAL    = 5
496
497GROUPS_ONE     = 1
498GROUPS_2VERT   = 2
499GROUPS_2HORZ   = 3
500GROUPS_3VERT   = 4
501GROUPS_3HORZ   = 5
502GROUPS_3PLUS   = 6 #deprecated
503GROUPS_1P2VERT = 6
504GROUPS_1P2HORZ = 7
505GROUPS_4VERT   = 8
506GROUPS_4HORZ   = 9
507GROUPS_4GRID   = 10
508GROUPS_6VERT   = 11
509GROUPS_6HORZ   = 12
510GROUPS_6GRID   = 13
511
512EMMET_EXPAND   = 0
513EMMET_WRAP     = 1
514EMMET_GET_POS  = 2
515
516EDACTION_UPDATE         = 0
517EDACTION_UNDOGROUP_BEGIN = 1
518EDACTION_UNDOGROUP_END   = 2
519EDACTION_REPLACE_ALL    = 4
520EDACTION_REPLACE_ONE    = 5
521EDACTION_FIND_ONE       = 6
522EDACTION_FIND_ALL       = 7
523EDACTION_FIND_BRACKETS  = 8
524EDACTION_SHOW_POS       = 9
525EDACTION_CODETREE_FILL  = 10
526EDACTION_LEXER_SCAN     = 11
527EDACTION_APPLY_THEME    = 12
528EDACTION_EXPORT_HTML    = 15
529
530MICROMAP_GET    = 0
531MICROMAP_ADD    = 1
532MICROMAP_DELETE = 2
533
534APPSTATE_LANG          = 20
535APPSTATE_THEME_UI      = 21
536APPSTATE_THEME_SYNTAX  = 22
537APPSTATE_GROUPS        = 23
538APPSTATE_CONFIG_REREAD = 24
539APPSTATE_SESSION_LOAD  = 25
540APPSTATE_SESSION_LOAD_BEGIN = 26
541APPSTATE_SESSION_LOAD_FAIL  = 27
542APPSTATE_PROJECT            = 28
543APPSTATE_API_SUBCOMMANDS    = 30
544APPSTATE_API_MENU_ADD       = 31
545APPSTATE_API_MENU_REMOVE    = 32
546APPSTATE_API_MENU_CHANGE    = 33
547APPSTATE_CODETREE_CLEAR         = 40
548APPSTATE_CODETREE_BEFORE_FILL   = 41
549APPSTATE_CODETREE_AFTER_FILL    = 42
550APPSTATE_CODETREE_SET_SELECTION = 43
551
552EDSTATE_WRAP      = 1
553EDSTATE_TAB_TITLE = 2
554EDSTATE_MODIFIED  = 3
555EDSTATE_PINNED    = 4
556EDSTATE_READONLY  = 5
557EDSTATE_ZOOM      = 6
558EDSTATE_BOOKMARK  = 7
559
560COLOR_ID_TextFont = 'EdTextFont'
561COLOR_ID_TextBg = 'EdTextBg'
562COLOR_ID_SelFont = 'EdSelFont'
563COLOR_ID_SelBg = 'EdSelBg'
564COLOR_ID_DisableFont = 'EdDisableFont'
565COLOR_ID_DisableBg = 'EdDisableBg'
566COLOR_ID_Caret = 'EdCaret'
567COLOR_ID_Markers = 'EdMarkers'
568COLOR_ID_CurLineBg = 'EdCurLineBg'
569COLOR_ID_IndentVLine = 'EdIndentVLine'
570COLOR_ID_UnprintFont = 'EdUnprintFont'
571COLOR_ID_UnprintBg = 'EdUnprintBg'
572COLOR_ID_UnprintHexFont = 'EdUnprintHexFont'
573COLOR_ID_MinimapBorder = 'EdMinimapBorder'
574COLOR_ID_MinimapSelBg = 'EdMinimapSelBg'
575COLOR_ID_MinimapTooltipBg = 'EdMinimapTooltipBg'
576COLOR_ID_MinimapTooltipBorder = 'EdMinimapTooltipBorder'
577COLOR_ID_StateChanged = 'EdStateChanged'
578COLOR_ID_StateAdded = 'EdStateAdded'
579COLOR_ID_StateSaved = 'EdStateSaved'
580COLOR_ID_BlockStaple = 'EdBlockStaple'
581COLOR_ID_BlockStapleActive = 'EdBlockStapleActive'
582COLOR_ID_BlockSepLine = 'EdBlockSepLine'
583COLOR_ID_Links = 'EdLinks'
584COLOR_ID_LockedBg = 'EdLockedBg'
585COLOR_ID_ComboArrow = 'EdComboArrow'
586COLOR_ID_ComboArrowBg = 'EdComboArrowBg'
587COLOR_ID_FoldMarkLine = 'EdFoldMarkLine'
588COLOR_ID_FoldMarkFont = 'EdFoldMarkFont'
589COLOR_ID_FoldMarkBorder = 'EdFoldMarkBorder'
590COLOR_ID_FoldMarkBg = 'EdFoldMarkBg'
591COLOR_ID_GutterFont = 'EdGutterFont'
592COLOR_ID_GutterBg = 'EdGutterBg'
593COLOR_ID_GutterCaretFont = 'EdGutterCaretFont'
594COLOR_ID_GutterCaretBg = 'EdGutterCaretBg'
595COLOR_ID_BookmarkBg = 'EdBookmarkBg'
596COLOR_ID_RulerFont = 'EdRulerFont'
597COLOR_ID_RulerBg = 'EdRulerBg'
598COLOR_ID_FoldLine = 'EdFoldLine'
599COLOR_ID_FoldBg = 'EdFoldBg'
600COLOR_ID_FoldPlusLine = 'EdFoldPlusLine'
601COLOR_ID_FoldPlusBg = 'EdFoldPlusBg'
602COLOR_ID_MarginFixed = 'EdMarginFixed'
603COLOR_ID_MarginCaret = 'EdMarginCaret'
604COLOR_ID_MarginUser = 'EdMarginUser'
605COLOR_ID_MarkedRangeBg = 'EdMarkedRangeBg'
606COLOR_ID_Border = 'EdBorder'
607COLOR_ID_BorderFocused = 'EdBorderFocused'
608
609CANVAS_SET_FONT      = 1
610CANVAS_SET_PEN       = 2
611CANVAS_SET_BRUSH     = 3
612CANVAS_SET_ANTIALIAS = 4
613CANVAS_SET_TESTPANEL = 9
614#CANVAS_GET_FONT      = 11
615#CANVAS_GET_PEN       = 12
616#CANVAS_GET_BRUSH     = 13
617CANVAS_GET_TEXT_SIZE = 15
618CANVAS_TEXT          = 20
619CANVAS_LINE          = 21
620CANVAS_PIXEL         = 24
621CANVAS_RECT          = 30
622CANVAS_RECT_FRAME    = 31
623CANVAS_RECT_FILL     = 32
624CANVAS_RECT_ROUND    = 33
625CANVAS_POLYGON       = 35
626CANVAS_ELLIPSE       = 40
627
628FONT_B = 1
629FONT_I = 2
630FONT_U = 4
631FONT_S = 8
632
633#TFPPenStyle = (psSolid, psDash, psDot, psDashDot, psDashDotDot, psinsideFrame, psPattern, psClear);
634PEN_STYLE_SOLID       = 0
635PEN_STYLE_DASH        = 1
636PEN_STYLE_DOT         = 2
637PEN_STYLE_DASHDOT     = 3
638PEN_STYLE_DASHDOTDOT  = 4
639PEN_STYLE_INSIDEFRAME = 5
640PEN_STYLE_PATTERN     = 6
641PEN_STYLE_CLEAR       = 7
642
643#TFPPenEndCap = (pecRound, pecSquare, pecFlat);
644PEN_CAPS_ROUND  = 0
645PEN_CAPS_SQUARE = 1
646PEN_CAPS_FLAT   = 2
647
648#TFPPenJoinStyle = (pjsRound, pjsBevel, pjsMiter);
649PEN_JOIN_ROUND = 0
650PEN_JOIN_BEVEL = 1
651PEN_JOIN_MITER = 2
652
653#TFPBrushStyle = (bsSolid, bsClear, bsHorizontal, bsVertical, bsFDiagonal,
654#                 bsBDiagonal, bsCross, bsDiagCross, bsImage, bsPattern);
655BRUSH_SOLID     = 0
656BRUSH_CLEAR     = 1
657BRUSH_HORZ      = 2
658BRUSH_VERT      = 3
659BRUSH_FDIAGONAL = 4
660BRUSH_BDIAGONAL = 5
661BRUSH_CROSS     = 6
662BRUSH_DIAGCROSS = 7
663#BRUSH_IMAGE     = 8
664#BRUSH_PATTERN   = 9
665
666ANTIALIAS_NONE = 0
667ANTIALIAS_ON   = 1
668ANTIALIAS_OFF  = 2
669
670GAP_MAKE_BITMAP = 1
671GAP_ADD         = 2
672GAP_DELETE      = 3
673GAP_DELETE_ALL  = 4
674GAP_GET_ALL     = 5
675GAP_DELETE_BY_TAG = 6
676
677FOLDING_GET_LIST           = 0
678FOLDING_FOLD               = 1
679FOLDING_UNFOLD             = 2
680FOLDING_ADD                = 3
681FOLDING_DELETE             = 4
682FOLDING_DELETE_ALL         = 5
683FOLDING_FIND               = 6
684FOLDING_UNFOLD_LINE        = 7
685FOLDING_FOLD_ALL           = 8
686FOLDING_UNFOLD_ALL         = 9
687FOLDING_CHECK_RANGE_INSIDE = 10
688FOLDING_CHECK_RANGES_SAME  = 11
689FOLDING_FOLD_LEVEL         = 12
690FOLDING_GET_LIST_FILTERED  = 13
691
692COMMANDS_USUAL   = 1
693COMMANDS_PLUGINS = 2
694COMMANDS_LEXERS  = 4
695COMMANDS_CONFIG  = 8
696COMMANDS_CENTERED = 16
697COMMANDS_FILES    = 32
698COMMANDS_RECENTS  = 64
699COMMANDS_CONFIG_LEXER = 128
700
701TOOLBAR_UPDATE         = 1
702TOOLBAR_GET_BUTTON_HANDLE = 2
703TOOLBAR_GET_COUNT      = 3
704TOOLBAR_GET_BUTTON_HANDLES = 4
705TOOLBAR_GET_INDEX_HOVERED = 5
706TOOLBAR_DELETE_ALL     = 6
707TOOLBAR_DELETE_BUTTON  = 7
708TOOLBAR_ADD_ITEM       = 8
709TOOLBAR_ADD_MENU       = 9
710TOOLBAR_GET_IMAGELIST  = 12
711TOOLBAR_GET_WRAP       = 14
712TOOLBAR_SET_WRAP       = 15
713TOOLBAR_GET_VERTICAL   = 16
714TOOLBAR_SET_VERTICAL   = 17
715TOOLBAR_THEME          = 20
716
717DLG_CREATE         = 0
718DLG_FREE           = 1
719DLG_LOCK           = 2
720DLG_UNLOCK         = 3
721DLG_SHOW_MODAL     = 5
722DLG_SHOW_NONMODAL  = 6
723DLG_HIDE           = 7
724DLG_FOCUS          = 8
725DLG_SCALE          = 9
726DLG_PROP_GET       = 10
727DLG_PROP_SET       = 11
728DLG_DOCK           = 12
729DLG_UNDOCK         = 13
730DLG_TO_FRONT       = 14
731#DLG_TO_BACK        = 15
732DLG_CTL_COUNT      = 20
733DLG_CTL_ADD        = 21
734DLG_CTL_PROP_GET   = 22
735DLG_CTL_PROP_SET   = 23
736DLG_CTL_DELETE     = 24
737DLG_CTL_DELETE_ALL = 25
738DLG_CTL_TO_FRONT   = 26
739DLG_CTL_TO_BACK    = 27
740DLG_CTL_FOCUS      = 30
741DLG_CTL_FIND       = 31
742DLG_CTL_HANDLE     = 32
743DLG_COORD_LOCAL_TO_SCREEN = 40
744DLG_COORD_SCREEN_TO_LOCAL = 41
745DLG_POS_GET_STR      = 45
746DLG_POS_SET_FROM_STR = 46
747
748#storage of live callbacks
749_live = {}
750
751IMAGE_CREATE      = 0
752IMAGE_GET_SIZE    = 1
753IMAGE_LOAD        = 2
754IMAGE_PAINT       = 5
755IMAGE_PAINT_SIZED = 6
756
757IMAGELIST_CREATE     = 0
758IMAGELIST_COUNT      = 1
759IMAGELIST_GET_SIZE   = 2
760IMAGELIST_SET_SIZE   = 3
761IMAGELIST_ADD        = 5
762IMAGELIST_DELETE     = 6
763IMAGELIST_DELETE_ALL = 7
764IMAGELIST_PAINT      = 10
765
766BTN_UPDATE         = -1
767BTN_GET_CHECKED    = 0
768BTN_SET_CHECKED    = 1
769BTN_GET_IMAGELIST  = 2
770BTN_SET_IMAGELIST  = 3
771BTN_GET_IMAGEINDEX = 4
772BTN_SET_IMAGEINDEX = 5
773BTN_GET_KIND       = 6
774BTN_SET_KIND       = 7
775BTN_GET_BOLD       = 8
776BTN_SET_BOLD       = 9
777BTN_GET_ENABLED    = 10
778BTN_SET_ENABLED    = 11
779BTN_GET_VISIBLE    = 12
780BTN_SET_VISIBLE    = 13
781BTN_GET_HINT       = 14
782BTN_SET_HINT       = 15
783BTN_GET_TEXT       = 16
784BTN_SET_TEXT       = 17
785BTN_GET_MENU       = 18
786BTN_SET_MENU       = 19
787BTN_GET_DATA1      = 20
788BTN_SET_DATA1      = 21
789BTN_GET_DATA2      = 22
790BTN_SET_DATA2      = 23
791BTN_GET_ARROW      = 30
792BTN_SET_ARROW      = 31
793BTN_GET_FOCUSABLE  = 32
794BTN_SET_FOCUSABLE  = 33
795BTN_GET_FLAT       = 34
796BTN_SET_FLAT       = 35
797BTN_GET_WIDTH      = 38
798BTN_SET_WIDTH      = 39
799BTN_GET_ITEMS      = 40
800BTN_SET_ITEMS      = 41
801BTN_GET_ITEMINDEX  = 42
802BTN_SET_ITEMINDEX  = 43
803BTN_GET_ARROW_ALIGN = 44
804BTN_SET_ARROW_ALIGN = 45
805BTN_GET_OVERLAY = 46
806BTN_SET_OVERLAY = 47
807BTN_GET_COLOR_LINE  = 48
808BTN_SET_COLOR_LINE  = 49
809BTN_GET_COLOR_LINE2 = 50
810BTN_SET_COLOR_LINE2 = 51
811
812BTNKIND_TEXT_ONLY      = 0
813BTNKIND_ICON_ONLY      = 1
814BTNKIND_TEXT_ICON_HORZ = 2
815BTNKIND_TEXT_ICON_VERT = 3
816BTNKIND_SEP_HORZ       = 4
817BTNKIND_SEP_VERT       = 5
818BTNKIND_TEXT_CHOICE    = 6
819
820ALIGN_NONE    = 0
821ALIGN_TOP     = 1
822ALIGN_BOTTOM  = 2
823ALIGN_LEFT    = 3
824ALIGN_RIGHT   = 4
825ALIGN_CLIENT  = 5
826
827DIM_ENUM       = 0
828DIM_ADD        = 1
829DIM_DELETE     = 3
830DIM_DELETE_ALL = 4
831
832VMODE_TEXT        = 0
833VMODE_BINARY      = 1
834VMODE_HEX         = 2
835VMODE_UNICODE     = 3
836VMODE_UNICODE_HEX = 4
837VMODE_NONE        = 10
838
839STATUSBAR_GET_COUNT            = 0
840STATUSBAR_DELETE_ALL           = 1
841STATUSBAR_DELETE_CELL          = 2
842STATUSBAR_ADD_CELL             = 3
843STATUSBAR_FIND_CELL            = 4
844STATUSBAR_SET_IMAGELIST        = 5
845STATUSBAR_GET_IMAGELIST        = 6
846STATUSBAR_SET_PADDING          = 7
847STATUSBAR_GET_PADDING          = 8
848STATUSBAR_SET_SEPARATOR        = 9
849STATUSBAR_GET_SEPARATOR        = 10
850STATUSBAR_SET_OVERFLOW_LEFT    = 11
851STATUSBAR_GET_OVERFLOW_LEFT    = 12
852
853STATUSBAR_SET_CELL_OVERLAY     = 14
854STATUSBAR_SET_CELL_COLOR_LINE  = 15
855STATUSBAR_SET_CELL_COLOR_LINE2 = 16
856STATUSBAR_SET_CELL_CALLBACK    = 17
857STATUSBAR_SET_CELL_FONT_NAME   = 18
858STATUSBAR_SET_CELL_FONT_SIZE   = 19
859STATUSBAR_SET_CELL_SIZE        = 20
860STATUSBAR_SET_CELL_ALIGN       = 21
861STATUSBAR_SET_CELL_TEXT        = 22
862STATUSBAR_SET_CELL_IMAGEINDEX  = 23
863STATUSBAR_SET_CELL_COLOR_FONT  = 24
864STATUSBAR_SET_CELL_COLOR_BACK  = 25
865STATUSBAR_SET_CELL_TAG         = 26
866STATUSBAR_SET_CELL_AUTOSIZE    = 27
867STATUSBAR_SET_CELL_AUTOSTRETCH = 28
868STATUSBAR_SET_CELL_HINT        = 29
869
870STATUSBAR_GET_CELL_SIZE        = 30
871STATUSBAR_GET_CELL_ALIGN       = 31
872STATUSBAR_GET_CELL_TEXT        = 32
873STATUSBAR_GET_CELL_IMAGEINDEX  = 33
874STATUSBAR_GET_CELL_COLOR_FONT  = 34
875STATUSBAR_GET_CELL_COLOR_BACK  = 35
876STATUSBAR_GET_CELL_TAG         = 36
877STATUSBAR_GET_CELL_AUTOSIZE    = 37
878STATUSBAR_GET_CELL_AUTOSTRETCH = 38
879STATUSBAR_GET_CELL_HINT        = 39
880STATUSBAR_GET_CELL_FONT_NAME   = 40
881STATUSBAR_GET_CELL_FONT_SIZE   = 41
882STATUSBAR_GET_CELL_CALLBACK    = 42
883STATUSBAR_GET_CELL_COLOR_LINE  = 43
884STATUSBAR_GET_CELL_COLOR_LINE2 = 44
885STATUSBAR_GET_CELL_OVERLAY     = 45
886STATUSBAR_GET_CELL_RECT        = 46
887
888STATUSBAR_SET_COLOR_BACK       = 50
889STATUSBAR_SET_COLOR_BORDER_BOTTOM = 51
890STATUSBAR_SET_COLOR_BORDER_TOP = 52
891STATUSBAR_SET_COLOR_BORDER_L   = 53
892STATUSBAR_SET_COLOR_BORDER_R   = 54
893STATUSBAR_SET_COLOR_BORDER_U   = 55
894STATUSBAR_SET_COLOR_BORDER_D   = 56
895
896STATUSBAR_GET_COLOR_BACK       = 60
897STATUSBAR_GET_COLOR_BORDER_BOTTOM = 61
898STATUSBAR_GET_COLOR_BORDER_TOP = 62
899STATUSBAR_GET_COLOR_BORDER_L   = 63
900STATUSBAR_GET_COLOR_BORDER_R   = 64
901STATUSBAR_GET_COLOR_BORDER_U   = 65
902STATUSBAR_GET_COLOR_BORDER_D   = 66
903
904HOTSPOT_GET_LIST      = 0
905HOTSPOT_ADD           = 1
906HOTSPOT_DELETE_ALL    = 2
907HOTSPOT_DELETE_LAST   = 3
908HOTSPOT_DELETE_BY_TAG = 4
909
910DBORDER_NONE     = 0
911DBORDER_SINGLE   = 1
912DBORDER_SIZE     = 2
913DBORDER_DIALOG   = 3
914DBORDER_TOOL     = 4
915DBORDER_TOOLSIZE = 5
916
917DECOR_GET_ALL          = 0
918DECOR_GET              = 1
919DECOR_SET              = 2
920DECOR_DELETE_BY_LINE   = 5
921DECOR_DELETE_BY_TAG    = 6
922DECOR_DELETE_ALL       = 7
923DECOR_GET_IMAGELIST    = 10
924
925INI_GET_SECTIONS     = 0
926INI_GET_KEYS         = 1
927INI_DELETE_KEY       = 2
928INI_DELETE_SECTION   = 3
929
930FINDER_CREATE           = 0
931FINDER_FREE             = 1
932FINDER_CLEAR            = 2
933FINDER_SET_FINDTEXT     = 4
934FINDER_GET_FINDTEXT     = 5
935FINDER_SET_REPTEXT      = 6
936FINDER_GET_REPTEXT      = 7
937FINDER_SET_ED           = 8
938FINDER_GET_ED           = 9
939FINDER_SET_OPT          = 10
940FINDER_GET_OPT          = 11
941FINDER_SET_MAXLEN       = 12
942FINDER_GET_MAXLEN       = 13
943FINDER_SET_CARETS       = 14
944FINDER_GET_CARETS       = 15
945FINDER_SET_INDENTS      = 16
946FINDER_GET_INDENTS      = 17
947FINDER_SET_TAG          = 18
948FINDER_GET_TAG          = 19
949FINDER_SET_ON_REPLACE   = 20
950FINDER_GET_ON_REPLACE   = 21
951FINDER_FIND             = 30
952FINDER_FIND_REP         = 31
953FINDER_FIND_ALL         = 32
954FINDER_COUNT            = 33
955FINDER_REP_ALL          = 38
956FINDER_REP_ALL_EX       = 39
957
958HOWREP_CANCEL  = 0
959HOWREP_REPLACE = 1
960HOWREP_SKIP    = 2
961
962HINTPOS_CARET         = 0
963HINTPOS_CARET_BRACKET = 1
964HINTPOS_TEXT          = 2
965HINTPOS_TEXT_BRACKET  = 3
966HINTPOS_WINDOW_TOP    = 8
967HINTPOS_WINDOW_BOTTOM = 9
968
969API, EXE_VER = ct.app_ver()
970
971def app_exe_version():
972    return EXE_VER
973
974def app_api_version():
975    return '1.0.'+str(API)
976
977def app_path(id):
978    return ct.app_path(id)
979
980def app_proc(id, val):
981    return ct.app_proc(id, to_str(val))
982
983def app_log(id, text, tag=0, panel=''):
984    if type(text) is not str:
985        raise ValueError('app_log() parameter "text" must be string')
986    if tag!=0:
987        print('ERROR: app_log() parameter "tag" has no effect, but %d is given'%tag)
988    return ct.app_log(id, text, tag, panel)
989
990def app_idle(wait=False):
991    return ct.app_idle(wait)
992
993def emmet(id, text, p1='', p2=''):
994    return ct.emmet(id, text, str(p1), str(p2))
995
996def msg_box(text, flags):
997    return ct.msg_box(text, flags)
998
999def msg_box_ex(caption, text, buttons, icon, focused=0):
1000    return ct.msg_box_ex(caption, text, chr(1).join(buttons), icon, focused)
1001
1002def msg_status(text, process_messages=False):
1003    return ct.msg_status(text, process_messages)
1004
1005def msg_status_alt(text, pause, pos=HINTPOS_CARET, x=0, y=0):
1006    return ct.msg_status_alt(text, pause, pos, x, y)
1007
1008def dlg_input(label, defvalue):
1009    return ct.dlg_input(label, defvalue)
1010
1011def dlg_color(value):
1012    return ct.dlg_color(value)
1013
1014def dlg_input_ex(number, caption,
1015                 label1   , text1='', label2='', text2='', label3='', text3='',
1016                 label4='', text4='', label5='', text5='', label6='', text6='',
1017                 label7='', text7='', label8='', text8='', label9='', text9='',
1018                 label10='', text10=''):
1019    return ct.dlg_input_ex(number, caption,
1020                 label1, text1, label2, text2, label3, text3,
1021                 label4, text4, label5, text5, label6, text6,
1022                 label7, text7, label8, text8, label9, text9,
1023                 label10, text10)
1024
1025def dlg_menu(id, items, focused=0, caption='', clip=0, w=0, h=0):
1026    if isinstance(items, str):
1027        s = items
1028    elif isinstance(items, (tuple, list)):
1029        s = '\n'.join(items)
1030    else:
1031        raise ValueError('Incorrect type in dlg_menu')
1032    return ct.dlg_menu(id, s, focused, caption, clip, w, h)
1033
1034def dlg_file(is_open, init_filename, init_dir, filters, caption=''):
1035    if not caption:
1036        caption = 'Open file' if is_open else 'Save file'
1037    return ct.dlg_file(is_open, init_filename, init_dir, filters, caption)
1038
1039def dlg_dir(init_dir, caption='Select folder'):
1040    return ct.dlg_dir(init_dir, caption)
1041
1042def dlg_hotkey(title=''):
1043    return ct.dlg_hotkey(title)
1044
1045def dlg_hotkeys(command, lexer=''):
1046    return ct.dlg_hotkeys(command, lexer)
1047
1048def dlg_commands(options, title='', w=0, h=0):
1049    return ct.dlg_commands(options, title, w, h)
1050
1051def _dlg_custom_dict(res, count):
1052    """Parse dlg_custom str result to dict"""
1053    clicked, vals = res
1054    vals = vals.splitlines()
1055    res = {}
1056    #res[i]
1057    for i in range(count):
1058        res[i] = vals[i]
1059    #res['clicked']
1060    res['clicked'] = clicked
1061    #res['focused']
1062    for i in range(count, len(vals)):
1063        s = vals[i].split('=', 1)
1064        s_key = s[0]
1065        s_val = s[1]
1066        if s_val.isdigit():
1067            s_val = int(s_val)
1068        res[s_key] = s_val
1069    return res
1070
1071def dlg_custom(title, size_x, size_y, text, focused=-1, get_dict=False):
1072    res = ct.dlg_custom(title, size_x, size_y, text, focused)
1073    if res is None:
1074        return
1075    if not get_dict:
1076        return res
1077    else:
1078        return _dlg_custom_dict(res, count=len(text.splitlines()) )
1079
1080def file_open(name, group=-1, options=''):
1081    if isinstance(name, (list, tuple)):
1082        return ct.file_open(name[0], name[1], group, options)
1083    else:
1084        return ct.file_open(name, '', group, options)
1085
1086def ed_handles():
1087    r0, r1 = ct.ed_handles()
1088    return range(r0, r1+1)
1089
1090def ed_group(n):
1091    h = ct.ed_group(n)
1092    if h:
1093        return Editor(h)
1094
1095def ini_read(filename, section, key, value):
1096    return ct.ini_read(filename, section, key, value)
1097
1098def ini_write(filename, section, key, value):
1099    return ct.ini_write(filename, section, key, value)
1100
1101def ini_proc(id, filename, section='', key=''):
1102    return ct.ini_proc(id, filename, section, key)
1103
1104def lexer_proc(id, value):
1105    return ct.lexer_proc(id, to_str(value))
1106
1107def imagelist_proc(id_list, id_action, value=''):
1108    return ct.imagelist_proc(id_list, id_action, to_str(value))
1109
1110def image_proc(id_image, id_action, value=''):
1111    return ct.image_proc(id_image, id_action, to_str(value))
1112
1113def tree_proc(id_tree, id_action, id_item=0, index=0, text='', image_index=-1, data=''):
1114    return ct.tree_proc(id_tree, id_action, id_item, index, to_str(text), image_index, data)
1115
1116def _menu_proc_callback_proxy(info=''):
1117    if info in _live:
1118        return _live[info]()
1119
1120def menu_proc(id_menu, id_action, command="", caption="", index=-1, hotkey="", tag=""):
1121    if callable(command):
1122        sid_callback = str(command)
1123        _live[sid_callback] = command
1124        command = 'module={};func=_menu_proc_callback_proxy;info="{}";'.format(__name__, sid_callback)
1125    return ct.menu_proc(str(id_menu), id_action, to_str(command), caption, index, hotkey, tag)
1126
1127def button_proc(id_button, id_action, value=''):
1128    if callable(value):
1129        sid_callback = str(value)
1130        _live[sid_callback] = value
1131        value = 'module={};func=_menu_proc_callback_proxy;info="{}";'.format(__name__, sid_callback)
1132    return ct.button_proc(id_button, id_action, to_str(value))
1133
1134def listbox_proc(id_listbox, id_action, index=0, text="", tag=0):
1135    return ct.listbox_proc(id_listbox, id_action, index, to_str(text), to_str(tag))
1136
1137def toolbar_proc(id_toolbar, id_action, text="", text2="", command=0, index=-1, index2=-1):
1138    if callable(command):
1139        sid_callback = str(command)
1140        _live[sid_callback] = command
1141        command = 'module={};func=_menu_proc_callback_proxy;info="{}";'.format(__name__, sid_callback)
1142    return ct.toolbar_proc(str(id_toolbar), id_action, text, text2, str(command), index, index2)
1143
1144def statusbar_proc(id_statusbar, id_action, index=-1, tag=0, value=""):
1145    return ct.statusbar_proc(str(id_statusbar), id_action, index, tag, to_str(value))
1146
1147def canvas_proc(id_canvas, id_action, text='', color=-1, size=-1, x=-1, y=-1, x2=-1, y2=-1, style=-1, p1=-1, p2=-1):
1148    return ct.canvas_proc(id_canvas, id_action, text, color, size, x, y, x2, y2, style, p1, p2)
1149
1150def _timer_proc_callback_proxy(tag='', info=''):
1151    if info in _live:
1152        return _live[info](tag)
1153
1154def timer_proc(id, callback, interval, tag=''):
1155    if callable(callback):
1156        sid_callback = str(callback)
1157        _live[sid_callback] = callback
1158        callback = 'module={};func=_timer_proc_callback_proxy;info="{}";'.format(__name__, sid_callback)
1159    return ct.timer_proc(id, callback, interval, tag)
1160
1161
1162def to_str(v, escape=False):
1163    def _pair(a, b):
1164        return to_str(a, True) + ':' + to_str(b, True)
1165
1166    if v is None:
1167        return ''
1168
1169    if isinstance(v, str):
1170        s = v
1171        if escape:
1172            s = s.replace(',', chr(2))
1173        return s
1174
1175    if isinstance(v, bool):
1176        return ('1' if v else '0')
1177
1178    if isinstance(v, (list, tuple)):
1179        l = [to_str(i, escape) for i in v]
1180        return ','.join(l)
1181
1182    def _o(k):
1183        #props must go first: *min* *max* p
1184        #props must go last: val
1185        if k in ('p', 'w_min', 'w_max', 'h_min', 'h_max'):
1186            return 0
1187        if k in ('val', 'columns'):
1188            return 2
1189        return 1
1190
1191    if isinstance(v, dict):
1192        res = chr(1).join(
1193            [_pair(k, vv) for k,vv in v.items() if _o(k)==0 ] +
1194            [_pair(k, vv) for k,vv in v.items() if _o(k)==1 ] +
1195            [_pair(k, vv) for k,vv in v.items() if _o(k)==2 ]
1196            )
1197        return '{'+res+'}'
1198
1199    return str(v)
1200
1201
1202def _dlg_proc_wait(id_dialog):
1203    while True:
1204        app_idle()
1205        from time import sleep
1206        sleep(0.03) # 30 msec seems ok for CPU load
1207
1208        d = ct.dlg_proc(id_dialog, DLG_PROP_GET, '', -1, -1, '')
1209        if isinstance(d, dict) and not d['vis']:
1210            return
1211
1212
1213def _dlg_proc_callback_proxy(id_dlg, id_ctl, data='', info=''):
1214    #print('dlg_proc_proxy: data:', data, ' info:', info)
1215    if info in _live:
1216        return _live[info](id_dlg, id_ctl, data=data)
1217
1218def _alter_live(id_dialog, prop, callback_name):
1219    callback_param = prop[callback_name]
1220    if callable(callback_param):
1221        sid_callback = '{}:{}'.format(id_dialog, callback_param)
1222        _live[sid_callback] = callback_param
1223        prop[callback_name] = 'module={};func=_dlg_proc_callback_proxy;info="{}";'.format(__name__, sid_callback)
1224
1225def dlg_proc(id_dialog, id_action, prop='', index=-1, index2=-1, name=''):
1226    #print('#dlg_proc id_action='+str(id_action)+' prop='+repr(prop))
1227
1228    #cleanup storage of live callbacks
1229    if id_action == DLG_FREE:
1230        for k in [k for k in _live if k.startswith(str(id_dialog)+':')]:
1231            _live.pop(k)
1232
1233    #support live callbacks by replacing them to str
1234    if isinstance(prop, dict):
1235        if 'resize' in prop and 'border' in prop:
1236            del prop['resize']
1237
1238        for k in prop:
1239            if k.startswith('on_'):
1240                _alter_live(id_dialog, prop, k)
1241
1242    res = ct.dlg_proc(id_dialog, id_action, to_str(prop), index, index2, name)
1243    if id_action == DLG_SHOW_MODAL:
1244        _dlg_proc_wait(id_dialog)
1245    return res
1246
1247def finder_proc(id_finder, id_action, value="", setcaret=True):
1248    return ct.finder_proc(id_finder, id_action, to_str(value), setcaret)
1249
1250def esc_z(s):
1251    # temp solution for null chars, later replace it to full solution with app patch
1252    if chr(0) in s:
1253        s = s.replace(chr(0), ' ')
1254    '''
1255    # by kvichans:
1256    s = s.replace('\\', r'\\') if '\\' in s else s
1257    s = s.replace(chr(0), r'\0') if chr(0) in s else s
1258    '''
1259    return s
1260
1261#Editor
1262class Editor:
1263    h = 0
1264    def __init__(self, handle):
1265        self.h = handle
1266
1267    def get_carets(self):
1268        return ct.ed_get_carets(self.h)
1269
1270    def set_caret(self, x1, y1, x2=-1, y2=-1, id=CARET_SET_ONE, options=0):
1271        return ct.ed_set_caret(self.h, x1, y1, x2, y2, id, options)
1272
1273    def get_line_count(self):
1274        return ct.ed_get_line_count(self.h)
1275
1276    def get_text_all(self):
1277        return ct.ed_get_text_all(self.h)
1278
1279    def set_text_all(self, text):
1280        return ct.ed_set_text_all(self.h, esc_z(text))
1281
1282    def get_text_sel(self):
1283        return ct.ed_get_text_sel(self.h)
1284
1285    def get_text_line(self, index, max_len=0):
1286        return ct.ed_get_text_line(self.h, index, max_len)
1287
1288    def set_text_line(self, index, text):
1289        return ct.ed_set_text_line(self.h, index, esc_z(text))
1290
1291    def get_text_substr(self, x1, y1, x2, y2):
1292        return ct.ed_get_text_substr(self.h, x1, y1, x2, y2)
1293
1294    def get_sel_mode(self):
1295        return ct.ed_get_sel_mode(self.h)
1296
1297    def get_sel_lines(self):
1298        return ct.ed_get_sel_lines(self.h)
1299
1300    def get_sel_rect(self):
1301        return ct.ed_get_sel_rect(self.h)
1302
1303    def set_sel_rect(self, x1, y1, x2, y2):
1304        return ct.ed_set_sel_rect(self.h, x1, y1, x2, y2)
1305
1306    def delete(self, x1, y1, x2, y2):
1307        return ct.ed_delete(self.h, x1, y1, x2, y2)
1308
1309    def insert(self, x1, y1, text):
1310        return ct.ed_insert(self.h, x1, y1, esc_z(text))
1311
1312    def replace(self, x1, y1, x2, y2, text):
1313        return ct.ed_replace(self.h, x1, y1, x2, y2, esc_z(text))
1314
1315    def replace_lines(self, y1, y2, lines):
1316        return ct.ed_replace_lines(self.h, y1, y2, [esc_z(l) for l in lines])
1317
1318    def get_filename(self, options=''):
1319        return ct.ed_get_filename(self.h, options)
1320
1321    def save(self, filename=''):
1322        return ct.ed_save(self.h, filename)
1323
1324    def cmd(self, code, text=''):
1325        return ct.ed_cmd(self.h, code, esc_z(text))
1326
1327    def focus(self):
1328        return ct.ed_focus(self.h)
1329
1330    def bookmark(self, id, nline, nkind=1, ncolor=-1, text='', auto_del=True, show=True, tag=0):
1331        return ct.ed_bookmark(self.h, id, nline, nkind, ncolor, text, auto_del, show, tag)
1332
1333    def decor(self, id, line=-1, tag=0, text='', color=0, bold=False, italic=False, image=-1, auto_del=True):
1334        return ct.ed_decor(self.h, id, line, tag, text, color, bold, italic, image, auto_del)
1335
1336    def lock(self):
1337        return ct.ed_lock(self.h)
1338
1339    def unlock(self):
1340        return ct.ed_unlock(self.h)
1341
1342    def get_prop(self, id, value=''):
1343        value = to_str(value)
1344        if id!=PROP_TAG:
1345            return ct.ed_get_prop(self.h, id, value)
1346        js_s = ct.ed_get_prop(self.h, PROP_TAG, '')
1347        key,dfv = value.split(':', 1) if ':' in value else ('_', value)
1348        if not js_s:
1349            return dfv
1350        import json
1351        js = json.loads(js_s)
1352        return js.get(key, dfv)
1353
1354    def set_prop(self, id, value):
1355        value = to_str(value)
1356        if id!=PROP_TAG:
1357            return ct.ed_set_prop(self.h, id, value)
1358        key,val = value.split(':', 1) if ':' in value else ('_', value)
1359        js_s = ct.ed_get_prop(self.h, PROP_TAG, '')
1360        js_s = js_s if js_s else '{}'
1361        import json
1362        js = json.loads(js_s)
1363        js[key] = val
1364        js_s = json.dumps(js)
1365        return ct.ed_set_prop(self.h, PROP_TAG, js_s)
1366
1367    def complete(self, text, len1, len2, selected=0, alt_order=False):
1368        return ct.ed_complete(self.h, text, len1, len2, selected, alt_order)
1369
1370    def complete_alt(self, text, snippet_id, len_chars, selected=0):
1371        return ct.ed_complete_alt(self.h, text, snippet_id, len_chars, selected)
1372
1373    def convert(self, id, x, y, text=''):
1374        return ct.ed_convert(self.h, id, x, y, esc_z(text))
1375
1376    def get_ranges(self):
1377        return ct.ed_get_ranges(self.h)
1378
1379    def get_sublexer_ranges(self):
1380        res = ct.ed_get_sublexer_ranges(self.h)
1381        if res is None: return
1382        #split string to items
1383        #note: EControl gives duplicated ranges, cannot find reason, del them here
1384        res = res.rstrip(';').split(';')
1385        res = [ r.split(',') for (index, r) in enumerate(res) if (index==0) or (res[index]!=res[index-1]) ]
1386        res = [ (r[4], int(r[0]), int(r[1]), int(r[2]), int(r[3])) for r in res ]
1387        return res
1388
1389    def markers(self, id, x=0, y=0, tag=0, len_x=0, len_y=0, line_len=0):
1390        return ct.ed_markers(self.h, id, x, y, tag, len_x, len_y, line_len)
1391
1392    def attr(self, id, tag=0, x=0, y=0, len=1,
1393             color_font=COLOR_NONE, color_bg=COLOR_NONE, color_border=COLOR_NONE,
1394             font_bold=0, font_italic=0, font_strikeout=0,
1395             border_left=0, border_right=0, border_down=0, border_up=0,
1396             show_on_map=False, map_only=0
1397             ):
1398
1399        if id==MARKERS_ADD_MANY:
1400            if not isinstance(x, int):
1401                x = ','.join(map(str, x))
1402                y = ','.join(map(str, y))
1403                len = ','.join(map(str, len))
1404        else:
1405            x = str(x)
1406            y = str(y)
1407            len = str(len)
1408
1409        column = 1 if show_on_map is True else -1 if show_on_map==False else show_on_map
1410
1411        return ct.ed_attr(self.h, id, tag,
1412                          x, y, len,
1413                          color_font, color_bg, color_border,
1414                          font_bold, font_italic, font_strikeout,
1415                          border_left, border_right, border_down, border_up,
1416                          column, map_only
1417                          )
1418
1419    def dim(self, id, index=0, index2=0, value=100):
1420        return ct.ed_dim(self.h, id, index, index2, value)
1421
1422    def hotspots(self, id, tag=0, tag_str="", pos=""):
1423        return ct.ed_hotspots(self.h, id, tag, tag_str, to_str(pos))
1424
1425    def get_token(self, id, index1=0, index2=0):
1426        return ct.ed_get_token(self.h, id, index1, index2)
1427
1428    def gap(self, id, num1, num2, tag=-1, size=0, color=COLOR_NONE):
1429        return ct.ed_gap(self.h, id, num1, num2, tag, size, color)
1430
1431    def folding(self, id, index=-1, item_x=-1, item_y=-1, item_y2=-1, item_staple=False, item_hint=''):
1432        return ct.ed_folding(self.h, id, index, item_x, item_y, item_y2, item_staple, item_hint)
1433
1434    def get_wrapinfo(self, param1=-1, param2=-1):
1435        return ct.ed_get_wrapinfo(self.h, param1, param2)
1436
1437    def action(self, id, param1='', param2='', param3=''):
1438        return ct.ed_action(self.h, id, to_str(param1), to_str(param2), to_str(param3))
1439
1440    def micromap(self, id, param1=0, param2=0, param3=0):
1441        return ct.ed_micromap(self.h, id, param1, param2, param3)
1442
1443    def __str__(self):
1444        return '<Editor h:{} id:{} title:"{}" gr:{} tab:{}>'.format(
1445            self.h,
1446            self.get_prop(PROP_TAB_ID),
1447            self.get_prop(PROP_TAB_TITLE),
1448            self.get_prop(PROP_INDEX_GROUP),
1449            self.get_prop(PROP_INDEX_TAB)
1450            )
1451
1452    def __repr__(self):
1453        return self.__str__()
1454
1455    def __eq__(self, other):
1456        return other and type(other) is Editor and self.get_prop(PROP_HANDLE_SELF) == other.get_prop(PROP_HANDLE_SELF)
1457    #end
1458
1459#objects
1460ed = Editor(0)
1461
1462#support input() in plugins
1463def _input(s):
1464    return dlg_input(s, '') or ''
1465
1466import builtins
1467builtins.input = _input
1468