Skip to content

Commit

Permalink
fix #51 and also fix #52
Browse files Browse the repository at this point in the history
  • Loading branch information
littlewhitecloud authored Jul 17, 2023
1 parent fc616ed commit 788dfd0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tktermwidget/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,13 @@ def execute(self, _: Event) -> str:
if cmd in ["clear", "cls"]:
self.text.delete("1.0", "end")
self.directory()
self.index = 1
return "break"
elif cmd == "exit":
self.master.quit()
elif cmd.startswith("cd"): # TAG: is all platform use cd...?
# It will raise OSError instead of output a normal error
# TODO: fix it
if cmd == "cd..":
chdir(path.abspath(path.join(getcwd(), "..")))
else:
Expand Down Expand Up @@ -252,8 +255,6 @@ def execute(self, _: Event) -> str:
# Update the text and the index
self.index = int(self.text.index("insert").split(".")[0])
self.update()

del cmd, errors, returncode, returnlines
return "break" # Prevent the default newline character insertion

def newline(self) -> None:
Expand All @@ -263,6 +264,8 @@ def newline(self) -> None:

def update(self) -> str:
"""Update the text widget or the command has no output"""
# Make a newline
self.newline()
# Insert the directory
self.directory()
# Update cursor and check if it is out of the edit range
Expand Down

0 comments on commit 788dfd0

Please sign in to comment.