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: Rewrite #324, add support for indicating ssh and program running in terminal buffer name #325 #331

Closed
wants to merge 3 commits into from

Conversation

HollowMan6
Copy link
Contributor

@HollowMan6 HollowMan6 commented Jul 5, 2020

Rewrite #324 so that the app won't exit without notification when launching it.

Add support for renaming terminal buffer under ssh, an example of terminal buffer name under ssh is provided as follows:
user@example.com:~/

Add support for renaming terminal buffer when running a program, an example of terminal buffer name when running a program is provided as follows:
test- ~/

@MatthewZMD
Copy link
Member

ssh- user@example.com:~/

这是什么语法?terminal ssh一般是这样的:

$ ssh foo@boo
$ ssh boo

@HollowMan6 HollowMan6 changed the title Terminal: add support for ssh #325 Terminal: Rewrite #324, add support for indicating ssh and program running in terminal buffer name #325 Jul 6, 2020
@HollowMan6
Copy link
Contributor Author

ssh- user@example.com:~/

这是什么语法?terminal ssh一般是这样的:

$ ssh foo@boo
$ ssh boo

抱歉,您一定是产生了误解,ssh- user@example.com:~/是在ssh状态下的buffer-name,并不是执行的命令。 为了避免产生误解,我新的commit中删去了ssh-
另外在新的commit中重写了#324 ,解决闪退问题。还完成了

当terminal正在跑一段程序的时候,buffer-name改成: 程序名 - pwd

@MatthewZMD
Copy link
Member

抱歉,您一定是产生了误解,ssh- user@example.com:~/是在ssh状态下的buffer-name,并不是执行的命令。 为了避免产生误解,我新的commit中删去了ssh-。

懂了,我之前无法测试成功,看不到更改后的buffer-name.

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.

现在无法判断ssh成功,destination还是我本地。在我处于ssh状态的时候executing_command一直显示的是我上一条command:changed_directory ~/ changed_destination 本地 changed_executing_command ssh

还有,进入ssh后,changed_directory最好显示服务器里面的pwd

app/terminal/index.html Outdated Show resolved Hide resolved
app/terminal/index.html Show resolved Hide resolved
Comment on lines 163 to 166
var ssh_re = /]0;(.*?):/g;
var re = /:([^\x07].*?)\x07/g;
ssh_arr = ssh_re.exec(msg.data)
arr = re.exec(msg.data)
Copy link
Member

Choose a reason for hiding this comment

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

在我ssh后这儿的bug有点多,match可能有点脆弱了

Copy link
Contributor Author

Choose a reason for hiding this comment

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

我这里一切正常,无论何种情况,可能是不同环境的msg不一样

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

现在无法判断ssh成功,destination还是我本地。在我处于ssh状态的时候executing_command一直显示的是我上一条command:changed_directory ~/ changed_destination 本地 changed_executing_command ssh

还有,进入ssh后,changed_directory最好显示服务器里面的pwd

您好,我这里一切正常,changed_directory也是显示的服务器里面的pwd,我使用的Manjaro的KDE桌面环境,Terminal使用的是Konsole,连接到的ssh服务器是Ubuntu 18.04。

您能否提供一下您的环境和ssh服务器的环境,并在这里插入console.log(msg.data),然后在使用APP的过程中使用devtools记录类似
�]0;hollowman@hollow-manjaro:~��[01;32m[hollowman@hollow-manjaro�[01;37m ~�[01;32m]$这样的信息供我研究?谢谢!

image
image
image
image
image
image

@MatthewZMD
Copy link
Member

目前master有时会出现以下错误:

Traceback (most recent call last):
  File "/home/mt/.emacs.d/site-elisp/emacs-application-framework/app/terminal/buffer.py", line 87, in on_change_directory
    self.update_title()
  File "/home/mt/.emacs.d/site-elisp/emacs-application-framework/app/terminal/buffer.py", line 92, in update_title
    self.change_title(self.buffer_widget.execute_js("title"))
  File "/home/mt/.emacs.d/site-elisp/emacs-application-framework/core/buffer.py", line 209, in change_title
    self.update_buffer_details.emit(self.buffer_id, new_title, self.url)
TypeError: Buffer.update_buffer_details[str, str, str].emit(): argument 2 has unexpected type 'QVariant'

回头看看有没有被你新commit修好

HollowMan6 added a commit to HollowMan6/EAF-OSPP-Summer-2020 that referenced this pull request Jul 7, 2020
@HollowMan6
Copy link
Contributor Author

HollowMan6 commented Jul 7, 2020

更新:

  • 放宽ssh_re匹配 /]0;(.*?):/g/;(.*?):/g
  • 删去buffer-name路径后面的/,因为加上去总感觉怪怪的
  • 其它的Change Request要求

我进行了大量测试,尚未发现任何问题,如果您那里还是ssh有问题,可能匹配需要分类处理,需要专开issue搜集不同terminal的message信息

目前master有时会出现以下错误:

Traceback (most recent call last):
  File "/home/mt/.emacs.d/site-elisp/emacs-application-framework/app/terminal/buffer.py", line 87, in on_change_directory
    self.update_title()
  File "/home/mt/.emacs.d/site-elisp/emacs-application-framework/app/terminal/buffer.py", line 92, in update_title
    self.change_title(self.buffer_widget.execute_js("title"))
  File "/home/mt/.emacs.d/site-elisp/emacs-application-framework/core/buffer.py", line 209, in change_title
    self.update_buffer_details.emit(self.buffer_id, new_title, self.url)
TypeError: Buffer.update_buffer_details[str, str, str].emit(): argument 2 has unexpected type 'QVariant'

回头看看有没有被你新commit修好

这个Bug应该是execute_js没做好类型转换,我已经在上一个Commit重写了update_title方法,理论上没有这个问题了

@MatthewZMD
Copy link
Member

MatthewZMD commented Jul 7, 2020

您能否提供一下您的环境和ssh服务器的环境,并在这里插入console.log(msg.data),然后在使用APP的过程中使用devtools记录类似

你可以用console.error,方便debug,在*eaf* buffer可以看到js: 结果,不需要专门打开devtools。

js: ��������������cd�[K
js: ��ssh yow-lpggp3
js: �[H�[2J�[01;32m[mt@mt-manjaro�[01;37m ~�[01;32m]$�[00m ssh yow-lpggp3
js: 

js: Last login: Mon Jul  6 22:24:10 2020 from 

我测试了一下别的服务器,没问题了,原因出在使用的TERMINAL不同。

目前这个匹配方式过于依赖terminal,比如这么做就会出问题:

$ cd ~
$ sh
$ ls
$ cd /

@MatthewZMD
Copy link
Member

放宽ssh_re匹配 /]0;(.?):/g至/;(.?):/g

在跑个别command后,msg.data有可能会变得特别复杂(比如�[1;48r�[47;1H[�[C�[3C0.420895]�[CNET:�[CRegistered�[Cprotocol�[Cfamily�[C31 �[1;47r�[47;211H)导致M-: (buffer-name) -> "48r�[47;1H[�[4C3.638316]�[CIPv6:~/.emacs.d/site-elisp/emacs-application-framework/app/terminal"

在众多复杂的可能性下,ssh_re几乎无法不出bug,这个方案不一定可行。

现在PR有点复杂了,我建议将它拆分成几个分别提交:

  1. 修复socket.close()引出的错误
  2. term.onLineFeed()里面的input_data与executing_command的计算方式基本没问题,将这部分提交。甚至判断是否ssh也可以从这里开始下手。
  3. 处理ssh

@MatthewZMD MatthewZMD closed this Jul 7, 2020
@HollowMan6
Copy link
Contributor Author

放宽ssh_re匹配 /]0;(.?):/g至/;(.?):/g

在跑个别command后,msg.data有可能会变得特别复杂(比如�[1;48r�[47;1H[�[C�[3C0.420895]�[CNET:�[CRegistered�[Cprotocol�[Cfamily�[C31 �[1;47r�[47;211H)导致M-: (buffer-name) -> "48r�[47;1H[�[4C3.638316]�[CIPv6:~/.emacs.d/site-elisp/emacs-application-framework/app/terminal"

在众多复杂的可能性下,ssh_re几乎无法不出bug,这个方案不一定可行。

现在PR有点复杂了,我建议将它拆分成几个分别提交:

  1. 修复socket.close()引出的错误
  2. term.onLineFeed()里面的input_data与executing_command的计算方式基本没问题,将这部分提交。甚至判断是否ssh也可以从这里开始下手。
  3. 处理ssh

OK. 但是term.onLineFeed()来判断ssh也存在着诸多的问题,用这个必须要先执行一条命令才能获取到ssh的destination信息,而且同样存在不同系统格式不一样的问题。所以这个问题比较棘手。
image
image

HollowMan6 added a commit to HollowMan6/EAF-OSPP-Summer-2020 that referenced this pull request Jul 28, 2020
Signed-off-by: Hollow Man <hollowman186@vip.qq.com>
manateelazycat added a commit that referenced this pull request Jul 28, 2020
Terminal: Rename buffer when running programme as in #331
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

2 participants