From 7c0a44e54f011eabbd4dafd9c6454d261e386583 Mon Sep 17 00:00:00 2001 From: David Bekoyan Date: Fri, 3 Feb 2017 12:25:12 +0400 Subject: [PATCH] init commit --- README.md | 20 ++++++++++++++++++-- htoint.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ screenshot.png | Bin 0 -> 9705 bytes 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 htoint.py create mode 100644 screenshot.png diff --git a/README.md b/README.md index 5c5fa27..1c46e21 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,18 @@ -# hex2int -sublime text plugin +hex2int +================ + +## Summary +This plugin show int value of hex in statusbar (just put cursor on hex value) + +## Screenshot +![ScreenShot](https://raw.github.com/unknownuser88/hex2int/master/screenshot.png) + +## Install + +#### Git Clone +Clone this repository in to the Sublime Text "Packages" directory, which is located where ever the +"Preferences" -> "Browse Packages" option in sublime takes you. + + + +--- \ No newline at end of file diff --git a/htoint.py b/htoint.py new file mode 100644 index 0000000..fe4d432 --- /dev/null +++ b/htoint.py @@ -0,0 +1,45 @@ +import sublime, sublime_plugin, re + +class HtointCommand(sublime_plugin.EventListener): + def on_new(self, view): + self.view = view + self.run() + + def on_close(self, view): + self.view.erase_status('Hexcode') + + def on_selection_modified(self, view): + self.view = view + self.run() + + def on_activated(self, view): + self.view = view + self.run() + + def run(self): + statusline = [] + for region in self.view.sel(): + if region.begin() == region.end(): + word = self.view.word(region) + else: + word = region + if not word.empty(): + keyword = self.view.substr(word) + isHex = re.findall(r'0x[0-9a-fA-F]+', keyword) + # print(isHex) + if isHex: + statusline.append('{} -> {}'.format(isHex[0], self.str_to_int(isHex[0]))) + else: + self.view.erase_status('Hexcode') + else: + self.view.erase_status('Hexcode') + # print(", ".join(statusline)) + self.view.set_status('Hexcode', '{}'.format(", ".join(statusline))) + + def str_to_int(self, s): + i = int(s, 16) + if i >= 2**23: + i -= 2**24 + return i + + diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..85c80680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