liveConsole 1.4.0__py3-none-any.whl → 1.5.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.
- __init__.py +1 -0
- commandHistory.py +34 -0
- helpTab.py +64 -0
- liveConsole.py +8 -752
- {liveconsole-1.4.0.dist-info → liveconsole-1.5.0.dist-info}/METADATA +20 -5
- liveconsole-1.5.0.dist-info/RECORD +14 -0
- liveconsole-1.5.0.dist-info/entry_points.txt +2 -0
- liveconsole-1.5.0.dist-info/top_level.txt +8 -0
- mainConsole.py +354 -0
- pysole.py +132 -0
- styledTextbox.py +51 -0
- suggestionManager.py +165 -0
- liveconsole-1.4.0.dist-info/RECORD +0 -7
- liveconsole-1.4.0.dist-info/top_level.txt +0 -2
- {liveconsole-1.4.0.dist-info → liveconsole-1.5.0.dist-info}/WHEEL +0 -0
- {liveconsole-1.4.0.dist-info → liveconsole-1.5.0.dist-info}/licenses/LICENSE +0 -0
__init__.py
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
from pysole import probe, InteractiveConsole
|
commandHistory.py
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
class CommandHistory:
|
2
|
+
"""Manages command history and navigation."""
|
3
|
+
|
4
|
+
def __init__(self):
|
5
|
+
self.history = []
|
6
|
+
self.index = -1
|
7
|
+
self.tempCommand = ""
|
8
|
+
|
9
|
+
def add(self, command):
|
10
|
+
"""Add a command to history."""
|
11
|
+
if command.strip():
|
12
|
+
self.history.append(command)
|
13
|
+
self.index = len(self.history)
|
14
|
+
|
15
|
+
def navigateUp(self):
|
16
|
+
"""Get previous command from history."""
|
17
|
+
if self.index > 0:
|
18
|
+
self.index -= 1
|
19
|
+
return(self.history[self.index])
|
20
|
+
return(None)
|
21
|
+
|
22
|
+
def navigateDown(self):
|
23
|
+
"""Get next command from history."""
|
24
|
+
if self.index < len(self.history) - 1:
|
25
|
+
self.index += 1
|
26
|
+
return(self.history[self.index])
|
27
|
+
elif self.index == len(self.history) - 1:
|
28
|
+
self.index = len(self.history)
|
29
|
+
return(self.tempCommand)
|
30
|
+
return(None)
|
31
|
+
|
32
|
+
def setTemp(self, command):
|
33
|
+
"""Store temporary command while navigating history."""
|
34
|
+
self.tempCommand = command
|
helpTab.py
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
import sys
|
2
|
+
import io
|
3
|
+
from pygments.styles import get_style_by_name
|
4
|
+
import customtkinter as ctk
|
5
|
+
from styledTextbox import StyledTextWindow
|
6
|
+
|
7
|
+
class HelpTab(ctk.CTkFrame):
|
8
|
+
"""A right-hand help tab with closable and updateable text content."""
|
9
|
+
|
10
|
+
def __init__(self, parent, width=500, title="Help", **kwargs):
|
11
|
+
super().__init__(parent, width=width, **kwargs)
|
12
|
+
self.parent = parent
|
13
|
+
self.visible = False
|
14
|
+
|
15
|
+
# Ensure initial width is respected
|
16
|
+
self.pack_propagate(False)
|
17
|
+
|
18
|
+
# Header frame with title and close button
|
19
|
+
headerFrame = ctk.CTkFrame(self, height=30)
|
20
|
+
headerFrame.pack(fill="x")
|
21
|
+
self.style = get_style_by_name("monokai")
|
22
|
+
|
23
|
+
self.titleLabel = ctk.CTkLabel(headerFrame, text=title, font=("Consolas", 12, "bold"))
|
24
|
+
self.titleLabel.pack(side="left", padx=5)
|
25
|
+
|
26
|
+
self.closeButton = ctk.CTkButton(headerFrame, text="X", height=20, command=self.close)
|
27
|
+
self.closeButton.pack(side="right", padx=5)
|
28
|
+
|
29
|
+
# Scrollable text area
|
30
|
+
self.textBox = StyledTextWindow(self, wrap="word", font=("Consolas", 11), bg="#2e2e2e")
|
31
|
+
self.textBox.pack(fill="both", expand=True, padx=5, pady=5)
|
32
|
+
self.textBox.configure(state="disabled") # read-only
|
33
|
+
|
34
|
+
def close(self):
|
35
|
+
"""Hide the help tab."""
|
36
|
+
if self.visible:
|
37
|
+
self.pack_forget()
|
38
|
+
self.visible = False
|
39
|
+
|
40
|
+
def open(self):
|
41
|
+
"""Show the help tab."""
|
42
|
+
if not self.visible:
|
43
|
+
self.pack(side="left", fill="y")
|
44
|
+
# self.configure(width=self.minWidth)
|
45
|
+
self.visible = True
|
46
|
+
|
47
|
+
def _getHelp(self, obj):
|
48
|
+
"""Return the output of help(obj) as a string."""
|
49
|
+
old_stdout = sys.stdout # save current stdout
|
50
|
+
sys.stdout = buffer = io.StringIO() # redirect stdout to a string buffer
|
51
|
+
try:
|
52
|
+
help(obj)
|
53
|
+
return(buffer.getvalue())
|
54
|
+
finally:
|
55
|
+
sys.stdout = old_stdout # restore original stdout
|
56
|
+
|
57
|
+
def updateHelp(self, obj):
|
58
|
+
"""Update the help tab content."""
|
59
|
+
|
60
|
+
self.textBox.configure(state="normal")
|
61
|
+
self.textBox.delete("1.0", "end")
|
62
|
+
self.textBox.insert("1.0", self._getHelp(obj))
|
63
|
+
self.textBox.updateStyling()
|
64
|
+
self.textBox.configure(state="disabled")
|