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

[59_22] MacBook日本键盘无法输入反斜杠 #1587

Open
thomas-huang opened this issue Jan 19, 2024 · 20 comments
Open

[59_22] MacBook日本键盘无法输入反斜杠 #1587

thomas-huang opened this issue Jan 19, 2024 · 20 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@thomas-huang
Copy link

thomas-huang commented Jan 19, 2024

Mogan 版本

1.2.2

操作系统版本和架构

MacOS 11.7.9

描述问题

我的MacBook是日本键盘, 输入反斜杠(backslash)是: option + ¥
但是在墨干里面无法输入反斜杠, 会出现一个backslash, 一个slash, 如下截图
Screen Shot 2024-01-19 at 12 31 18

期待的结果

希望能正常输入反斜杠

@thomas-huang thomas-huang added the bug Something isn't working label Jan 19, 2024
@da-liii
Copy link
Contributor

da-liii commented Jan 19, 2024

如何切换到日本键盘?硬件上是一样的吧?是不是切换到日语的环境就可以复现这个问题了?

@da-liii
Copy link
Contributor

da-liii commented Jan 19, 2024

输入反斜杠是进入命令模式,输入反斜杠之后,再按tab,就可以输入反斜杠

@da-liii da-liii added the question Further information is requested label Jan 19, 2024
@thomas-huang
Copy link
Author

日本键盘是下面这样的, 上面没有backslash键, 要用option + ¥组合键才能输入反斜杠

问题是, 我在输入数学公式的时候, 使用option+¥组合键时, 会出现一个反斜杠, 一个斜杠, 无法输入Latex命令

Screen Shot 2024-01-20 at 09 45 24

Screen Shot 2024-01-20 at 09 50 13

@thomas-huang
Copy link
Author

我在TeXmacs里用option+¥输入数学公式是正常的:

Screen Shot 2024-01-23 at 18 17 54

@da-liii
Copy link
Contributor

da-liii commented Jan 23, 2024

https://github.com/XmacsLabs/mogan/blob/v1.2.3-rc3/src/Plugins/Qt/qt_utilities.cpp#L1223-L1409'

你可以自己改一下from_key_press_event这个函数,按照截图中显示的,问题在于本来应该是\,但是变成了A-\ (Option+\),所以无法识别。

或者,可以参考("\\" (if (or (inside? 'hybrid) (in-prog?)) (insert "\\") (make-hybrid)))A-\定义为输入latex混合命令的快捷键

详见:
https://github.com/XmacsLabs/mogan/blob/v1.2.3-rc3/TeXmacs/progs/generic/generic-kbd.scm#L45

这一行的快捷键定义决定了\是输入latex混合命令的快捷键

@thomas-huang
Copy link
Author

好的谢谢, 搞定了

@da-liii
Copy link
Contributor

da-liii commented Jan 29, 2024

在这里分享一下你是如何解决这个问题的?改cpp代码还是改Scheme代码?帮助一下使用墨干且使用日本键盘笔记本的朋友?

@thomas-huang
Copy link
Author

对于使用MacBook JIS keyboard(日本键盘)的同学, 最简单的方法是修改自定义配置文件

打开: Develop-Open my-init-texmacs.scm

Screen Shot 2024-01-29 at 22 57 47

添加配置代码:

(delayed
  (lazy-keyboard-force)

  ;; shortcuts in all modes
  (kbd-map
    ;; fix JIS keyboard bugs
    ("A-\\" (if (or (inside? 'hybrid) (in-prog?)) (insert "\\") (make-hybrid)))

)

@da-liii
Copy link
Contributor

da-liii commented Jan 29, 2024

有什么办法可以判断一个键盘是JIS Keyboard么?

@thomas-huang
Copy link
Author

应该是要用苹果的API: TISCopyCurrentKeyboardInputSource

Screen Shot 2024-01-31 at 02 12 28

@thomas-huang
Copy link
Author

安装v1.2.3后, option+¥ 又输入不了反斜杠了

v1.3.3似乎没有按键事件:
Screen Shot 2024-01-31 at 18 52 33

v1.2.2是正常的:
Screen Shot 2024-01-31 at 18 50 37

@da-liii
Copy link
Contributor

da-liii commented Jan 31, 2024

v1.2.3对键盘相关的处理逻辑做了重构,参考任务 59_13:
https://github.com/XmacsLabs/mogan/issues?q=59_13

@da-liii
Copy link
Contributor

da-liii commented Feb 3, 2024

https://doc.qt.io/qt-5/qinputmethod.html#locale-prop

这是qt的获取输入法locale的接口,或许可以用于判断是否是Japanese键盘。

@da-liii
Copy link
Contributor

da-liii commented Feb 3, 2024

#1638

这个pr应该能修复这个问题

@da-liii da-liii changed the title MacBook日本键盘无法输入反斜杠 [59_22] MacBook日本键盘无法输入反斜杠 Feb 3, 2024
@da-liii da-liii added this to the v1.2.5 milestone Feb 3, 2024
@da-liii
Copy link
Contributor

da-liii commented Feb 5, 2024

试一下 https://github.com/XmacsLabs/mogan/releases/tag/v1.2.5-alpha

这个问题应该已经解决了。

@thomas-huang
Copy link
Author

https://doc.qt.io/qt-5/qinputmethod.html#locale-prop

这是qt的获取输入法locale的接口,或许可以用于判断是否是Japanese键盘。

这个应该不行,我的locale设置的是en_US.UTF-8

Screen Shot 2024-02-17 at 21 27 55

@thomas-huang
Copy link
Author

试一下 https://github.com/XmacsLabs/mogan/releases/tag/v1.2.5-alpha

这个问题应该已经解决了。

还是不行

@da-liii da-liii added help wanted Extra attention is needed and removed question Further information is requested labels Feb 18, 2024
@da-liii da-liii removed this from the v1.2.5 milestone Feb 19, 2024
@da-liii
Copy link
Contributor

da-liii commented Feb 19, 2024

我试了将系统语言切换到日语,以及切换键盘,在我的macOS上无法复现这个问题,需要使用日本键盘的用户或者开发者参与开发才能最终解决这个问题。

@ProfFan
Copy link

ProfFan commented Mar 25, 2024

本质是 input 没用 Cocoa Text 那一套造成的,感觉还是比较难搞
@thomas-huang 可以试试用 Karabiner Elements workaround 一下

@thomas-huang
Copy link
Author

对于使用MacBook JIS keyboard(日本键盘)的同学, 最简单的方法是修改自定义配置文件

打开: Develop-Open my-init-texmacs.scm

Screen Shot 2024-01-29 at 22 57 47

添加配置代码:

(delayed
  (lazy-keyboard-force)

  ;; shortcuts in all modes
  (kbd-map
    ;; fix JIS keyboard bugs
    ("A-\\" (if (or (inside? 'hybrid) (in-prog?)) (insert "\\") (make-hybrid)))

)

@ProfFan @darcy-shen 感谢回复, 只能暂时通过配置文件解决, 代码如下

(delayed
  (lazy-keyboard-force)

  ;; shortcuts in all modes
  (kbd-map
    ;; fix JIS keyboard bugs
    ("yen" (if (or (inside? 'hybrid) (in-prog?)) (insert "\\") (make-hybrid)))

)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants