Skip to content

Commit 61cfe77

Browse files
committed
added ability to run bidi on selection
added ability to run bidi on selection or multiple selected text
1 parent 7bb582b commit 61cfe77

6 files changed

+30
-7
lines changed

Context.sublime-menu

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[
2-
{ "command": "bidi", "caption":"Bidirectional text" }
2+
{ "command": "bidi", "caption":"Bidirectional text" },
3+
{ "command": "bidiselection", "caption":"Bidirectional Selection" }
34
]

Default (Windows).sublime-keymap

+4
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
{
33
"keys": ["ctrl+b"],
44
"command": "bidi"
5+
},
6+
{
7+
"keys": ["ctrl+u"],
8+
"command": "bidiselection"
59
}
610
]

Default.sublime-commands

+4
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
{
33
"caption": "Bidirectional text",
44
"command": "run_bidi"
5+
},
6+
{
7+
"caption": "Bidirectional selection",
8+
"command": "run_bidiselection"
59
}
610
]

Main.sublime-menu

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
"caption": "Bidirectional text",
1111
"mnemonic": "B",
1212
"command": "bidi"
13+
},
14+
{
15+
"caption": "Bidirectional selection",
16+
"mnemonic": "S",
17+
"command": "bidiselection"
1318
}
1419
]
1520
}

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Bidirectional text support for Sublime Text 2
1+
Bidirectional text support for Sublime Text 3
22
===================
33

4-
Currently Sublime Text 2 is not supporting bidirectional languages like Arabic, Hebrew etc.. Using this plugin you can view bidirectional texts.
4+
Currently Sublime Text 3 is not supporting bidirectional languages like Arabic, Hebrew etc.. Using this plugin you can view bidirectional texts.
55

66
Please note, I don't know Arabic or Hebrew. I have checked the results by pattern matching. Its a starting point.
77

rtl.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,16 @@
1717
class bidiCommand(sublime_plugin.TextCommand):
1818
def run(self, edit):
1919
region = sublime.Region(0, self.view.size())
20-
txt = self.view.substr(region)
21-
reshaped_text = reshape(txt)
22-
bdiText = get_display(reshaped_text)
23-
self.view.replace(edit, region, bdiText)
20+
bidiRegion(region, self.view, edit)
21+
22+
class bidiselectionCommand(sublime_plugin.TextCommand):
23+
def run(self, edit):
24+
selectionSet = self.view.sel()
25+
for selectionRegion in selectionSet:
26+
bidiRegion(selectionRegion, self.view, edit)
27+
28+
def bidiRegion(region, view, edit):
29+
txt = view.substr(region)
30+
reshaped_text = reshape(txt)
31+
bdiText = get_display(reshaped_text)
32+
view.replace(edit, region, bdiText)

0 commit comments

Comments
 (0)