liveConsole 1.7.1__py3-none-any.whl → 1.7.3__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.
Potentially problematic release.
This version of liveConsole might be problematic. Click here for more details.
- {liveconsole-1.7.1.dist-info → liveconsole-1.7.3.dist-info}/METADATA +1 -1
- {liveconsole-1.7.1.dist-info → liveconsole-1.7.3.dist-info}/RECORD +10 -10
- pysole/mainConsole.py +24 -20
- pysole/pysole.py +66 -37
- pysole/settings.json +1 -1
- pysole/themes.json +4 -4
- {liveconsole-1.7.1.dist-info → liveconsole-1.7.3.dist-info}/WHEEL +0 -0
- {liveconsole-1.7.1.dist-info → liveconsole-1.7.3.dist-info}/entry_points.txt +0 -0
- {liveconsole-1.7.1.dist-info → liveconsole-1.7.3.dist-info}/licenses/LICENSE +0 -0
- {liveconsole-1.7.1.dist-info → liveconsole-1.7.3.dist-info}/top_level.txt +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
liveconsole-1.7.
|
|
1
|
+
liveconsole-1.7.3.dist-info/licenses/LICENSE,sha256=7dZ0zL72aGaFE0C9DxacOpnaSkC5jajhG6iL7lqhWmU,1064
|
|
2
2
|
pysole/__init__.py,sha256=SfaSBmFVSmhyf55UedBCqhi2Ss6Tre-BCKtZb3bSr2k,60
|
|
3
3
|
pysole/__main__.py,sha256=QvVFH8J2yzgQaF9MosQ6ajCW67uiRbYliePsTEUCIAg,82
|
|
4
4
|
pysole/commandHistory.py,sha256=xJtWbJ_vgJo2QGgaZJsApTOi_Hm8Yz0V9_zqQUCItj8,1084
|
|
5
5
|
pysole/helpTab.py,sha256=o0uSY-8sw7FuuBrt0FQwcgK6ljNVx3IgRnW7heZ6GvY,2454
|
|
6
6
|
pysole/liveConsole.py,sha256=lzS3dphAQ1i8pQC4E2FY-FyMMSKi-dAN0xr6XUgrNmo,168
|
|
7
|
-
pysole/mainConsole.py,sha256=
|
|
8
|
-
pysole/pysole.py,sha256=
|
|
9
|
-
pysole/settings.json,sha256=
|
|
7
|
+
pysole/mainConsole.py,sha256=t_ijaSm2rTxM5CrLqjxT5Oq_OFwxk7JsPOAXxo9dbdE,15357
|
|
8
|
+
pysole/pysole.py,sha256=OdENWPZnchn_DbYGdcb7WULumYM1NxQmwe9DJzPb0xY,12707
|
|
9
|
+
pysole/settings.json,sha256=cmOtIhRDWHMwmQMESuykWuzJd_jG6iT2tJ-uhSps_3U,722
|
|
10
10
|
pysole/styledTextbox.py,sha256=qWnwGAKjl7R2HYPXQOr8GrGYIr4JC8PzmeioOCH7hGo,2236
|
|
11
11
|
pysole/suggestionManager.py,sha256=EUFeCQoZnLS8EjPPNuZpzjY0BR07m2KP5TloyaMDVGY,6457
|
|
12
|
-
pysole/themes.json,sha256=
|
|
12
|
+
pysole/themes.json,sha256=2KvEfxm-eDsfVKIdBhWk-Qd93wYQub3YwkxbS6CGKH0,2525
|
|
13
13
|
pysole/utils.py,sha256=-mGHAp0MkbMPQ9eYzPmo5AGHDLuQ9NfPio_2_iaiCuY,294
|
|
14
|
-
liveconsole-1.7.
|
|
15
|
-
liveconsole-1.7.
|
|
16
|
-
liveconsole-1.7.
|
|
17
|
-
liveconsole-1.7.
|
|
18
|
-
liveconsole-1.7.
|
|
14
|
+
liveconsole-1.7.3.dist-info/METADATA,sha256=6AmM8rq7hHfgfxzn7353PwDLSBgVs2JoX2tNWvUdhMM,4955
|
|
15
|
+
liveconsole-1.7.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
16
|
+
liveconsole-1.7.3.dist-info/entry_points.txt,sha256=qtvuJHcex4QqM97x_UawFWJYnfhQRl0jhqLcWRpnAGo,84
|
|
17
|
+
liveconsole-1.7.3.dist-info/top_level.txt,sha256=DlpA93ScJbRZcF8kGSc5YoO8Ntu1ib1_MEZMb4xea_Q,7
|
|
18
|
+
liveconsole-1.7.3.dist-info/RECORD,,
|
pysole/mainConsole.py
CHANGED
|
@@ -50,6 +50,10 @@ class InteractiveConsoleText(StyledTextWindow):
|
|
|
50
50
|
self.bind("<Up>", self.onUp)
|
|
51
51
|
self.bind("<Down>", self.onDown)
|
|
52
52
|
|
|
53
|
+
def getPromptPosition(self):
|
|
54
|
+
"""Get the position right after the prompt on current command line."""
|
|
55
|
+
return(f"{self.currentCommandLine}.{self.PROMPT_LENGTH}")
|
|
56
|
+
|
|
53
57
|
def getCurrentLineNumber(self):
|
|
54
58
|
"""Get the line number where current command starts."""
|
|
55
59
|
return(int(self.index("end-1c").split(".")[0]))
|
|
@@ -60,30 +64,35 @@ class InteractiveConsoleText(StyledTextWindow):
|
|
|
60
64
|
def getCommandStartPosition(self):
|
|
61
65
|
"""Get the starting position of the current command."""
|
|
62
66
|
return(f"{self.currentCommandLine}.0")
|
|
67
|
+
|
|
68
|
+
def writeToPrompt(self, text):
|
|
69
|
+
"""Write text to the prompt of the console"""
|
|
70
|
+
if self.isExecuting:
|
|
71
|
+
return
|
|
72
|
+
|
|
73
|
+
if text:
|
|
74
|
+
self.insert("end", text)
|
|
75
|
+
self.mark_set("insert", "end")
|
|
76
|
+
self.see("end")
|
|
77
|
+
self.updateStyling(start=self.getPromptPosition()) #< Ensure styling/lexer applied after programmatic change:
|
|
63
78
|
|
|
64
79
|
def replaceCurrentCommand(self, newCommand):
|
|
65
80
|
"""Replace the current command with new text."""
|
|
66
|
-
if self.isExecuting:
|
|
67
|
-
return
|
|
68
|
-
|
|
69
81
|
start = self.getPromptPosition()
|
|
70
82
|
end = "end-1c"
|
|
71
|
-
|
|
72
83
|
self.delete(start, end)
|
|
73
|
-
|
|
74
|
-
self.insert(start, newCommand)
|
|
75
|
-
self.mark_set("insert", "end")
|
|
76
|
-
self.see("end")
|
|
77
|
-
# Ensure styling/lexer applied after programmatic change:
|
|
78
|
-
self.updateStyling(start=self.getPromptPosition())
|
|
84
|
+
self.writeToPrompt(newCommand)
|
|
79
85
|
|
|
80
|
-
def runCommand(self, command, printCommand=False):
|
|
86
|
+
def runCommand(self, command, printCommand=False, clearPrompt=True):
|
|
81
87
|
"""Insert code into the console prompt and execute it as if Enter was pressed."""
|
|
82
88
|
if self.isExecuting:
|
|
83
89
|
return(False)
|
|
84
90
|
if printCommand:
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
if clearPrompt:
|
|
92
|
+
self.replaceCurrentCommand(command) #< Replace current command with the new code
|
|
93
|
+
else:
|
|
94
|
+
self.writeToPrompt(command)
|
|
95
|
+
self.onEnter(None, insertWhitespace=False) #< Simulate pressing Enter to run the command
|
|
87
96
|
else:
|
|
88
97
|
self.executeCommandThreaded(command, addPrompt=False)
|
|
89
98
|
|
|
@@ -98,7 +107,7 @@ class InteractiveConsoleText(StyledTextWindow):
|
|
|
98
107
|
return((cursorLine >= self.currentCommandLine and
|
|
99
108
|
(cursorLine > self.currentCommandLine or cursorCol >= self.PROMPT_LENGTH)))
|
|
100
109
|
|
|
101
|
-
def onEnter(self, event):
|
|
110
|
+
def onEnter(self, event, insertWhitespace=True):
|
|
102
111
|
"""Handle Enter key - execute command."""
|
|
103
112
|
self.suggestionManager.hideSuggestions()
|
|
104
113
|
|
|
@@ -119,9 +128,8 @@ class InteractiveConsoleText(StyledTextWindow):
|
|
|
119
128
|
return("break")
|
|
120
129
|
|
|
121
130
|
# Check if statement is incomplete
|
|
122
|
-
if self.isIncompleteStatement(command):
|
|
131
|
+
if self.isIncompleteStatement(command) and insertWhitespace:
|
|
123
132
|
return(self.onShiftEnter(event))
|
|
124
|
-
|
|
125
133
|
# Execute the command
|
|
126
134
|
self.history.add(command)
|
|
127
135
|
self.mark_set("insert", "end")
|
|
@@ -351,10 +359,6 @@ class InteractiveConsoleText(StyledTextWindow):
|
|
|
351
359
|
"""Insert a newline at the end."""
|
|
352
360
|
self.writeOutput("")
|
|
353
361
|
|
|
354
|
-
def getPromptPosition(self):
|
|
355
|
-
"""Get the position right after the prompt on current command line."""
|
|
356
|
-
return(f"{self.currentCommandLine}.{self.PROMPT_LENGTH}")
|
|
357
|
-
|
|
358
362
|
def getCurrentCommand(self):
|
|
359
363
|
"""Extract the current command text (without prompt)."""
|
|
360
364
|
start = self.getPromptPosition()
|
pysole/pysole.py
CHANGED
|
@@ -96,8 +96,11 @@ class InteractiveConsole(ctk.CTk):
|
|
|
96
96
|
with open(filename, "r", encoding="utf-8") as f:
|
|
97
97
|
lines = f.readlines()
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
startLineIndex = callerFrame.f_lineno
|
|
100
|
+
startLine = lines[startLineIndex - 1]
|
|
101
|
+
leadingWhitespaceLen = len(startLine) - len(startLine.lstrip())
|
|
102
|
+
self.startupCode = lines[startLineIndex:]
|
|
103
|
+
self.startupCode = [line.rstrip()[leadingWhitespaceLen:] for line in self.startupCode]
|
|
101
104
|
|
|
102
105
|
def _createMenu(self):
|
|
103
106
|
"""Create a menu bar using CTkOptionMenu."""
|
|
@@ -257,44 +260,70 @@ class InteractiveConsole(ctk.CTk):
|
|
|
257
260
|
sys.stdout = sys.__stdout__
|
|
258
261
|
sys.stderr = sys.__stderr__
|
|
259
262
|
self.destroy()
|
|
263
|
+
|
|
264
|
+
def _printWaterMark(self):
|
|
265
|
+
m = (
|
|
266
|
+
"Welcome to Pysole, if you find me useful, please star me on GitHub:\n"
|
|
267
|
+
"https://github.com/TzurSoffer/Pysole"
|
|
268
|
+
)
|
|
269
|
+
stdPrint(m)
|
|
270
|
+
self.console.newline()
|
|
271
|
+
self.console.writeOutput(m, "instruction")
|
|
272
|
+
time.sleep(0.1)
|
|
273
|
+
if self.runRemainingCode:
|
|
274
|
+
if self.printStartupCode:
|
|
275
|
+
self.console.addPrompt()
|
|
276
|
+
else:
|
|
277
|
+
self.console.newline()
|
|
278
|
+
else:
|
|
279
|
+
self.console.addPrompt()
|
|
280
|
+
|
|
281
|
+
def _splitCodeIntoChunks(self):
|
|
282
|
+
codeChunks = []
|
|
283
|
+
currentChunk = []
|
|
284
|
+
|
|
285
|
+
for line in self.startupCode:
|
|
286
|
+
strippedLine = line.lstrip()
|
|
287
|
+
indentLevel = len(line) - len(strippedLine)
|
|
288
|
+
|
|
289
|
+
if not strippedLine: #< Blank line, keep it in current chunk
|
|
290
|
+
currentChunk.append(line)
|
|
291
|
+
continue
|
|
292
|
+
|
|
293
|
+
if indentLevel != 0:
|
|
294
|
+
currentChunk.append(line)
|
|
295
|
+
else:
|
|
296
|
+
codeChunks.append(currentChunk)
|
|
297
|
+
currentChunk = [line]
|
|
298
|
+
|
|
299
|
+
if currentChunk:
|
|
300
|
+
codeChunks.append(currentChunk)
|
|
301
|
+
|
|
302
|
+
return(["\n".join(chunk).strip() for chunk in codeChunks if any(line.strip() for line in chunk)])
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
def _runStartup(self):
|
|
306
|
+
if self.removeWaterMark == False:
|
|
307
|
+
self._printWaterMark()
|
|
308
|
+
|
|
309
|
+
if self.runRemainingCode == False:
|
|
310
|
+
return
|
|
311
|
+
|
|
312
|
+
if self.printStartupCode == False:
|
|
313
|
+
self.console.newline()
|
|
314
|
+
code = "\n".join(self.startupCode)
|
|
315
|
+
self.console.executeCommandThreaded(code, addPrompt=True)
|
|
316
|
+
return
|
|
317
|
+
|
|
318
|
+
chunks = self._splitCodeIntoChunks()
|
|
319
|
+
for chunk in chunks:
|
|
320
|
+
while self.console.isExecuting:
|
|
321
|
+
time.sleep(0.01)
|
|
322
|
+
self.console.runCommand(chunk, printCommand=True, clearPrompt=True)
|
|
260
323
|
|
|
261
324
|
def probe(self, *args, **kwargs):
|
|
262
325
|
"""Start the console main loop."""
|
|
263
|
-
|
|
264
|
-
if not self.removeWaterMark:
|
|
265
|
-
m = (
|
|
266
|
-
"Welcome to Pysole, if you find me useful, please star me on GitHub:\n"
|
|
267
|
-
"https://github.com/TzurSoffer/Pysole"
|
|
268
|
-
)
|
|
269
|
-
stdPrint(m)
|
|
270
|
-
self.console.newline()
|
|
271
|
-
self.console.writeOutput(m, "instruction")
|
|
272
|
-
time.sleep(0.1)
|
|
273
|
-
if self.runRemainingCode:
|
|
274
|
-
if self.printStartupCode:
|
|
275
|
-
self.console.addPrompt()
|
|
276
|
-
else:
|
|
277
|
-
self.console.newline()
|
|
278
|
-
else:
|
|
279
|
-
self.console.addPrompt()
|
|
280
|
-
elif self.runRemainingCode == True and self.printStartupCode == False:
|
|
281
|
-
self.console.newline()
|
|
282
|
-
|
|
283
|
-
for line in self.startupCode:
|
|
284
|
-
line = line.rstrip()
|
|
285
|
-
while self.console.isExecuting:
|
|
286
|
-
time.sleep(0.01)
|
|
287
|
-
if self.printStartupCode:
|
|
288
|
-
# self.console.writeOutput(line)
|
|
289
|
-
self.console.runCommand(line, printCommand=True)
|
|
290
|
-
else:
|
|
291
|
-
# self.console.writeOutput(line)
|
|
292
|
-
self.console.runCommand(line, printCommand=False)
|
|
293
|
-
|
|
294
|
-
if self.runRemainingCode == True and self.printStartupCode == False:
|
|
295
|
-
self.console.resetCurrentLineNumber()
|
|
296
|
-
self.console.addPrompt()
|
|
297
|
-
threading.Thread(target=runStartup).start()
|
|
326
|
+
self.after(0, threading.Thread(target=self._runStartup).start)
|
|
298
327
|
self.mainloop(*args, **kwargs)
|
|
299
328
|
|
|
300
329
|
def probe(userGlobals=None, userLocals=None, callerFrame=None,
|
pysole/settings.json
CHANGED
pysole/themes.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"OUTPUT": "#ffffff",
|
|
12
12
|
"ERROR": "#ff0000",
|
|
13
13
|
"RESULT": "#66ccff",
|
|
14
|
-
"INSTRUCTION": "#
|
|
14
|
+
"INSTRUCTION": "#ffccdd",
|
|
15
15
|
"SUGGESTION_BOX_BG": "#2d2d2d",
|
|
16
16
|
"SUGGESTION_BOX_SELECTION_BG": "#0066cc",
|
|
17
17
|
"FONT": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"OUTPUT": "#000000",
|
|
32
32
|
"ERROR": "#ff0000",
|
|
33
33
|
"RESULT": "#0066cc",
|
|
34
|
-
"INSTRUCTION": "#
|
|
34
|
+
"INSTRUCTION": "#ffccdd",
|
|
35
35
|
"SUGGESTION_BOX_BG": "#f0f0f0",
|
|
36
36
|
"SUGGESTION_BOX_SELECTION_BG": "#cce6ff",
|
|
37
37
|
"FONT": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"OUTPUT": "#586e75",
|
|
52
52
|
"ERROR": "#dc322f",
|
|
53
53
|
"RESULT": "#2aa198",
|
|
54
|
-
"INSTRUCTION": "#
|
|
54
|
+
"INSTRUCTION": "#ffccdd",
|
|
55
55
|
"SUGGESTION_BOX_BG": "#eee8d5",
|
|
56
56
|
"SUGGESTION_BOX_SELECTION_BG": "#b58900",
|
|
57
57
|
"FONT": {
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"OUTPUT": "#f8f8f2",
|
|
72
72
|
"ERROR": "#ff5555",
|
|
73
73
|
"RESULT": "#8be9fd",
|
|
74
|
-
"INSTRUCTION": "#
|
|
74
|
+
"INSTRUCTION": "#ffccdd",
|
|
75
75
|
"SUGGESTION_BOX_BG": "#44475a",
|
|
76
76
|
"SUGGESTION_BOX_SELECTION_BG": "#6272a4",
|
|
77
77
|
"FONT": {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|