forked from faisal-oead/sublime-text-2-arabic-support
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtl.py
25 lines (20 loc) · 801 Bytes
/
rtl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# -*- coding: utf-8 -*-
# This work is licensed under the GNU Public License (GPL).
# To view a copy of this license, visit http://www.gnu.org/copyleft/gpl.html
# Written by praveen vijayan (praveenvijayan)
# Written by faisal oead
import sublime, sublime_plugin, sys
import arabic_reshaper
class bidiCommand(sublime_plugin.TextCommand):
def run(self, edit):
region = sublime.Region(0, self.view.size())
bidiRegion(region, self.view, edit)
class bidiselectionCommand(sublime_plugin.TextCommand):
def run(self, edit):
selectionSet = self.view.sel()
for selectionRegion in selectionSet:
bidiRegion(selectionRegion, self.view, edit)
def bidiRegion(region, view, edit):
txt = view.substr(region)
reshaped_text = arabic_reshaper.reshape(txt)
view.replace(edit, region, reshaped_text)