suplemon-editor 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. suplemon/__init__.py +0 -0
  2. suplemon/__main__.py +3 -0
  3. suplemon/cli.py +65 -0
  4. suplemon/config/defaults.json +153 -0
  5. suplemon/config/keymap.json +63 -0
  6. suplemon/config.py +324 -0
  7. suplemon/cursor.py +135 -0
  8. suplemon/editor.py +568 -0
  9. suplemon/file.py +193 -0
  10. suplemon/help.py +327 -0
  11. suplemon/helpers.py +104 -0
  12. suplemon/hex2xterm.py +23 -0
  13. suplemon/key_mappings.py +239 -0
  14. suplemon/lexer.py +88 -0
  15. suplemon/line.py +51 -0
  16. suplemon/linelight/__init__.py +0 -0
  17. suplemon/linelight/color_map.py +9 -0
  18. suplemon/linelight/css.py +21 -0
  19. suplemon/linelight/diff.py +17 -0
  20. suplemon/linelight/html.py +19 -0
  21. suplemon/linelight/js.py +21 -0
  22. suplemon/linelight/json.py +15 -0
  23. suplemon/linelight/lua.py +10 -0
  24. suplemon/linelight/md.py +19 -0
  25. suplemon/linelight/php.py +27 -0
  26. suplemon/linelight/py.py +27 -0
  27. suplemon/logger.py +90 -0
  28. suplemon/main.py +771 -0
  29. suplemon/module_loader.py +98 -0
  30. suplemon/modules/application_state.py +84 -0
  31. suplemon/modules/autocomplete.py +114 -0
  32. suplemon/modules/autodocstring.py +142 -0
  33. suplemon/modules/battery.py +118 -0
  34. suplemon/modules/bulk_delete.py +75 -0
  35. suplemon/modules/clock.py +22 -0
  36. suplemon/modules/comment.py +59 -0
  37. suplemon/modules/config.py +20 -0
  38. suplemon/modules/date.py +22 -0
  39. suplemon/modules/diff.py +42 -0
  40. suplemon/modules/eval.py +43 -0
  41. suplemon/modules/hostname.py +34 -0
  42. suplemon/modules/input_test.py +23 -0
  43. suplemon/modules/keymap.py +20 -0
  44. suplemon/modules/linter.py +274 -0
  45. suplemon/modules/lower.py +21 -0
  46. suplemon/modules/lstrip.py +20 -0
  47. suplemon/modules/paste.py +49 -0
  48. suplemon/modules/reload.py +16 -0
  49. suplemon/modules/replace_all.py +23 -0
  50. suplemon/modules/reverse.py +22 -0
  51. suplemon/modules/rstrip.py +19 -0
  52. suplemon/modules/save.py +16 -0
  53. suplemon/modules/save_all.py +19 -0
  54. suplemon/modules/sort_lines.py +41 -0
  55. suplemon/modules/strip.py +19 -0
  56. suplemon/modules/system_clipboard.py +121 -0
  57. suplemon/modules/tabstospaces.py +18 -0
  58. suplemon/modules/toggle_whitespace.py +18 -0
  59. suplemon/modules/upper.py +21 -0
  60. suplemon/prompt.py +319 -0
  61. suplemon/suplemon_module.py +210 -0
  62. suplemon/themes/8colors.tmTheme +179 -0
  63. suplemon/themes/monokai.tmTheme +284 -0
  64. suplemon/themes.py +201 -0
  65. suplemon/ui.py +656 -0
  66. suplemon/viewer.py +1004 -0
  67. suplemon_editor-0.3.0.dist-info/METADATA +515 -0
  68. suplemon_editor-0.3.0.dist-info/RECORD +72 -0
  69. suplemon_editor-0.3.0.dist-info/WHEEL +5 -0
  70. suplemon_editor-0.3.0.dist-info/entry_points.txt +3 -0
  71. suplemon_editor-0.3.0.dist-info/licenses/LICENSE +21 -0
  72. suplemon_editor-0.3.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,210 @@
1
+ # -*- encoding: utf-8
2
+ """
3
+ Base class for extension modules to inherit.
4
+ """
5
+
6
+ import os
7
+ import json
8
+ import logging
9
+
10
+
11
+ class Storage:
12
+ """
13
+ Semi-automatic key/value store for suplemon modules.
14
+ """
15
+ def __init__(self, module):
16
+ self.data = {}
17
+ self.automatic = False
18
+ self.module = module
19
+ self.data_subdir = "modules"
20
+ self.extension = "json"
21
+ self.storage_dir = os.path.join(self.module.app.config.config_dir, self.data_subdir)
22
+ if not os.path.exists(self.storage_dir):
23
+ try:
24
+ os.makedirs(self.storage_dir)
25
+ except OSError:
26
+ self.module.app.logger.warning(
27
+ "Module storage folder '{0}' doesn't exist and couldn't be created.".format(
28
+ self.storage_dir))
29
+
30
+ def __getitem__(self, i):
31
+ """Get a storage key value."""
32
+ return self.data[i]
33
+
34
+ def __setitem__(self, i, v):
35
+ """Set a storage key value."""
36
+ self.data[i] = v
37
+ if self.automatic:
38
+ self.store()
39
+
40
+ def __str__(self):
41
+ """Convert entire data dict to string."""
42
+ return str(self.data)
43
+
44
+ def __len__(self):
45
+ """Return length of data dict."""
46
+ return len(self.data)
47
+
48
+ def keys(self):
49
+ return self.data.keys()
50
+
51
+ def items(self):
52
+ return self.data.items()
53
+
54
+ def get_path(self):
55
+ """Get the storage file path."""
56
+ if self.module.get_name():
57
+ return os.path.join(self.storage_dir, self.module.get_name() + "." + self.extension)
58
+ return False
59
+
60
+ def get_data(self):
61
+ """Get the storage data."""
62
+ return self.data
63
+
64
+ def set_data(self, data):
65
+ """Set the storage data."""
66
+ self.data = data
67
+
68
+ def set_automatic(self, auto):
69
+ """Set wether the data should be stored automatically when changed."""
70
+ self.automatic = auto
71
+
72
+ def store(self):
73
+ """Store the storage data to disk."""
74
+ try:
75
+ data = json.dumps(self.data)
76
+ f = open(self.get_path(), "w")
77
+ f.write(data)
78
+ f.close()
79
+ except (OSError, TypeError, ValueError):
80
+ self.module.logger.exception("Storing module storage failed.")
81
+
82
+ def load(self):
83
+ """Load the storage data from disk."""
84
+ if os.path.exists(self.get_path()):
85
+ try:
86
+ f = open(self.get_path())
87
+ data = f.read()
88
+ f.close()
89
+ except OSError:
90
+ self.module.logger.debug("Loading module storage failed.")
91
+ return False
92
+ else:
93
+ return False
94
+
95
+ try:
96
+ self.data = json.loads(data)
97
+ return True
98
+ except ValueError:
99
+ self.module.logger.exception("Parsing module storage failed.")
100
+ return False
101
+
102
+
103
+ class Module:
104
+ def __init__(self, app, name, options=None):
105
+ self.app = app
106
+ self.name = name
107
+ self.options = options
108
+ self.logger = None
109
+ self.storage = Storage(self)
110
+ self.init_logging(self.get_name())
111
+ self.storage.load()
112
+ self.init()
113
+
114
+ def init(self):
115
+ """Initialize the module.
116
+
117
+ This function is run when the module is loaded and can be
118
+ reimplemented for module specific initializations.
119
+ """
120
+
121
+ def get_name(self):
122
+ """Get module name."""
123
+ return self.name
124
+
125
+ def get_options(self):
126
+ """Get module options."""
127
+ return self.options
128
+
129
+ def get_status(self):
130
+ """Called by app when to get status bar contents."""
131
+ return ""
132
+
133
+ def set_name(self, name):
134
+ """Set module name."""
135
+ self.name = name
136
+
137
+ def set_options(self, options):
138
+ """Set module options."""
139
+ self.options = options
140
+
141
+ def get_default_config(self):
142
+ """Return module default config dict"""
143
+ return {}
144
+
145
+ def is_runnable(self):
146
+ cls_method = getattr(Module, "run")
147
+ return self.run.__module__ != cls_method.__module__
148
+
149
+ def init_logging(self, name):
150
+ """Initialize the module logger (self.logger).
151
+
152
+ Should be called before the module uses logging.
153
+ Always pass __name__ as the value to name, for consistency.
154
+
155
+ Args:
156
+ :param name: should be specified as __name__
157
+ """
158
+ if not self.logger:
159
+ self.logger = logging.getLogger("module.{0}".format(name))
160
+
161
+ def run(self, app, editor, args):
162
+ """This is called each time the module is run.
163
+
164
+ Called when command is issued via prompt or key binding.
165
+
166
+ Args:
167
+ :param app: the app instance
168
+ :param editor: the current editor instance
169
+ """
170
+ pass
171
+
172
+ def bind_key(self, key):
173
+ """Shortcut for binding run method to a key.
174
+
175
+ Args:
176
+ :param key:
177
+ """
178
+ self.app.set_key_binding(key, self._proxy_run)
179
+
180
+ def bind_event(self, event, callback):
181
+ """Bind a callback to be called before event is run.
182
+
183
+ If the callback returns True the event will be canceled.
184
+
185
+ :param event: The event name
186
+ :param callback: Function to be called
187
+ """
188
+ self.app.set_event_binding(event, "before", callback)
189
+
190
+ def bind_event_before(self, event, callback):
191
+ """Bind a callback to be called before event is run.
192
+
193
+ If the callback returns True the event will be canceled.
194
+
195
+ :param event: The event name
196
+ :param callback: Function to be called
197
+ """
198
+ self.app.set_event_binding(event, "before", callback)
199
+
200
+ def bind_event_after(self, event, callback):
201
+ """Bind a callback to be called after event is run.
202
+
203
+ :param event: The event name
204
+ :param callback: Function to be called
205
+ """
206
+ self.app.set_event_binding(event, "after", callback)
207
+
208
+ def _proxy_run(self):
209
+ """Calls the run method with necessary arguments."""
210
+ self.run(self.app, self.app.get_editor(), "")
@@ -0,0 +1,179 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <plist version="1.0">
3
+ <dict>
4
+ <key>name</key>
5
+ <string>Monokai</string>
6
+ <key>settings</key>
7
+ <array>
8
+ <dict>
9
+ <key>settings</key>
10
+ <dict>
11
+ <key>caret</key>
12
+ <string>7</string>
13
+ <key>foreground</key>
14
+ <string>7</string>
15
+ </dict>
16
+ </dict>
17
+ <dict>
18
+ <key>name</key>
19
+ <string>Comment</string>
20
+ <key>scope</key>
21
+ <string>comment</string>
22
+ <key>settings</key>
23
+ <dict>
24
+ <key>foreground</key>
25
+ <string>5</string>
26
+ </dict>
27
+ </dict>
28
+ <dict>
29
+ <key>name</key>
30
+ <string>String</string>
31
+ <key>scope</key>
32
+ <string>string</string>
33
+ <key>settings</key>
34
+ <dict>
35
+ <key>foreground</key>
36
+ <string>3</string>
37
+ </dict>
38
+ </dict>
39
+ <dict>
40
+ <key>name</key>
41
+ <string>Number</string>
42
+ <key>scope</key>
43
+ <string>constant.numeric</string>
44
+ <key>settings</key>
45
+ <dict>
46
+ <key>foreground</key>
47
+ <string>7</string>
48
+ </dict>
49
+ </dict>
50
+
51
+ <dict>
52
+ <key>name</key>
53
+ <string>Built-in constant</string>
54
+ <key>scope</key>
55
+ <string>constant.language</string>
56
+ <key>settings</key>
57
+ <dict>
58
+ <key>foreground</key>
59
+ <string>6</string>
60
+ </dict>
61
+ </dict>
62
+ <dict>
63
+ <key>name</key>
64
+ <string>User-defined constant</string>
65
+ <key>scope</key>
66
+ <string>constant.character, constant.other</string>
67
+ <key>settings</key>
68
+ <dict>
69
+ <key>foreground</key>
70
+ <string>7</string>
71
+ </dict>
72
+ </dict>
73
+ <dict>
74
+ <key>name</key>
75
+ <string>Variable</string>
76
+ <key>scope</key>
77
+ <string>variable</string>
78
+ <key>settings</key>
79
+ <dict>
80
+ <key>foreground</key>
81
+ <string>7</string>
82
+ <key>fontStyle</key>
83
+ <string></string>
84
+ </dict>
85
+ </dict>
86
+ <dict>
87
+ <key>name</key>
88
+ <string>Keyword</string>
89
+ <key>scope</key>
90
+ <string>keyword</string>
91
+ <key>settings</key>
92
+ <dict>
93
+ <key>foreground</key>
94
+ <string>3</string>
95
+ </dict>
96
+ </dict>
97
+ <dict>
98
+ <key>name</key>
99
+ <string>Storage</string>
100
+ <key>scope</key>
101
+ <string>storage</string>
102
+ <key>settings</key>
103
+ <dict>
104
+ <key>fontStyle</key>
105
+ <string></string>
106
+ <key>foreground</key>
107
+ <string>7</string>
108
+ </dict>
109
+ </dict>
110
+ <dict>
111
+ <key>name</key>
112
+ <string>Storage type</string>
113
+ <key>scope</key>
114
+ <string>storage.type</string>
115
+ <key>settings</key>
116
+ <dict>
117
+ <key>fontStyle</key>
118
+ <string>italic</string>
119
+ <key>foreground</key>
120
+ <string>7</string>
121
+ </dict>
122
+ </dict>
123
+ <dict>
124
+ <key>name</key>
125
+ <string>Class name</string>
126
+ <key>scope</key>
127
+ <string>entity.name.class</string>
128
+ <key>settings</key>
129
+ <dict>
130
+ <key>fontStyle</key>
131
+ <string>italic</string>
132
+ <key>foreground</key>
133
+ <string>2</string>
134
+ </dict>
135
+ </dict>
136
+ <dict>
137
+ <key>name</key>
138
+ <string>Inherited class</string>
139
+ <key>scope</key>
140
+ <string>entity.other.inherited-class</string>
141
+ <key>settings</key>
142
+ <dict>
143
+ <key>fontStyle</key>
144
+ <string>italic underline</string>
145
+ <key>foreground</key>
146
+ <string>2</string>
147
+ </dict>
148
+ </dict>
149
+ <dict>
150
+ <key>name</key>
151
+ <string>Function name</string>
152
+ <key>scope</key>
153
+ <string>entity.name.function</string>
154
+ <key>settings</key>
155
+ <dict>
156
+ <key>fontStyle</key>
157
+ <string>italic</string>
158
+ <key>foreground</key>
159
+ <string>6</string>
160
+ </dict>
161
+ </dict>
162
+ <dict>
163
+ <key>name</key>
164
+ <string>Function argument</string>
165
+ <key>scope</key>
166
+ <string>variable.parameter</string>
167
+ <key>settings</key>
168
+ <dict>
169
+ <key>fontStyle</key>
170
+ <string>italic</string>
171
+ <key>foreground</key>
172
+ <string>7</string>
173
+ </dict>
174
+ </dict>
175
+ </array>
176
+ <key>uuid</key>
177
+ <string>D8D5E82E-3D5B-46B5-B38E-8C841C21347D</string>
178
+ </dict>
179
+ </plist>
@@ -0,0 +1,284 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <plist version="1.0">
3
+ <dict>
4
+ <key>name</key>
5
+ <string>Monokai</string>
6
+ <key>settings</key>
7
+ <array>
8
+ <dict>
9
+ <key>settings</key>
10
+ <dict>
11
+ <key>caret</key>
12
+ <string>254</string>
13
+ <key>foreground</key>
14
+ <string>254</string>
15
+ <key>invisibles</key>
16
+ <string>236</string>
17
+ <key>lineHighlight</key>
18
+ <string>237</string>
19
+ <key>selection</key>
20
+ <string>239</string>
21
+ <key>findHighlight</key>
22
+ <string>15</string>
23
+ <key>findHighlightForeground</key>
24
+ <string>16</string>
25
+ <key>selectionBorder</key>
26
+ <string>235</string>
27
+ </dict>
28
+ </dict>
29
+ <dict>
30
+ <key>name</key>
31
+ <string>Generic</string>
32
+ <key>scope</key>
33
+ <string>generic</string>
34
+ <key>settings</key>
35
+ <dict>
36
+ <key>foreground</key>
37
+ <string>254</string>
38
+ </dict>
39
+ </dict>
40
+ <dict>
41
+ <key>name</key>
42
+ <string>Punctuation</string>
43
+ <key>scope</key>
44
+ <string>punctuation</string>
45
+ <key>settings</key>
46
+ <dict>
47
+ <key>foreground</key>
48
+ <string>254</string>
49
+ </dict>
50
+ </dict>
51
+ <dict>
52
+ <key>name</key>
53
+ <string>Comment</string>
54
+ <key>scope</key>
55
+ <string>comment</string>
56
+ <key>settings</key>
57
+ <dict>
58
+ <key>foreground</key>
59
+ <string>243</string>
60
+ </dict>
61
+ </dict>
62
+ <dict>
63
+ <key>name</key>
64
+ <string>String</string>
65
+ <key>scope</key>
66
+ <string>string</string>
67
+ <key>settings</key>
68
+ <dict>
69
+ <key>foreground</key>
70
+ <string>228</string>
71
+ </dict>
72
+ </dict>
73
+ <dict>
74
+ <key>name</key>
75
+ <string>String Interpolated</string>
76
+ <key>scope</key>
77
+ <string>string.interpolated</string>
78
+ <key>settings</key>
79
+ <dict>
80
+ <key>foreground</key>
81
+ <string>135</string>
82
+ </dict>
83
+ </dict>
84
+ <dict>
85
+ <key>name</key>
86
+ <string>Number</string>
87
+ <key>scope</key>
88
+ <string>constant.numeric, constant.language</string>
89
+ <key>settings</key>
90
+ <dict>
91
+ <key>foreground</key>
92
+ <string>135</string>
93
+ </dict>
94
+ </dict>
95
+ <dict>
96
+ <key>name</key>
97
+ <string>Built-in constant</string>
98
+ <key>scope</key>
99
+ <string>constant.language</string>
100
+ <key>settings</key>
101
+ <dict>
102
+ <key>foreground</key>
103
+ <string>135</string>
104
+ </dict>
105
+ </dict>
106
+ <dict>
107
+ <key>name</key>
108
+ <string>User-defined constant</string>
109
+ <key>scope</key>
110
+ <string>constant.character, constant.other</string>
111
+ <key>settings</key>
112
+ <dict>
113
+ <key>foreground</key>
114
+ <string>153</string>
115
+ </dict>
116
+ </dict>
117
+ <dict>
118
+ <key>name</key>
119
+ <string>Variable</string>
120
+ <key>scope</key>
121
+ <string>variable</string>
122
+ <key>settings</key>
123
+ <dict>
124
+ <key>foreground</key>
125
+ <string>153</string>
126
+ <key>fontStyle</key>
127
+ <string></string>
128
+ </dict>
129
+ </dict>
130
+ <dict>
131
+ <key>name</key>
132
+ <string>Keyword</string>
133
+ <key>scope</key>
134
+ <string>keyword</string>
135
+ <key>settings</key>
136
+ <dict>
137
+ <key>foreground</key>
138
+ <string>161</string>
139
+ </dict>
140
+ </dict>
141
+ <dict>
142
+ <key>name</key>
143
+ <string>Keyword Control</string>
144
+ <key>scope</key>
145
+ <string>keyword.control</string>
146
+ <key>settings</key>
147
+ <dict>
148
+ <key>foreground</key>
149
+ <string>161</string>
150
+ </dict>
151
+ </dict>
152
+ <dict>
153
+ <key>name</key>
154
+ <string>Storage</string>
155
+ <key>scope</key>
156
+ <string>storage</string>
157
+ <key>settings</key>
158
+ <dict>
159
+ <key>fontStyle</key>
160
+ <string></string>
161
+ <key>foreground</key>
162
+ <string>75</string>
163
+ </dict>
164
+ </dict>
165
+ <dict>
166
+ <key>name</key>
167
+ <string>Storage type</string>
168
+ <key>scope</key>
169
+ <string>storage.type</string>
170
+ <key>settings</key>
171
+ <dict>
172
+ <key>fontStyle</key>
173
+ <string>italic</string>
174
+ <key>foreground</key>
175
+ <string>75</string>
176
+ </dict>
177
+ </dict>
178
+ <dict>
179
+ <key>name</key>
180
+ <string>Class name</string>
181
+ <key>scope</key>
182
+ <string>entity.name</string>
183
+ <key>settings</key>
184
+ <dict>
185
+ <key>foreground</key>
186
+ <string>118</string>
187
+ </dict>
188
+ </dict>
189
+ <dict>
190
+ <key>name</key>
191
+ <string>Class name</string>
192
+ <key>scope</key>
193
+ <string>entity.name.class</string>
194
+ <key>settings</key>
195
+ <dict>
196
+ <key>fontStyle</key>
197
+ <string>italic</string>
198
+ <key>foreground</key>
199
+ <string>118</string>
200
+ </dict>
201
+ </dict>
202
+ <dict>
203
+ <key>name</key>
204
+ <string>Tag name</string>
205
+ <key>scope</key>
206
+ <string>entity.name.tag</string>
207
+ <key>settings</key>
208
+ <dict>
209
+ <key>fontStyle</key>
210
+ <string>italic</string>
211
+ <key>foreground</key>
212
+ <string>81</string>
213
+ </dict>
214
+ </dict>
215
+ <dict>
216
+ <key>name</key>
217
+ <string>Tag name type</string>
218
+ <key>scope</key>
219
+ <string>entity.name.type</string>
220
+ <key>settings</key>
221
+ <dict>
222
+ <key>fontStyle</key>
223
+ <string>italic</string>
224
+ <key>foreground</key>
225
+ <string>81</string>
226
+ </dict>
227
+ </dict>
228
+ <dict>
229
+ <key>name</key>
230
+ <string>Inherited class</string>
231
+ <key>scope</key>
232
+ <string>entity.other.inherited-class</string>
233
+ <key>settings</key>
234
+ <dict>
235
+ <key>fontStyle</key>
236
+ <string>italic underline</string>
237
+ <key>foreground</key>
238
+ <string>118</string>
239
+ </dict>
240
+ </dict>
241
+ <dict>
242
+ <key>name</key>
243
+ <string>Function name</string>
244
+ <key>scope</key>
245
+ <string>entity.name.function</string>
246
+ <key>settings</key>
247
+ <dict>
248
+ <key>fontStyle</key>
249
+ <string>italic</string>
250
+ <key>foreground</key>
251
+ <string>118</string>
252
+ </dict>
253
+ </dict>
254
+ <dict>
255
+ <key>name</key>
256
+ <string>Function argument</string>
257
+ <key>scope</key>
258
+ <string>variable.parameter</string>
259
+ <key>settings</key>
260
+ <dict>
261
+ <key>fontStyle</key>
262
+ <string>italic</string>
263
+ <key>foreground</key>
264
+ <string>214</string>
265
+ </dict>
266
+ </dict>
267
+ <dict>
268
+ <key>name</key>
269
+ <string>Error</string>
270
+ <key>scope</key>
271
+ <string>invalid</string>
272
+ <key>settings</key>
273
+ <dict>
274
+ <key>fontStyle</key>
275
+ <string>italic</string>
276
+ <key>foreground</key>
277
+ <string>161</string>
278
+ </dict>
279
+ </dict>
280
+ </array>
281
+ <key>uuid</key>
282
+ <string>D8D5E82E-3D5B-46B5-B38E-8C841C21347D</string>
283
+ </dict>
284
+ </plist>