Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal: Catch change directory signal in node-pty, rename terminal buffer and change Emacs default-directory variable real-time #325

Merged
merged 3 commits into from
Jul 3, 2020

Conversation

HollowMan6
Copy link
Contributor

@HollowMan6 HollowMan6 commented Jul 3, 2020

When you change the directory, sever sends a mesage to the front-end. Here is an example of the message sent when you change your directory into ~:
�]0;hollowman@hollow-manjaro:~��[01;32m[hollowman@hollow-manjaro�[01;37m ~�[01;32m]$

So I use regular expression /:([^\x07].*?)\x07/g to extract the directory infomation when that signal occurs and store it in variable title.

�]0;hollowman@hollow-manjaro: ~ ��[01;32m[hollowman@hollow-manjaro�[01;37m ~�[01;32m]$

AppBuffer(Buffer.py) keep checking the title variable every 250ms, if it detects any change, on_change_directory method will set the title and Emacs default directory.

@HollowMan6 HollowMan6 changed the title Terminal: Catch change directory signal in node-pty, rename terminal buffer and change Emacs default-directory real-time Terminal: Catch change directory signal in node-pty, rename terminal buffer and change Emacs default-directory variable real-time Jul 3, 2020
@MatthewZMD
Copy link
Member

注意indentation,我把之前的改过来了导致这儿出现conflict,你也改一下。

@MatthewZMD MatthewZMD self-requested a review July 3, 2020 06:15
Copy link
Member

@MatthewZMD MatthewZMD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

粗略的看了一下,还没时间测试

app/terminal/index.html Outdated Show resolved Hide resolved
app/terminal/buffer.py Outdated Show resolved Hide resolved
@HollowMan6
Copy link
Contributor Author

感谢Review, 已经按相关要求更新。

另外我在JS中多增加了一个判断,避免了切换到"/"根目录时显示“//”的情况

@MatthewZMD
Copy link
Member

MatthewZMD commented Jul 3, 2020

基本没有问题,可以试着支持一下ssh

你感兴趣的话可以再增加一个功能,当terminal正在跑一段程序的时候,buffer-name改成: 程序名 - pwd

@MatthewZMD MatthewZMD merged commit 48c44fd into emacs-eaf:master Jul 3, 2020
@HollowMan6
Copy link
Contributor Author

基本没有问题,可以试着支持一下ssh

可以尝试。

你感兴趣的话可以再增加一个功能,当terminal正在跑一段程序的时候,buffer-name改成: 程序名 - pwd

我看了一下,服务器端如果执行程序的话,并不会发送特别的消息到前端,要实现这个可能需要换一种思路。

@HollowMan6
Copy link
Contributor Author

你感兴趣的话可以再增加一个功能,当terminal正在跑一段程序的时候,buffer-name改成: 程序名 - pwd

我想到了,可以首先储存按下的按键信息,在前端按下回车后,进入跑程序状态,当收到下面命令后自动退出跑程序状态。那这也可以尝试。

�]0;hollowman@hollow-manjaro:~��[01;32m[hollowman@hollow-manjaro�[01;37m ~�[01;32m]$

@MatthewZMD
Copy link
Member

哈哈,一种问题有很多种解法,随便尝试随便玩

HollowMan6 added a commit to HollowMan6/EAF-OSPP-Summer-2020 that referenced this pull request Jul 4, 2020
MatthewZMD added a commit that referenced this pull request Jul 4, 2020
HollowMan6 added a commit to HollowMan6/EAF-OSPP-Summer-2020 that referenced this pull request Jul 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants