term.js icon indicating copy to clipboard operation
term.js copied to clipboard

CJK support, Copy and Paste support

Open yoshiokatsuneo opened this issue 10 years ago • 18 comments

yoshiokatsuneo avatar Nov 09 '15 08:11 yoshiokatsuneo

The patch support CJK languages(Japanese for me) for both input(IME) and output. Also, copy and paste (Command-C,Command-V on Mac, or context menu on Windows) works. I tested on Safari, Chrome, Firefox on Mac OS X, and IE, Edge, Chrome, Safari on Windows.

j8enu3mvpp

yoshiokatsuneo avatar Nov 09 '15 08:11 yoshiokatsuneo

To test with tty.js, following patch need to be applied.

/usr/local/lib/node_modules/tty.js/static (master)$ diff -u tty.js-orig tty.js
--- tty.js-orig 2015-11-04 17:03:14.000000000 +0900
+++ tty.js  2015-11-04 17:06:53.000000000 +0900
@@ -302,7 +302,10 @@
 Window.prototype.focus = function() {
   // Restack
   var parent = this.element.parentNode;
-  if (parent) {
+  if (parent && this.element != parent.lastChild) {
+    if (Terminal.focus) {
+        Terminal.focus.blur();
+    }
     parent.removeChild(this.element);
     parent.appendChild(this.element);
   }
@@ -637,7 +640,9 @@
 Tab.prototype._focus = Tab.prototype.focus;

 Tab.prototype.focus = function() {
-  if (Terminal.focus === this) return;
+  var prevFocus = Terminal.focus;
+  this._focus();
+  if (prevFocus === this) return;

   var win = this.window;

@@ -661,7 +666,7 @@

   this.handleTitle(this.title);

-  this._focus();
+  // this._focus();

   win.focus();

yoshiokatsuneo avatar Nov 09 '15 08:11 yoshiokatsuneo

@chjj Is there any chance of taking a look at this PR? I'd really love for #87 to be addressed, and this seems to do it. I can't claim to understand how the CJK support in this PR works, though.

vincentwoo avatar Dec 01 '15 22:12 vincentwoo

+1

e1ee1e11 avatar Jan 26 '16 02:01 e1ee1e11

Hi yoshiokatsuneo, Thanks for your contributing. It will be helpful to me. But I encounter bugs when using yoshiokatsuneo/term.js repository.

  1. The console will become wide after I paste (ctrl + v) a long enough CJK string.
  2. I keep pressing Backspace to delete CJK string , the first character '$' in the console will be deleted. My OS: Win10 and my browser: Chrome ver 48. Best regards.

e1ee1e11 avatar Jan 26 '16 08:01 e1ee1e11

@e1ee1e11 I'm sorry but I cannot reproduce the issue. I think it is nice to have a capture image...

yoshiokatsuneo avatar Jan 26 '16 09:01 yoshiokatsuneo

I'm read and test his code, it's works for me and the code seems fine.

liuzheng avatar Feb 24 '16 05:02 liuzheng

Typing CJK character's problems have not been fully resolved, when pressing the backspace key, you can not delete characters correctly. image

codehz avatar Mar 17 '16 14:03 codehz

@codehz This can't be happen... Please give a short code to reconstruct it. I am very curious about it

liuzheng avatar Mar 17 '16 14:03 liuzheng

@liuzheng712 你用的是什么版本的term.js,我用的是Rancher的,还有我用的是前面提到的TTY.js修改方式对tty.js打了补丁

Which term.js version are you using? I am using rancher/term.js . And I use the patch by yoshiokatsuneo for tty.js.

codehz avatar Mar 17 '16 15:03 codehz

@codehz I'm only using yoshiokatsuneo's verstion, if it possible , Please create a git repository. Maybe this bug comes from your back-end code? which technical you use for the back-end? My is tornado .

liuzheng avatar Mar 17 '16 15:03 liuzheng

@liuzheng712 I use tty.js, I will create a repo tomorrow(GMT+8)...

codehz avatar Mar 17 '16 15:03 codehz

@codehz ok, BTW I'm Chinese~ I know you are Chinese too ... I'm in Shanghai~

liuzheng avatar Mar 17 '16 15:03 liuzheng

@liuzheng712 I have create a repo for this. latest commit is https://github.com/codehz/tty.js/commit/d45942b7c1a348e2dd52439e43e7a818efa42fc4 And I found this problem does not occur when I use bash shell, but other program will. image It seem this problem will occur when program direct read text from stdin. image

codehz avatar Mar 17 '16 23:03 codehz

@codehz snip20160318_19 I cloned your code and run it, no bug....

I'm use OS X Yosemite 10.10.5, Chrome 49.0.2623.87 (64-bit)

liuzheng avatar Mar 18 '16 03:03 liuzheng

@liuzheng712 I'm use win 10, Chrome 49, (tty.js run on Linux vm) it may be the reason.

codehz avatar Mar 18 '16 04:03 codehz

@liuzheng712 Can you try to use some program to get text direct from stdin, I mean do not use readline library, just use scanf function or std::cin. Some shell can handle backspace in their own way. You can just copy that ,compile it, and run it.

#include <iostream>
int main() {
        char test[32];
        std::cin >> test;
        std::cout << test << std::endl;
        return 0;
}

I do not believe this issue depends on OS.

codehz avatar Mar 18 '16 04:03 codehz

@yoshiokatsuneo your cjk branch code works perfect, thanks! :+1:

huan avatar Apr 30 '16 06:04 huan