branch : pmacs2
This commit is contained in:
moculus 2008-10-14 01:42:55 +00:00
parent c6de3642ad
commit eda2cd274f
2 changed files with 17 additions and 5 deletions

View File

@ -677,7 +677,6 @@ class Binary32Buffer(FileBuffer):
def __init__(self, path, name=None): def __init__(self, path, name=None):
'''fb = FileBuffer(path)''' '''fb = FileBuffer(path)'''
FileBuffer.__init__(self, path, name) FileBuffer.__init__(self, path, name)
#self.rawdata = []
def _detect_nl_type(self, data): def _detect_nl_type(self, data):
return '\n' return '\n'
def cursorx_to_datax(self, cy, cx): def cursorx_to_datax(self, cy, cx):

View File

@ -3,6 +3,7 @@ from subprocess import Popen, PIPE, STDOUT
import color, mode import color, mode
from lex import Grammar, PatternRule, RegionRule from lex import Grammar, PatternRule, RegionRule
from method import Method, Argument from method import Method, Argument
from method.move import GotoBeginning, GotoEnd
from point import Point from point import Point
from render import RenderString from render import RenderString
@ -19,20 +20,22 @@ class HexSetByteOrder(Method):
class HexForward(Method): class HexForward(Method):
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
end = w.buffer.get_buffer_end()
if w.cursor >= end.add(-2, 0):
return
w.forward() w.forward()
if w.mode.symbolic_edit: if w.mode.symbolic_edit:
w.forward() w.forward()
end = w.buffer.get_buffer_end()
while w.cursor_char().isspace() and w.cursor < end: while w.cursor_char().isspace() and w.cursor < end:
w.forward() w.forward()
class HexBackward(Method): class HexBackward(Method):
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
w.backward() w.backward()
if w.mode.symbolic_edit:
w.backward()
start = w.buffer.get_buffer_start() start = w.buffer.get_buffer_start()
while w.cursor_char().isspace() and w.cursor > start: while w.cursor_char().isspace() and w.cursor > start:
w.backward() w.backward()
if w.mode.symbolic_edit:
w.backward()
class HexForwardWord(Method): class HexForwardWord(Method):
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
@ -56,6 +59,14 @@ class HexEndOfLine(Method):
if w.cursor_char() == '\n': if w.cursor_char() == '\n':
w.backward() w.backward()
class HexGotoBeginning(GotoBeginning):
'''Move the cursor to the start of the current hex line'''
class HexGotoEnd(GotoEnd):
'''Move the cursor to the end of the current hex line'''
def _execute(self, w, **vargs):
w.application.methods['goto-end'].execute(w)
w.application.methods['hex-backward'].execute(w)
class HexRead(Method): class HexRead(Method):
_is_method = False _is_method = False
def __init__(self, type_, fmt): def __init__(self, type_, fmt):
@ -219,7 +230,7 @@ class Hex(mode.Fundamental):
HexStartOfLine, HexEndOfLine, ShowAddress, ShowX86Instruction, HexStartOfLine, HexEndOfLine, ShowAddress, ShowX86Instruction,
GotoAddress, HexSetByteOrder, HexToggleSymbolic, GotoAddress, HexSetByteOrder, HexToggleSymbolic,
HexOverwriteCharSpace, HexOverwriteCharTab, HexOverwriteCharSpace, HexOverwriteCharTab,
HexOverwriteCharNewline] HexOverwriteCharNewline, HexGotoBeginning, HexGotoEnd]
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)
self.bindings = {} self.bindings = {}
@ -277,6 +288,8 @@ class Hex(mode.Fundamental):
self.add_bindings('hex-backward-word', ('M-b', 'M-L_ARROW',)) self.add_bindings('hex-backward-word', ('M-b', 'M-L_ARROW',))
self.add_bindings('hex-start-of-line', ('C-a', 'HOME',)) self.add_bindings('hex-start-of-line', ('C-a', 'HOME',))
self.add_bindings('hex-end-of-line', ('C-e', 'END',)) self.add_bindings('hex-end-of-line', ('C-e', 'END',))
self.add_bindings('hex-goto-beginning', ('M-<',))
self.add_bindings('hex-goto-end', ('M->',))
self.add_action_and_bindings(HexRead('char', 'b'), ('C-c b',)) self.add_action_and_bindings(HexRead('char', 'b'), ('C-c b',))
self.add_action_and_bindings(HexRead('uchar', 'B'), ('C-c B',)) self.add_action_and_bindings(HexRead('uchar', 'B'), ('C-c B',))