Skip to content

Commit

Permalink
Patch for CR #325 and code improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
HollowMan6 committed Jul 3, 2020
1 parent 7536509 commit 14f1639
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
10 changes: 7 additions & 3 deletions app/terminal/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(self, buffer_id, url, config_dir, arguments, emacs_var_dict, module
arguments_dict = json.loads(arguments)
self.command = arguments_dict["command"]
self.start_directory = arguments_dict["directory"]
self.current_directory = self.start_directory
self.index_file = os.path.join(os.path.dirname(__file__), "index.html")
self.server_js = os.path.join(os.path.dirname(__file__), "server.js")

Expand Down Expand Up @@ -77,12 +78,15 @@ def open_terminal_page(self):
(self.emacs_var_dict["eaf-terminal-dark-mode"] == "" and self.emacs_var_dict["eaf-emacs-theme-mode"] == "dark"):
theme = "dark"
with open(self.index_file, "r") as f:
html = f.read().replace("%1", str(self.port)).replace("%2", "file://" + os.path.join(os.path.dirname(__file__))).replace("%3", theme).replace("%4", self.emacs_var_dict["eaf-terminal-font-size"])
html = f.read().replace("%1", str(self.port)).replace("%2", "file://" + os.path.join(os.path.dirname(__file__))).replace("%3", theme).replace("%4", self.emacs_var_dict["eaf-terminal-font-size"]).replace("%5", self.current_directory)
self.buffer_widget.setHtml(html)

def on_change_directory(self):
self.update_title()
self.eval_in_emacs.emit('''(setq default-directory "'''+self.buffer_widget.execute_js("title")+'''")''')
changed_directory = self.buffer_widget.execute_js("title")
if not str(changed_directory) == self.current_directory:
self.update_title()
self.eval_in_emacs.emit('''(setq default-directory "'''+ str(changed_directory) +'''")''')
self.current_directory = str(changed_directory)

def update_title(self):
self.change_title(self.buffer_widget.execute_js("title"))
Expand Down
13 changes: 9 additions & 4 deletions app/terminal/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
theme: theme
});

var title = "~/"
var title = "%5"

const searchAddon = new SearchAddon.SearchAddon();

Expand Down Expand Up @@ -126,13 +126,18 @@
}

socket.onmessage = (msg) => {
var re = /:([^\x07]*?)\x07/g;
var re = /:([^\x07].*?)\x07/g;
arr = re.exec(msg.data)
if(arr) {
title = arr[1]+"/";
if (arr[1] === "/") {
title = arr[1];
}
else {
title = arr[1]+"/"
}
}

if(msg==="Closing") {
if(msg === "Closing") {
socket.close();
}
}
Expand Down

0 comments on commit 14f1639

Please sign in to comment.