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

Emacs like TeX Input Method #289

Closed
humphreylee opened this issue Feb 15, 2021 · 19 comments
Closed

Emacs like TeX Input Method #289

humphreylee opened this issue Feb 15, 2021 · 19 comments

Comments

@humphreylee
Copy link

In Atom, particularly Juno, special character, e.g. beta (β) could be entered into the editor with "\beta", followed by "tab". Is this do able in notepad2?

@zufuliu
Copy link
Owner

zufuliu commented Feb 15, 2021

Only following is available: type and select \u03B2, then click Edit -> Special -> Hex to Char (Ctrl + Alt +C).

@humphreylee
Copy link
Author

humphreylee commented Feb 15, 2021

Tested. Yes, that's current workflow - but not practical. How many people knows "\u03B2" is for beta that got to be entered in a special way? Most/I would just find it from/copy web and paste it. Frankly, not many editors have this feature. Julia's REPL does it nicely. This is how Emacs does it -> [https://emacs.stackexchange.com/questions/5647/how-to-input-special-character-such-as-celsius-symbol-and-common-greek-letters]

Looking forward for this feature.

@zufuliu zufuliu changed the title Special character auto-completion Emacs like TeX Input Method Feb 18, 2021
@zufuliu
Copy link
Owner

zufuliu commented Feb 18, 2021

The Emacs wiki https://www.emacswiki.org/emacs/TeXInputMethod

Currently Tab is used to insert tab character (or expand it to spaces) and indent text, Enter is used to insert new line and auto indent on next line, Space is not intercepted.

@humphreylee
Copy link
Author

Some pointers of implementation.
Julia REPL: https://docs.julialang.org/en/v1/manual/unicode-input/
Julia REPL & others: https://stackoverflow.com/questions/25494567/julia-how-to-deal-with-special-unicode-characters

@zufuliu zufuliu added this to the v4.21.03 milestone Feb 22, 2021
@zufuliu
Copy link
Owner

zufuliu commented Feb 27, 2021

Implemented by 11be675. This change make the exe 60 KiB bigger (with 56 KiB data grabbed from https://docs.julialang.org/en/v1.7-dev/manual/unicode-input/). feel free to test latest builds from https://github.com/zufuliu/notepad2/actions

@maboroshin, @VenusGirl: there is a menu item need translation.

zufuliu added a commit that referenced this issue Feb 28, 2021
…irectly

to avoid extra UTF-32 to UTF-16 conversion, issue #289.
@humphreylee
Copy link
Author

Thanks for your prompt action. Downloaded a version from https://github.com/zufuliu/notepad2/actions/runs/605432502. It works momentarily. Below are the steps to reproduce the error.

  1. Setting -> "Enable LaTeX Input Method"
  2. Type "\beta", followed by Tab key. A "β" appeared.
  3. Enter/Type either "Tab" or "Space". The "β" became "XCEbeta". "XCE" is in inverted color (black background+white word). Sometime XCE became XCF.
  4. Smiley is not working. E.g. ":smile" will remain as it is, despite the drop-down selection.

It would really nice to have the drop-down selection display actual symbol/smiley. Currently, the drop down selection shows symbol_name_in_text.

@zufuliu
Copy link
Owner

zufuliu commented Feb 28, 2021

Thanks for testing, I will debug the "XCE" bug. For emoji, the trailing : is needed (\:smile:, 😄), maybe it can be added automatically after selection.
issue-289-emoji

@zufuliu
Copy link
Owner

zufuliu commented Feb 28, 2021

@humphreylee can you provide a screenshot for the "XCE" bug? especial, statusbar (which contains encoding info, like UTF-8) and text around \beta. I seems cannot reproduce the bug, below is a gif for the default UTf-8 encoding (made by https://github.com/NickeManarin/ScreenToGif)
LaTeX289

@zufuliu
Copy link
Owner

zufuliu commented Feb 28, 2021

Please test latest build again, and provide more info (file encoding, surrounding text and steps as before) when it still failed.

The : suffix for emoji is optional now. Also disable Tab to finish auto-completion (in Auto Completion Settings) sometimes might useful when using LaTeX input method.

@humphreylee
Copy link
Author

humphreylee commented Feb 28, 2021

Tested latest version from https://github.com/zufuliu/notepad2/actions/runs/607900939. Observations are below.

  • Symbol (e.g. "\beta") and emoji (e.g. "\:smile") are working as expected, i.e. producing the correct symbol/emoji after tabbing.
  • Disabling tab to finish auto-completion creates unpleasant behaviour, but probably expected. For example, typing "\be" will create drop-down of options, including beta, etc.. Scroll to "beta" then tab to auto-complete. It does not auto complete to "\beta", and does not change into correct symbol. This is probably expected behaviour - then it is OK.

Thank you for completing the requested enhancement.

zufuliu added a commit that referenced this issue Mar 1, 2021
@zufuliu
Copy link
Owner

zufuliu commented Mar 1, 2021

Tab should works as expected now. i.e. type \be, then select beta, press Tab, β will be entered directly; press other keys (like Enter), \beta will be entered, which is useful when typing LaTeX commands.

A further enhancement is showing the symbol with it's name, just like GitHub emoji drop down list (see screenshot in #289 (comment)), implement this is straightforward.

@humphreylee
Copy link
Author

Tested the last two versions (CI #541 and CI#542). Some observations below.

  • "XCE" bug resurfaced.
    notepad2latexsymbol

  • I guess the "further enhancement" has not being implemented. Sorry, just too eager to try out.

@zufuliu
Copy link
Owner

zufuliu commented Mar 2, 2021

The "xCE" is fixed by 1e4d859.

Show symbol in auto-completion drop-down list will not be implemented before https://sourceforge.net/p/scintilla/bugs/2179/ is implemented. The drop-down list is rendered with GDI, which has bugs on rendering characters not implemented by the selected font: unsupported characters will be rendered as boxes (this bug was reported many times). e.g., you can download https://github.com/zufuliu/notepad2/blob/master/scintilla/win32/LaTeXInputData.h, then open it with Notepad2, in Settings -> Advanced Settings, change Rendering Technology to Legacy GDI, you will see most math symbols now rendered as boxes.

@zufuliu
Copy link
Owner

zufuliu commented Mar 6, 2021

I think the code is stable now, please test latest builds and check whether there are other bugs, or improvements better to have.

@humphreylee
Copy link
Author

Tested version CI#550. The \latex_input seems working as expected, except some quirk with disabling the "tab" in auto-completion. Enabling "tab" in auto-completion seems working as expected. Step to reproduce it.

  1. Disable "Tab" in auto-completion.
  2. Type "\beta" and press tab. You will notice that "\beta" will remain as it is.
  3. Press "Arrow Back", then "tab". "\beta" will turn into β.

For someone familiar with his/her symbol, typically would type the symbol_full_name instead of scrolling the drop-down (mouse or keyboard -> faster), and followed by tab. In this case, the \latex will remain as it is. Just wondering (still wondering) whether it is OK to make an exception/option (in auto-completion) for \latex.

Other than that, just waiting for the upstream fix to have symbol/emoji dropdown.

@zufuliu
Copy link
Owner

zufuliu commented Mar 6, 2021

Disable "Tab" in auto-completion.

I'm wrong about disable Tab, so I made enable Tab (the default) works as expected, because I found that saved one key press: type a prefix, select one from auto-completion list, then press Tab to enter the corresponding symbol directly; press Enter or other keys to enter the selected name (which is useful in other situation).

Show symbol/emoji will be implemented once the upstream issue fixed.

@humphreylee
Copy link
Author

I'm wrong about disable Tab, so I made enable Tab (the default) works as expected, because I found that saved one key press: type a prefix, select one from auto-completion list, then press Tab to enter the corresponding symbol directly; press Enter or other keys to enter the selected name (which is useful in other situation).

The test version that I have used had "tab" enabled in auto-completion (default), which is OK. My earlier comment is confusing - my apology. Indeed, by tabbing, user can save key press. Personally, the current setup is OK.

What I meant in earlier comment is if someone purposely/ accidentally un-check "tab" in auto-completion, then some quirky behaviour (Step 2 and 3) as described in that comment will appear. Below are the steps to reproduce it (copied from above).

  1. Disable "Tab" in auto-completion.
  2. Type "\beta" and press tab. You will notice that "\beta" will remain as it is.
  3. Press "Arrow Back", then "tab". "\beta" will turn into β.

For someone familiar with his/her symbol, typically would type the symbol_full_name instead of scrolling the drop-down (mouse or keyboard -> faster), and followed by tab. In this case, the \latex will remain as it is. Just wondering (still wondering) whether it is OK to make an exception/option (in auto-completion) for \latex. <- Enhancement??

zufuliu added a commit that referenced this issue Mar 6, 2021
@zufuliu
Copy link
Owner

zufuliu commented Mar 6, 2021

Implemented by db2a834, when LaTeX input method is enabled, pressing Tab will always trying to convert text before caret into corresponding symbol/emoji.

@humphreylee
Copy link
Author

Tested CI #552. \latex and :smiley are working as expected. This is great. Thank you.

@zufuliu zufuliu closed this as completed Mar 14, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
…irectly

to avoid extra UTF-32 to UTF-16 conversion, issue zufuliu#289.
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants