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

prompt is Garbled #1054

Closed
zydxhs opened this issue Jul 31, 2016 · 12 comments · Fixed by #1070
Closed

prompt is Garbled #1054

zydxhs opened this issue Jul 31, 2016 · 12 comments · Fixed by #1070

Comments

@zydxhs
Copy link

zydxhs commented Jul 31, 2016

As shown below:
prompt

cmder ver is 1.3 in win7 64bit。

@jankatins
Copy link
Contributor

jankatins commented Aug 1, 2016

Seems that the replacement code can't handle non-ascii chars?

c:\temp
λ mkdir ü

c:\temp
λ cd ü

c:\temp\�
λ

It works fine in a plain cmd window:

c:\temp\ü>

@jankatins
Copy link
Contributor

We currently do this:

    cwd = clink.get_cwd()
    prompt = "\x1b[1;32;40m{cwd} {git}{hg} \n\x1b[1;30;40m{lamb} \x1b[0m"
    new_value = string.gsub(prompt, "{cwd}", cwd)
    clink.prompt.value = string.gsub(new_value, "{lamb}", "λ")

So my reading is that we can't pass the output of clink.get_cwd() to clink.prompt.value?

CC: @mridgers (clink maintainer)

@zydxhs
Copy link
Author

zydxhs commented Aug 3, 2016

May be the clink does not support non-ascii.

@jankatins
Copy link
Contributor

I think it does (letting the cmd set the prompt and then handling it in clink works...), just that the string has to get encoded... No idea how that works :-/

@jankatins
Copy link
Contributor

jankatins commented Aug 8, 2016

So, a bit of debugging (to a ANSI encoded file) shows this:

cwd(string): c:\temp\ü
prompt(string): c:\temp\ü> # before any changes in lua
prompt(string): �[1;32;40mc:\temp\ü {git}{hg}  # after changes in lua

If I interpete http://stackoverflow.com/a/14981670/1380673 and the unicode code points right, then
[updated]

  • the prompt is utf and probably need to set encoded unicode (ü interpreted as windows1252 is encoded as c3 bc, which translates to ü when interpreted as a unicode codepoint)
  • get_cwd() returns the path in windows-125x variants (at least it seems so on my system)

[Note, I have changed my codepage to utf8: chcp 65001 but the same debug output happens with chcp 850 which is the default in a regular cmd window]

So this looks like a problem in clink :-(

@jankatins
Copy link
Contributor

I've taken that upstream: mridgers/clink#415

@zydxhs
Copy link
Author

zydxhs commented Aug 9, 2016

Directly set value to "clink.prompt.value" is ok:
clink.prompt.value = clink.get_cwd
2016-08-09_171234
So, I think the problem is happened in the lua script fun string.gsub.

@jankatins
Copy link
Contributor

I can't reproduce: on my system with clink.prompt.value = clink.get_cwd() (not the last ()!) exactly the same happens:

c:\temp\�

@jankatins
Copy link
Contributor

Please try #1070 for a version which parses the original prompt.

@zydxhs
Copy link
Author

zydxhs commented Aug 10, 2016

I also do not know why.

tks for your efforts(#1070), and it's ok in my system.

2016-08-10

johnsmithcry

发件人:Jan Schulz [email protected]
发送时间:2016-08-09 18:47
主题:Re: [cmderdev/cmder] prompt is Garbled (#1054)
收件人:"cmderdev/cmder"[email protected]
抄送:"zydxhs"[email protected],"Author"[email protected]

I can't reproduce: on my system with clink.prompt.value = clink.get_cwd() (not the last ()!) exactly the same happens:
c:\temp\�


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@jing2si
Copy link

jing2si commented Aug 15, 2016

good job!Thx~
it fixed my same problem!

@davpaez
Copy link

davpaez commented May 4, 2022

According to this commit in clink, the encoding problem appears to have been fixed.

If so, should the clink.lua script go back to use the clink.get_cwd() inside the set_prompt_filter() function again, instead of relying on the more convoluted parsing of clink.prompt.value?

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 a pull request may close this issue.

4 participants