I am developing a sublimetext plug-in.
This is a plug-in that allows you to divide Japanese into word levels by double-clicking.
https://github.com/ASHIJANKEN/JapaneseWordSeparator
Currently, this plug-in is being registered with Package Control and has been interacting with the administrator.
https://github.com/wbond/package_control_channel/pull/6992#issuecomment-383399294
"In order to enable this function only for Japanese sentences, it is better to mask the key bindings using the following context in .sublime-keymap or .sublime_mousemap."
{
"keys": ["ctrl+left",
"command": "key_select_jp",
"args": {"key": "left"},
"context": [
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\p {Jpan}$"}
]
}
Based on this, I tried to create the following context, but it doesn't work well. I've been playing with operand a lot, but this plug-in will be enabled at any time (even in English sentences).
// Pattern 1
"context": [
{ "key": "preceding_text", "operator": "regex_contains", "operand": "[\\p {Katakana}\\p {Hiragana}\\p {Han}. , .?!? · "()":()"$"}
]
// Pattern 2
"context": [
{ "key": "preceding_text", "operator": "regex_contains", "operand": "[\\p {Katakana}\\p {Hiragana}\\p {Han}. , .?!? · "()":()"}
]
// Pattern 3
"context": [
{ "key": "preceding_text", "operator": "regex_contains", "operand": "[An-ahn 1- 。v., , !?!? · "()]}
]
// and so on. I also tried regex_match but it didn't work.
I think the regular expression method is bad, but I don't know how to specify it to solve it.
Does anyone have any tips?
Thank you for your cooperation.
By the way, regarding the context, I think the following site is easy to understand.
https://qiita.com/shibainurou/items/dc18f2dfc91e36adb208#%E3%82%B3%E3%83%B3%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%81%8C%E3%81%82%E3%82%8B%E5%A0%B4%E5%90%88
I also made some Sublime Text packages and registered them in Package Control.
When I put the package you made in the Packages
directory of the Sublime Text and tried pattern 1-3, pattern 12 doesn't work, but pattern 3 seems to work fine.
"Operating without problems" specifically refers to the following:
key_select_jp
command responds when the cursor is in Japanese in the line preceding the cursorset_motion
command responds when there is no Japanese in the line before the cursor (=Sublime Text default movement)Incidentally, some of the .sublime-keymap
when I checked the operation are as follows:
{
"keys": ["super+left",
"command": "key_select_jp",
"args": {"key": "left"},
"context": [
{
"key": "preceding_text",
"operator": "regex_contains",
"operand": "[An-An-An-An-An-An-An-An-An-An-An-An-An-An-An-An-An-An-An-An-An-An-An-An-An-An-An-An-An-An-An-An
}
]
},
My environment is macOS.
Below are some comments.
\\p {Katakana}
in pattern 12 is not available here.Please check it out.context
documents, so you should refer to other packages.If you have already installed many packages, you can search under the Packages
directory for examples.I hope you will find it helpful. :)
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
581 PHP ssh2_scp_send fails to send files as intended
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.