parent
5546b56fd6
commit
6294113e20
|
@ -1373,3 +1373,11 @@ class CloseBrace(CloseTag):
|
|||
mytag = '}'
|
||||
class CloseBracket(CloseTag):
|
||||
mytag = ']'
|
||||
|
||||
class GetToken(Method):
|
||||
def _execute(self, w, **vargs):
|
||||
token = w.get_token()
|
||||
if token is None:
|
||||
w.application.set_error('No Token')
|
||||
else:
|
||||
w.application.set_error('Token: %r' % token.string)
|
||||
|
|
5
mode2.py
5
mode2.py
|
@ -1,5 +1,5 @@
|
|||
import os, sets, string
|
||||
import color, lex2
|
||||
import color, lex2, method
|
||||
|
||||
DEBUG = False
|
||||
|
||||
|
@ -142,6 +142,9 @@ class Fundamental(Handler):
|
|||
self.add_bindings('set-mode', ('C-x m',))
|
||||
self.add_bindings('cancel', ('C-]',))
|
||||
|
||||
# unbound actions
|
||||
self.add_action(method.GetToken())
|
||||
|
||||
# create all the insert actions for the basic text input
|
||||
for c in string.letters + string.digits + string.punctuation:
|
||||
self.add_binding('insert-string-%s' % c, c)
|
||||
|
|
|
@ -352,7 +352,9 @@ class PerlViewWordPerldoc(method.Method):
|
|||
w.application.data_buffer("*Perldoc*", data, switch_to=True)
|
||||
w.application.set_error('displaying documentation for %r' % word)
|
||||
def _execute(self, w, **vargs):
|
||||
word = w.get_word(wl=string.letters + string.digits + '_:')
|
||||
token = w.get_token()
|
||||
#word = w.get_word(wl=string.letters + string.digits + '_:')
|
||||
word = token.string
|
||||
|
||||
# make sure that the name is (mostly) valid
|
||||
if word is None:
|
||||
|
|
|
@ -24,7 +24,9 @@ class XML(mode2.Fundamental):
|
|||
#self.add_bindings('close-brace', ('}',))
|
||||
#self.add_bindings('close-bracket', (']',))
|
||||
self.colors = {
|
||||
'comment': color.build('red', 'default'),
|
||||
'comment.start': color.build('red', 'default'),
|
||||
'comment.null': color.build('red', 'default'),
|
||||
'comment.end': color.build('red', 'default'),
|
||||
'opentag.start': color.build('default', 'default'),
|
||||
'opentag.namespace': color.build('magenta', 'default'),
|
||||
'opentag.name': color.build('blue', 'default'),
|
||||
|
|
11
window2.py
11
window2.py
|
@ -532,6 +532,17 @@ class Window(object):
|
|||
self.buffer.redo()
|
||||
|
||||
# highlighting tokens
|
||||
def get_token(self):
|
||||
return self.get_token_at_point(self.logical_cursor())
|
||||
def get_token_at_point(self, p):
|
||||
for token in self.get_highlighter().tokens[p.y]:
|
||||
if token.end_x() <= p.x:
|
||||
continue
|
||||
elif token.x > p.x:
|
||||
continue
|
||||
else:
|
||||
return token
|
||||
return None
|
||||
def get_next_token_by_lambda(self, p, f):
|
||||
for token in self.get_highlighter().tokens[p.y]:
|
||||
if token.x < p.x:
|
||||
|
|
Loading…
Reference in New Issue