-
Notifications
You must be signed in to change notification settings - Fork 383
/
Copy path__init__.py
499 lines (474 loc) · 12.7 KB
/
__init__.py
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
# -*- coding: utf-8 -*-
# Copyright 2008-2015 Nokia Networks
# Copyright 2016- Robot Framework Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import builtins
import os
import sys
import wx
from . import logger
from ..robotapi import ROBOT_LOGGER
from ..version import VERSION
_ = wx.GetTranslation # To keep linter/code analyser happy
builtins.__dict__['_'] = wx.GetTranslation
APP = None
LOG = logger.Logger()
ROBOT_LOGGER.unregister_console_logger()
ROBOT_LOGGER.register_logger(LOG)
IS_WINDOWS = os.sep == '\\'
IS_MAC = sys.platform == 'darwin'
IS_LINUX = sys.platform == 'linux'
WX_VERSION = wx.VERSION_STRING
IS_WX_410_OR_HIGHER = WX_VERSION >= '4.1.0'
EXECUTABLE = sys.executable
if IS_WINDOWS:
SETTINGS_DIRECTORY = os.path.join(
os.environ['APPDATA'], 'RobotFramework', 'ride')
else:
SETTINGS_DIRECTORY = os.path.join(
os.path.expanduser('~/.robotframework'), 'ride')
LIBRARY_XML_DIRECTORY = os.path.join(SETTINGS_DIRECTORY, 'library_xmls')
if not os.path.isdir(LIBRARY_XML_DIRECTORY):
os.makedirs(LIBRARY_XML_DIRECTORY)
SETTING_EDITOR_WIDTH = 450
SETTING_LABEL_WIDTH = 150
SETTING_ROW_HEIGHT = 40
# DEBUG: Make this colour configurable
POPUP_BACKGROUND = (240, 242, 80) # (255, 255, 187)
POPUP_FOREGROUND = (40, 40, 0) # (255, 255, 187)
pyversion = '.'.join(str(v) for v in sys.version_info[:3])
SYSTEM_INFO = _("Started RIDE %s using python version %s with wx version %s in %s.") % \
(VERSION, pyversion, WX_VERSION, sys.platform)
def get_about_ride():
rf = '<a href="https://robotframework.org/">Robot Framework</a>'
ghrf = '<a href="https://github.com/robotframework/RIDE">https://github.com/robotframework/RIDE</a>'
si = '<a href="https://github.com/legacy-icons/famfamfam-silk/">Silk Icons</a>'
# Note: <!-- Originally from http://www.famfamfam.com/lab/icons/silk/ 404 in 10-june-2023-->
mt = '<a href="https://github.com/HelioGuilherme66">Hélio Guilherme</a>'
foundation = '<a href="https://robotframework.org/foundation/">Robot Framework Foundation</a>'
from ..localization.tr_credits import tr_credits
tr = tr_credits()
translators = _("Thanks all RIDE translators: %s") % tr
rfecosys = '<b>Robot Framework Ecosystem Projects 2023</b>'
heading = _("RIDE -- Robot Framework Test Data Editor")
content = []
content += [_("RIDE %s running on Python %s.") % (VERSION, pyversion)]
content += ["<br/>" + _("RIDE is a test data editor for %s.") % rf]
content += [_("For more information, see project pages at %s.") % ghrf]
content += ["<br/>" + _("Some of the icons are from %s.") % si]
maintainer = _("%s the maintainer of the project thanks the original authors and all users and collaborators.") % mt
special = _("A special thanks to %s for having sponsored the development of translated test suites content "
"compatibility with %s Version 6.1, in their %s.") % (foundation, rf, rfecosys)
build_about = []
build_about += [f"<h3>{heading}</h3>"]
build_about += [f"{line}<br/>" for line in content]
build_about += [f"<p><br/>{maintainer}<br/></p>"]
build_about += [f"<p>{special}</p>"]
build_about += [f"<br/><div>{translators}</div>"]
return "".join(build_about)
"""
ABOUT_RIDE = '''<h3>RIDE -- Robot Framework Test Data Editor</h3>
<p>RIDE %s running on Python %s.</p>
<p>RIDE is a test data editor for <a href="https://robotframework.org/">Robot Framework</a>.
For more information, see project pages at
<a href="https://github.com/robotframework/RIDE">https://github.com/robotframework/RIDE</a>.</p>
<p>Some of the icons are from <a href="https://github.com/legacy-icons/famfamfam-silk/">Silk Icons</a>.</p>
<!-- Originally from http://www.famfamfam.com/lab/icons/silk/ 404 in 10-june-2023-->
<p><br/><br/><a href="https://github.com/HelioGuilherme66">Hélio Guilherme</a> the maintainer of the project thanks the
original authors and all users and collaborators.<br/>
<!--
A very special thanks to <b><a href="https://github.com/Nyral">Nyral</a></b> and <b><a href="https://github.com/jnhyperi
on">Johnny.H</a></b> the most commited in helping RIDE development and maintenance.
--></p>
''' % (VERSION, pyversion)
"""
def ctrl_or_cmd():
if IS_MAC:
return wx.ACCEL_CMD
return wx.ACCEL_CTRL
def bind_keys_to_evt_menu(target, actions):
accelrators = []
for accel, keycode, handler in actions:
_id = wx.NewIdRef()
target.Bind(wx.EVT_MENU, handler, id=_id)
accelrators.append((accel, keycode, _id))
target.SetAcceleratorTable(wx.AcceleratorTable(accelrators))
SHORTCUT_KEYS = '''<h2>Shortcut keys in RIDE</h2>
<table>
<tr align="left">
<th><b>Shortcut</b></th>
<th><b>What it does</b></th>
</tr>
<tr>
<td>CtrlCmd-S</td>
<td>Save</td>
</tr>
<tr>
<td>CtrlCmd-Shift-S</td>
<td>Save all</td>
</tr>
<tr>
<td>CtrlCmd-O</td>
<td>Open</td>
</tr>
<tr>
<td>CtrlCmd-Shift-O</td>
<td>Open directory</td>
</tr>
<tr>
<td>CtrlCmd-R</td>
<td>Open resource</td>
</tr>
<tr>
<td>CtrlCmd-Shift-R</td>
<td>Refresh directory</td>
</tr>
<tr>
<td>CtrlCmd-N</td>
<td>New project</td>
</tr>
<tr>
<td>CtrlCmd-Shift-N</td>
<td>New resource</td>
</tr>
<tr>
<td>CtrlCmd-Q</td>
<td>Quit RIDE</td>
</tr>
<tr>
<td>Alt-X</td>
<td>Go Forward</td>
</tr>
<tr>
<td>Alt-Z</td>
<td>Go Back</td>
</tr>
<tr>
<td>F6</td>
<td>Open preview</td>
</tr>
<tr>
<td>F5</td>
<td>Open search keywords dialog</td>
</tr>
<tr>
<td>F3</td>
<td>Open search tests dialog</td>
</tr>
<tr>
<td>F8</td>
<td>Run test suite</td>
</tr>
<tr>
<td>CtrlCmd-F8</td>
<td>Stop running test suite</td>
</tr>
</table>
<h3>Grid</h3>
<table>
<tr align="left">
<th><b>Shortcut</b></th>
<th><b>What it does</b></th>
</tr>
<tr>
<td>Ctrl-Space or Alt-Space</td>
<td>Suggestions and auto completion</td>
</tr>
<tr>
<td>CtrlCmd</td>
<td>Help for cell content</td>
</tr>
<tr>
<td>CtrlCmd-Shift-J</td>
<td>Pop-up JSON Editor</td>
</tr>
<tr>
<td>CtrlCmd-B</td>
<td>Go to Definition</td>
</tr>
<tr>
<td>CtrlCmd-Z</td>
<td>Undo</td>
</tr>
<tr>
<td>CtrlCmd-Y</td>
<td>Redo</td>
</tr>
<tr>
<td>CtrlCmd-1</td>
<td>Make scalar variable body</td>
</tr>
<tr>
<td>CtrlCmd-2</td>
<td>Make list variable body</td>
</tr>
<tr>
<td>CtrlCmd-5</td>
<td>Make dictionary variable body</td>
</tr>
<tr>
<td>CtrlCmd-Shift-3</td>
<td>Comment content with #</td>
</tr>
<tr>
<td>CtrlCmd-Shift-4</td>
<td>Uncomment content from #</td>
</tr>
<tr>
<td>Alt-Enter</td>
<td>Move cursor down</td>
</tr>
<tr>
<td>CtrlCmd-3</td>
<td>Comment row(s)</td>
</tr>
<tr>
<td>CtrlCmd-4</td>
<td>Uncomment row(s)</td>
</tr>
<tr>
<td>Alt-Up</td>
<td>Move row(s) up</td>
</tr>
<tr>
<td>Alt-Down</td>
<td>Move row(s) down</td>
</tr>
<tr>
<td>CtrlCmd-T</td>
<td>Swap row up</td>
</tr>
<tr>
<td>CtrlCmd-Shift-I</td>
<td>Insert cell(s)</td>
</tr>
<tr>
<td>CtrlCmd-Shift-D</td>
<td>Delete cell(s)</td>
</tr>
<tr>
<td>CtrlCmd-I</td>
<td>Insert row(s)</td>
</tr>
<tr>
<td>CtrlCmd-D</td>
<td>Delete row(s)</td>
</tr>
<tr>
<td>CtrlCmd-A</td>
<td>Select all</td>
</tr>
<tr>
<td>CtrlCmd-X</td>
<td>Cut (does not remove cells or rows)</td>
</tr>
<tr>
<td>CtrlCmd-C</td>
<td>Copy</td>
</tr>
<tr>
<td>CtrlCmd-V</td>
<td>Paste (does not move cells or rows)</td>
</tr>
<tr>
<td>CtrlCmd-Shift-V</td>
<td>Insert (adds empty rows and pastes data)</td>
</tr>
<tr>
<td>Del</td>
<td>Remove cell content</td>
</tr>
<tr>
<td>Ctrl-MouseWheel Roll</td>
<td>Increases or Decreases font size (Zoom +/-)</td>
</tr>
</table>
<h3>Tree view</h3>
<table>
<tr align="left">
<th><b>Shortcut</b></th>
<th><b>What it does</b></th>
</tr>
<tr>
<td>CtrlCmd-Shift-T</td>
<td>Add new test case</td>
</tr>
<tr>
<td>CtrlCmd-Shift-K</td>
<td>Add new keyword</td>
</tr>
<tr>
<td>CtrlCmd-Shift-V</td>
<td>Add new scalar variable</td>
</tr>
<tr>
<td>CtrlCmd-Shift-L</td>
<td>Add new list variable</td>
</tr>
<tr>
<td>F2</td>
<td>Rename</td>
</tr>
<tr>
<td>CtrlCmd-Shift-C</td>
<td>Clone/Copy selected keyword/test case</td>
</tr>
<tr>
<td>CtrlCmd-Up</td>
<td>Move item up</td>
</tr>
<tr>
<td>CtrlCmd-Down</td>
<td>Move item down</td>
</tr>
</table>
<h3>Text editor</h3>
<table>
<tr align="left">
<th><b>Shortcut</b></th>
<th><b>What it does</b></th>
</tr>
<tr>
<td>Ctrl-Space or Alt-Space</td>
<td>Suggestions and auto completion</td>
</tr>
<tr>
<td>CtrlCmd</td>
<td>Help for content at cursor or selected autocomplete list item</td>
</tr>
<tr>
<td>CtrlCmd-T</td>
<td>Swap current row up</td>
</tr>
<tr>
<td>Tab</td>
<td>Inserts the defined number of spaces</td>
</tr>
<tr>
<td>Shift-Tab</td>
<td>Moves cursor to the left the defined number of spaces</td>
</tr>
<tr>
<td>Ctrl-MouseWheel Roll</td>
<td>Increases or Decreases font size (Zoom +/-)</td>
</tr>
<tr>
<td>CtrlCmd-F</td>
<td>Find in text</td>
</tr>
<tr>
<td>CtrlCmd-G</td>
<td>Find next search result</td>
</tr>
<tr>
<td>CtrlCmd-Shift-G</td>
<td>Find previous search result</td>
</tr>
<tr>
<td>CtrlCmd-Z</td>
<td>Undo</td>
</tr>
<tr>
<td>CtrlCmd-Y</td>
<td>Redo</td>
</tr>
<tr>
<td>CtrlCmd-1</td>
<td>Make scalar variable body</td>
</tr>
<tr>
<td>CtrlCmd-2</td>
<td>Make list variable body</td>
</tr>
<tr>
<td>CtrlCmd-5</td>
<td>Make dictionary variable body</td>
</tr>
<tr>
<td>Alt-Up</td>
<td>Move row(s) up</td>
</tr>
<tr>
<td>Alt-Down</td>
<td>Move row(s) down</td>
</tr>
<tr>
<td>CtrlCmd-D</td>
<td>Delete row(s)</td>
</tr>
<tr>
<td>CtrlCmd-I</td>
<td>Insert row(s)</td>
</tr>
<tr>
<td>CtrlCmd-3</td>
<td>Comment row(s)</td>
</tr>
<tr>
<td>CtrlCmd-Shift-3</td>
<td>Comment content with #</td>
</tr>
<tr>
<td>CtrlCmd-4</td>
<td>Uncomment row(s)</td>
</tr>
<tr>
<td>CtrlCmd-Shift-4</td>
<td>Uncomment content with #</td>
</tr>
<tr>
<td>CtrlCmd-Shift-I</td>
<td>Insert cell(s)</td>
</tr>
<tr>
<td>CtrlCmd-Shift-D</td>
<td>Delete cell(s)</td>
</tr>
<tr>
<td>CtrlCmd-Shift Click on Folding marker</td>
<td>Expands or Collapses all Folding markers</td>
</tr>
<tr>
<td>Enter</td>
<td>When focus is in the search field, find next search result</td>
</tr>
<tr>
<td>Shift-Enter</td>
<td>When focus is in the search field, find previous search result</td>
</tr>
</table>
<h3>Run tab</h3>
<table>
<tr align="left">
<th><b>Shortcut</b></th>
<th><b>What it does</b></th>
</tr>
<tr>
<td>CtrlCmd-C</td>
<td>Copy from text output when text selected</td>
</tr>
<tr>
<td>CtrlCmd-L</td>
<td>Open HTML log</td>
</tr>
<tr>
<td>CtrlCmd-R</td>
<td>Show HTML report</td>
</tr>
<tr>
<td>Ctrl-MouseWheel Roll</td>
<td>Increases or Decreases font size (Zoom +/-)</td>
</tr>
</table>
'''