Perfect. Now I can switch seamlessly between viewer and editor... I find this very useful (eg with encoding problems when moving files from Windows to Linux). Well done, great feature.
EDIT: Hm... load a file, switch to hex view, switch back to text edit, add some text and try to save. Error message saying file can't be saved. I toggled read-only... no change.
Probably some flag set by the viewer.
plugin to (re)open file as hex/binary
Great.
FWIW, this is the plugin code (disclaimer: I am no Pythonista):There's a small problem in that the ed.cmd(cmds.cCommand_ScrollToCaretTop) call doesn't really do what it's supposed to do.
FWIW, this is the plugin code (disclaimer: I am no Pythonista):
Code: Select all
def fancy_python_name(self):
if ed.get_prop(PROP_V_MODE)!=VMODE_NONE:
ed.set_prop(PROP_V_MODE,VMODE_NONE)
ed.focus()
ed.set_caret(*Command.hexCr[ed])
ed.cmd(cmds.cCommand_ScrollToCaretTop)
else:
Command.hexCr[ed]=ed.get_carets()[0]
ed.set_prop(PROP_V_MODE,VMODE_HEX)
ed.set_prop(PROP_V_WIDTH_HEX,32)
Code uses unset var... need do this:
Code: Select all
class Command:
crt = None #global inited var
def method(self):
# code to restore crt
if self.crt:
ed.set_caret(*self.crt)
#code to save crt
self.crt = ed.get_carets()[0]
I've left that bit out as an exercise for the reader Of course, I have defined hexCr (as evidenced by it being referenced as Command.hexCr).Alexey wrote:Code uses unset var... need do this:
Sure, it works in the general case but it definitely does not work when switching back into text editor mode.Alexey wrote:> the ed.cmd(cmds.cCommand_ScrollToCaretTop) call doesn't really do what it's supposed to do.
It works here- if I place 10 carets, scroll to end of big file, cmd scrolls to top caret