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

Version 3.2.3 space key does not work on Mac+Safari #169

Open
warpkwd opened this issue Jul 4, 2018 · 12 comments
Open

Version 3.2.3 space key does not work on Mac+Safari #169

warpkwd opened this issue Jul 4, 2018 · 12 comments

Comments

@warpkwd
Copy link

warpkwd commented Jul 4, 2018

Butterfly version 3.2.3, space key does not work on Mac+Safari.
MacOS: High Sierra varsion 10.13.4
Safari: version 11.1

example : type "ls -la" then
[D 180704 10:57:29 terminal:299] WRIT<u'l'
[D 180704 10:57:29 terminal:318] READ>'l'
[D 180704 10:57:29 terminal:299] WRIT<u's'
[D 180704 10:57:29 terminal:318] READ>'s'
[D 180704 10:57:29 terminal:299] WRIT<u'\xa0'
[D 180704 10:57:29 terminal:318] READ>'\xc2\xa0'
[D 180704 10:57:29 terminal:299] WRIT<u'-'
[D 180704 10:57:29 terminal:318] READ>'-'
[D 180704 10:57:31 terminal:299] WRIT<u'l'
[D 180704 10:57:31 terminal:318] READ>'l'
[D 180704 10:57:32 terminal:299] WRIT<u'a'
[D 180704 10:57:32 terminal:318] READ>'a'
[D 180704 10:57:32 terminal:299] WRIT<u'\r'
[D 180704 10:57:32 terminal:318] READ>'\r\n'
[D 180704 10:57:32 terminal:318] READ>"-bash: $'ls\302\240-la': command not found\r\n\x1b]

version 3.2.2 is OK. but can not use IME and CJK.
firefox , chrome version 3.2.3 is OK.

In case of IPAD mini version 3.2.3 then one key type echo 2 times.
Example: if type "k" then "kk" echoed.

@paradoxxxzero
Copy link
Owner

@PeterCxy any idea?

@paradoxxxzero
Copy link
Owner

For some reason your space key seems to send non breaking space ('\xa0') instead of space (' '), which is why it does not work. As for why though...

@PeterCxy
Copy link
Contributor

PeterCxy commented Jul 4, 2018

Do this happen only when IME is active? Or is it happening regardless of the IME status?

@PeterCxy
Copy link
Contributor

PeterCxy commented Jul 4, 2018

It's because of white-space: nowrap attribute of the hidden textarea. stackoverflow says maybe we need wrap="off"

@warpkwd
Copy link
Author

warpkwd commented Jul 4, 2018

C2A0 (oct \302\240) is UTF-8 NO-BREAK SPACE.
I do not know why safari is sending it.

@warpkwd
Copy link
Author

warpkwd commented Jul 5, 2018

I do not use IME on Mac.

@PeterCxy
Copy link
Contributor

PeterCxy commented Jul 5, 2018

Since I do not have any macOS device to test this, I think I'm going to leave for anybody who could do a test... Although it might be as simple as adding wrap="off" to the textarea in the main HTML.

@paradoxxxzero
Copy link
Owner

Me neither
@warpkwd can you try putting the wrap="off" on the textarea (even with the browser inspector) and see if it changes something?

@warpkwd
Copy link
Author

warpkwd commented Jul 6, 2018

I tried warp="off", but it's nothing changes.
if typing space, space, space, then It becomes as follows.
And web console line shows like underline characters.

[D 180706 10:48:06 terminal:299] WRIT<u'\xa0'
[D 180706 10:48:06 terminal:318] READ>'\xc2\xa0'
[D 180706 10:48:06 terminal:299] WRIT<u'\xa0'
[D 180706 10:48:06 terminal:318] READ>'\xc2\xa0'
[D 180706 10:48:07 terminal:299] WRIT<u'\xa0'
[D 180706 10:48:07 terminal:318] READ>'\xc2\xa0'

Version 3.2.2 is
[D 180706 10:57:02 terminal:299] WRIT<u' '
[D 180706 10:57:02 terminal:318] READ>' '
[D 180706 10:57:03 terminal:299] WRIT<u' '
[D 180706 10:57:03 terminal:318] READ>' '
[D 180706 10:57:08 terminal:299] WRIT<u' '
[D 180706 10:57:08 terminal:318] READ>' '
No problem.

diff` --git a/butterfly/templates/index.html b/butterfly/templates/index.html
index eca7e00..f71e390 100644
--- a/butterfly/templates/index.html
+++ b/butterfly/templates/index.html
@@ -18,7 +18,7 @@
         data-force-unicode-width="{{ 'yes' if options.force_unicode_width else 'no' }}"
         data-root-path="{{ options.uri_root_path }}"
         data-session-token={{ session }}>
-    <textarea id="input-helper">
+    <textarea id="input-helper" wrap="off">
     </textarea>
 <div id="input-view" class="hidden">
 </div>

@warpkwd
Copy link
Author

warpkwd commented Jul 10, 2018

I think this issue is only about Japanese-Mac-default installed IME.
Example, Safari with Google IME works fine.
Maybe, the cause is that u '\xa0' will be sent when space is typed at IME off.
If reviced codes as follow, then works fine.
Thank you.

diff --git a/butterfly/terminal.py b/butterfly/terminal.py
index fb2be29..d090182 100644
--- a/butterfly/terminal.py
+++ b/butterfly/terminal.py
@@ -297,6 +297,8 @@ class Terminal(object):
             self.close()

         log.debug('WRIT<%r' % message)
+        if message == u'\xa0':
+            message = u' '
         self.writer.write(message)
         self.writer.flush()

@paradoxxxzero
Copy link
Owner

Glad you adapted it for your use, but I can't merge this patch since there are some times when you want to input an unbreakable space.

@warpkwd
Copy link
Author

warpkwd commented Jul 10, 2018

OK, no problem.

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

No branches or pull requests

3 participants