parent
ef6c9c92e2
commit
9cf785885a
|
@ -69,8 +69,7 @@ public class HibernateUtil {
|
|||
}
|
||||
public static void checkData(String sql) {
|
||||
try {
|
||||
HibernateUtil.outputResultSet(st
|
||||
.executeQuery(sql));
|
||||
HibernateUtil.outputResultSet(st.executeQuery(sql));
|
||||
// conn.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -507,9 +507,9 @@ class TabBuffer(Method):
|
|||
y = w.logical_cursor().y
|
||||
it = InsertTab()
|
||||
for i in range(0, len(w.buffer.lines)):
|
||||
w.goto_line(i)
|
||||
w.goto_line(i + 1)
|
||||
it.execute(w)
|
||||
w.goto_line(y)
|
||||
w.goto_line(y + 1)
|
||||
class GetIndentionLevel(Method):
|
||||
'''Calculate the indention level for this line'''
|
||||
def _execute(self, w, **vargs):
|
||||
|
|
|
@ -82,7 +82,7 @@ class CTabber2(tab.StackTabber2):
|
|||
control_tokens = {'keyword': {'if': 1, 'else': 1, 'while': 1, 'do': 1, 'for': 1}}
|
||||
end_at_eof = False
|
||||
end_at_tokens = {'delimiter': {';': 1}}
|
||||
nocontinue_tokens = {'delimiter': {';': 1}}
|
||||
nocontinue_tokens = {'delimiter': {';': 1, ',': 1}}
|
||||
start_free_tokens = {'string.start': 'string.end'}
|
||||
end_free_tokens = {'string.end': 'string.start'}
|
||||
start_macro_tokens = {'macro.start': 'macro.end'}
|
||||
|
|
|
@ -10,6 +10,7 @@ class StringGrammar(Grammar):
|
|||
PatternRule('data', r'[^\\"]+'),
|
||||
]
|
||||
|
||||
# TODO: a lot of these rules need fixing
|
||||
chr1 = '[a-zA-Z_]'
|
||||
chr2 = '[a-zA-Z0-9-_]'
|
||||
symb = chr1 + chr2 + '*'
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import commands, os.path, string, sys, traceback
|
||||
import color, completer, default, mode, regex, tab
|
||||
from point import Point
|
||||
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule, NocasePatternRule
|
||||
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
|
||||
from lex import NocasePatternRule, PatternMatchRule
|
||||
from method.shell import Interact
|
||||
|
||||
class AtomGrammar(Grammar):
|
||||
|
@ -16,23 +17,28 @@ class StringGrammar(Grammar):
|
|||
NocasePatternRule(r'data', r'[^\\"]+'),
|
||||
]
|
||||
|
||||
chr1 = '[a-z]'
|
||||
chr2 = '[a-zA-Z0-9_@]'
|
||||
atom = chr1 + chr2 + '*'
|
||||
|
||||
class ErlangGrammar(Grammar):
|
||||
rules = [
|
||||
PatternRule(r'eol', r'\n'),
|
||||
PatternRule(r'comment', r'%.*$'),
|
||||
PatternRule(r'erl_attribute', r'-[a-z][a-zA-Z0-9_@]+'),
|
||||
PatternRule(r'erl_reserved', r"(?:xor|when|try|rem|receive|query|orelse|or|of|not|let|if|fun|end|div|cond|catch|case|bxor|bsr|bsl|bor|bnot|begin|band|andalso|and|after)(?![a-zA-Z0-9_'])"),
|
||||
PatternRule(r'erl_arity', r'[a-z][a-zA-Z0-9_@]*/(?:0|[1-9][0-9]*)'),
|
||||
PatternRule(r'erl_function', r'[a-z][a-zA-Z0-9_@]*(?= *\()'),
|
||||
PatternRule(r'erl_namespace', r'[a-z][a-zA-Z0-9_@]*(?=:)'),
|
||||
PatternRule(r'erl_builtin', r"whereis|unregister|unlink|tuple_to_list|tuple_size|trunc|tl|time|throw|term_to_binary|term_to_binary|statistics|split_binary|spawn_opt|spawn_opt|spawn_opt|spawn_opt|spawn_monitor|spawn_monitor|spawn_link|spawn_link|spawn_link|spawn_link|spawn|spawn|spawn|spawn|size|setelement|self|round|registered|register|put|purge_module|process_info|process_info|process_flag|process_flag|processes|pre_loaded|port_control|port_connect|port_command|port_close|pid_to_list|open_port|now|nodes|nodes|node|node|monitor_node|module_loaded|make_ref|load_module|list_to_tuple|list_to_pid|list_to_integer|list_to_float|list_to_existing_atom|list_to_bitstring|list_to_binary|list_to_atom|link|length|is_tuple|is_reference|is_record|is_record|is_process_alive|is_port|is_pid|is_number|is_list|is_integer|is_function|is_function|is_float|is_boolean|is_bitstring|is_binary|is_atom|is_alive|iolist_to_binary|iolist_size|iolist|iodata|integer_to_list|hd|halt|halt|group_leader|group_leader|get_keys|get|get|garbage_collect|garbage_collect|float_to_list|float|ext_binary|exit|exit|erase|erase|ence|element|disconnect_node|delete_module|date|concat_binary|check_process_code|byte_size|bitstring_to_list|bit_size|binary_to_term|binary_to_list|binary_to_list|atom_to_list|atom_to_list|apply|apply|apply|abs"),
|
||||
RegionRule(r'erl_atom', r"'", AtomGrammar, r"'"),
|
||||
RegionRule(r'string', r'"', StringGrammar, r'"'),
|
||||
PatternRule(r'erl_atom', r"[a-z][a-zA-Z0-9_@]*"),
|
||||
PatternRule(r'erl_variable', r"[A-Z_][a-zA-Z0-9_@]*"),
|
||||
PatternRule(r'delimiter', r'->|<<|>>|\(|\)|{|}|\[|\]|\.|;|,|\|'),
|
||||
PatternRule(r'operator', r'\+\+|--|==|/=|=<|<|>=|>|=:=|=/=>|-|\+|\*|/|:|#|!]'),
|
||||
NocasePatternRule(r'number', r'\$.|[+-]?\d+#[a-z0-9]+|[+-]?\d+\.\d+|[+-]?\.\d+|[+-]?\d+'),
|
||||
PatternRule('eol', r'\n'),
|
||||
PatternRule('comment', '%.*$'),
|
||||
PatternRule('erl_attribute', '-' + atom),
|
||||
RegionRule('erl_attribute', "-'", AtomGrammar ,"'"),
|
||||
PatternRule('erl_reserved', "(?:xor|when|try|rem|receive|query|orelse|or|of|not|let|if|fun|end|div|cond|catch|case|bxor|bsr|bsl|bor|bnot|begin|band|andalso|and|after)(?!" + chr2 + ")"),
|
||||
PatternRule('erl_arity', atom + '/(?:0|[1-9][0-9]*)'),
|
||||
PatternMatchRule('x', '('+atom+')( *)(\()', 'erl_function', 'spaces', 'delimiter'),
|
||||
PatternMatchRule('x', '('+atom+')(:)', 'erl_namespace', 'delimiter'),
|
||||
PatternRule('erl_builtin', "(?:whereis|unregister|unlink|tuple_to_list|tuple_size|trunc|tl|time|throw|term_to_binary|term_to_binary|statistics|split_binary|spawn_opt|spawn_opt|spawn_opt|spawn_opt|spawn_monitor|spawn_monitor|spawn_link|spawn_link|spawn_link|spawn_link|spawn|spawn|spawn|spawn|size|setelement|self|round|registered|register|put|purge_module|process_info|process_info|process_flag|process_flag|processes|pre_loaded|port_control|port_connect|port_command|port_close|pid_to_list|open_port|now|nodes|nodes|node|node|monitor_node|module_loaded|make_ref|load_module|list_to_tuple|list_to_pid|list_to_integer|list_to_float|list_to_existing_atom|list_to_bitstring|list_to_binary|list_to_atom|link|length|is_tuple|is_reference|is_record|is_record|is_process_alive|is_port|is_pid|is_number|is_list|is_integer|is_function|is_function|is_float|is_boolean|is_bitstring|is_binary|is_atom|is_alive|iolist_to_binary|iolist_size|iolist|iodata|integer_to_list|hd|halt|halt|group_leader|group_leader|get_keys|get|get|garbage_collect|garbage_collect|float_to_list|float|ext_binary|exit|exit|erase|erase|ence|element|disconnect_node|delete_module|date|concat_binary|check_process_code|byte_size|bitstring_to_list|bit_size|binary_to_term|binary_to_list|binary_to_list|atom_to_list|atom_to_list|apply|apply|apply|abs)(?!" + chr2 + ")"),
|
||||
RegionRule('erl_atom', "'", AtomGrammar, "'"),
|
||||
RegionRule('string', '"', StringGrammar, '"'),
|
||||
PatternRule('erl_atom', atom),
|
||||
PatternRule('erl_variable', r"[A-Z_]" + chr2 + "*"),
|
||||
PatternRule('delimiter', r'->|<<|>>|\(|\)|{|}|\[|\]|\.|;|,|\|'),
|
||||
PatternRule('operator', r'\+\+|--|==|/=|=<|<|>=|>|=:=|=/=>|-|\+|\*|/|:|#|!]'),
|
||||
NocasePatternRule('number', r'\$.|[+-]?\d+#[a-z0-9]+|[+-]?\d+\.\d+|[+-]?\.\d+|[+-]?\d+'),
|
||||
]
|
||||
|
||||
class ErlangTabber(tab.StackTabber):
|
||||
|
@ -106,6 +112,7 @@ class Erlang(mode.Fundamental):
|
|||
'erl_atom': ('magenta', 'default', 'bold'),
|
||||
'erl_atom.start': ('magenta', 'default', 'bold'),
|
||||
'erl_atom.null': ('magenta', 'default', 'bold'),
|
||||
'erl_atom.data': ('magenta', 'default', 'bold'),
|
||||
'erl_atom.end': ('magenta', 'default', 'bold'),
|
||||
}
|
||||
actions = [
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import re
|
||||
from method import Method
|
||||
import mode
|
||||
from mode import Fundamental
|
||||
|
||||
_error_regexes = [
|
||||
r'at (?P<file>\S+) line (?P<line>\d+)\.?$', #perl
|
||||
|
@ -39,11 +39,11 @@ class ErrorGotoLine(Method):
|
|||
a.methods['goto-line'].execute(b2.windows[0], lineno=line)
|
||||
w.set_error(errline)
|
||||
|
||||
class Error(mode.Fundamental):
|
||||
class Error(Fundamental):
|
||||
name = 'Error'
|
||||
actions = [ErrorGotoLine]
|
||||
def __init__(self, w):
|
||||
mode.Fundamental.__init__(self, w)
|
||||
Fundamental.__init__(self, w)
|
||||
self.add_bindings('error-goto-line', ('RETURN', 'C-c M-g',))
|
||||
|
||||
install = Error.install
|
||||
|
|
|
@ -7,57 +7,52 @@ from mode.python import StringGrammar2
|
|||
from mode.pipe import Pipe
|
||||
from method.shell import Interact
|
||||
|
||||
class DataGrammar(Grammar):
|
||||
rules = [PatternRule(r'data', r'[^)]+')]
|
||||
class LineGrammar(Grammar):
|
||||
rules = [PatternRule(r'data', r'.+')]
|
||||
|
||||
class StringGrammar3(Grammar):
|
||||
rules = [PatternRule(r'data', r'[^)]+')]
|
||||
class DataGrammar(Grammar): rules = [PatternRule('data', r'[^)]+')]
|
||||
class LineGrammar(Grammar): rules = [PatternRule('data', r'.+')]
|
||||
class StringGrammar3(Grammar): rules = [PatternRule('data', r'[^)]+')]
|
||||
|
||||
class ForthGrammar(Grammar):
|
||||
rules = [
|
||||
PatternRule(r'comment', r"\\(?: .*)?\n$"),
|
||||
RegionRule(r'comment', r'\((?= |\n)', DataGrammar, r'\)'),
|
||||
NocaseRegionRule(r'comment', r'0 \[if\]', DataGrammar, r'\[(?:endif|then)\]'),
|
||||
RegionRule(r'string', r'[.cs]" ', StringGrammar2, r'"'),
|
||||
RegionRule(r'string', r'[.s]\\" ', StringGrammar2, r'"'),
|
||||
RegionRule(r'string', r'\.\( ', StringGrammar3, r'\)'),
|
||||
PatternRule('comment', r"\\(?: .*)?\n$"),
|
||||
RegionRule('comment', r'\((?= |\n)', DataGrammar, r'\)'),
|
||||
NocaseRegionRule('comment', r'0 \[if\]', DataGrammar, r'\[(?:endif|then)\]'),
|
||||
RegionRule('string', r'[.cs]" ', StringGrammar2, r'"'),
|
||||
RegionRule('string', r'[.s]\\" ', StringGrammar2, r'"'),
|
||||
RegionRule('string', r'\.\( ', StringGrammar3, r'\)'),
|
||||
|
||||
# builtin
|
||||
NocasePatternRule(r'builtin', r'(?:true|false|on|off)(?= |\n|$)'),
|
||||
NocasePatternRule('builtin', r'(?:true|false|on|off)(?= |\n|$)'),
|
||||
|
||||
# mathn
|
||||
NocasePatternRule(r'keyword', r'(?:\+|-|\*/mod|\*/|\*|/mod|/|mod|negate|abs|min|max|and|or|xor|not|lshift|rshift|invert|2\*|2/|2\+|2-|1\+|1-|8\*|under\+|m\+|m\*/|m\*|um/mod|um\*|fm/mod|sm/rem|d\+|d-|dnegate|dabs|dmin|dmax|d2\*|d2/|f\+|f-|f\*\*|f\*|f/|fnegate|fabs|fmax|fmin|floor|fround|fsqrt|fexpm1|fexp|flnp1|fln|flog|falog|fsincos|fsinh|fsin|fcosh|fcos|ftanh|ftan|fasinh|fasin|facosh|facos|fatan2|fatanh|fatan|f2\*|f2/|1/f|f~rel|f~abs|f~|0<>|0<=|0<|0=|0>=|0>|<>|<=|<|>=|>|=|u<=|u<|u>=|u>|d0<=|d0<>|d0<|d0=|d0>=|d0>|d<=|d<>|d<|d=|d>=|d>|du<=|du<|du>=|du>|within|\?negate|\?dnegate)(?= |\n|$)'),
|
||||
NocasePatternRule('keyword', r'(?:\+|-|\*/mod|\*/|\*|/mod|/|mod|negate|abs|min|max|and|or|xor|not|lshift|rshift|invert|2\*|2/|2\+|2-|1\+|1-|8\*|under\+|m\+|m\*/|m\*|um/mod|um\*|fm/mod|sm/rem|d\+|d-|dnegate|dabs|dmin|dmax|d2\*|d2/|f\+|f-|f\*\*|f\*|f/|fnegate|fabs|fmax|fmin|floor|fround|fsqrt|fexpm1|fexp|flnp1|fln|flog|falog|fsincos|fsinh|fsin|fcosh|fcos|ftanh|ftan|fasinh|fasin|facosh|facos|fatan2|fatanh|fatan|f2\*|f2/|1/f|f~rel|f~abs|f~|0<>|0<=|0<|0=|0>=|0>|<>|<=|<|>=|>|=|u<=|u<|u>=|u>|d0<=|d0<>|d0<|d0=|d0>=|d0>|d<=|d<>|d<|d=|d>=|d>|du<=|du<|du>=|du>|within|\?negate|\?dnegate)(?= |\n|$)'),
|
||||
# stack
|
||||
NocasePatternRule(r'keyword', r'(?:drop|nip|dup|over|tuck|swap|rot|-rot|\?dup|pick|roll|2drop|2nip|2dup|2over|2tuck|2swap|2rot|2-rot|3dup|4dup|5dup|3drop|4drop|5drop|8drop|4swap|4rot|4-rot|4tuck|8swap|8dup|>r|r>|r@|rdrop|2>r|2r>|2r@|2rdrop|4>r|4r>|4r@|4rdrop|fdrop|fnip|fdup|fover|ftuck|fswap|frot)(?= |\n|$)'),
|
||||
NocasePatternRule('keyword', r'(?:drop|nip|dup|over|tuck|swap|rot|-rot|\?dup|pick|roll|2drop|2nip|2dup|2over|2tuck|2swap|2rot|2-rot|3dup|4dup|5dup|3drop|4drop|5drop|8drop|4swap|4rot|4-rot|4tuck|8swap|8dup|>r|r>|r@|rdrop|2>r|2r>|2r@|2rdrop|4>r|4r>|4r@|4rdrop|fdrop|fnip|fdup|fover|ftuck|fswap|frot)(?= |\n|$)'),
|
||||
# pointer
|
||||
NocasePatternRule(r'keyword', r'(?:forthsp|sp@|sp!|fp@|fp!|rp@|rp!|lp@|lp!)(?= |\n|$)'),
|
||||
NocasePatternRule('keyword', r'(?:forthsp|sp@|sp!|fp@|fp!|rp@|rp!|lp@|lp!)(?= |\n|$)'),
|
||||
# address
|
||||
NocasePatternRule(r'keyword', r'(?:@|!|\+!|c@|c!|2@|2!|f@|f!|sf@|sf!|df@|df!|chars|char\+|cells|cell\+|cell|align|aligned|floats|float\+|float|faligned|falign|sfloats|sfloat\+|sfaligned|sfalign|dfloats|dfloat\+|dfaligned|dfalign|maxaligned|maxalign|cfaligned|cfalign|address-unit-bits|allot|allocate|here|move|erase|cmove>|cmove|fill|blank)(?= |\n|$)'),
|
||||
NocasePatternRule('keyword', r'(?:@|!|\+!|c@|c!|2@|2!|f@|f!|sf@|sf!|df@|df!|chars|char\+|cells|cell\+|cell|align|aligned|floats|float\+|float|faligned|falign|sfloats|sfloat\+|sfaligned|sfalign|dfloats|dfloat\+|dfaligned|dfalign|maxaligned|maxalign|cfaligned|cfalign|address-unit-bits|allot|allocate|here|move|erase|cmove>|cmove|fill|blank)(?= |\n|$)'),
|
||||
# conditional (*)
|
||||
NocasePatternRule(r'builtin', r'(?:if|else|endif|then|case|of|endof|endcase|\?dup-if|\?dup-0=-if|ahead|cs-pick|cs-roll|catch|throw|within)(?= |\n|$)'),
|
||||
NocasePatternRule('builtin', r'(?:if|else|endif|then|case|of|endof|endcase|\?dup-if|\?dup-0=-if|ahead|cs-pick|cs-roll|catch|throw|within)(?= |\n|$)'),
|
||||
# iter (*)
|
||||
NocasePatternRule(r'builtin', r'(?:begin|while|repeat|until|again|\?do|loop|i|j|k|\+do|u\+do|u-do|-do|do|\+loop|-loop|unloop|leave|\?leave|exit|done|for|next)(?= |\n|$)'),
|
||||
NocasePatternRule('builtin', r'(?:begin|while|repeat|until|again|\?do|loop|i|j|k|\+do|u\+do|u-do|-do|do|\+loop|-loop|unloop|leave|\?leave|exit|done|for|next)(?= |\n|$)'),
|
||||
|
||||
# define
|
||||
NocasePatternRule(r'builtin', r'(?:constant|2constant|fconstant|variable|2variable|fvariable|create|user|to|defer|is|does>|immediate|compile-only|compile|restrict|interpret|postpone|execute|literal|create-interpret/compile|interpretation>|<interpretation|compilation>|<compilation|\]|lastxt|comp\'|postpone|find-name|name>int|name\?int|name>comp|name>string|state|c;|cvariable|,|2,|f,|c,|\[(?:ifdef|ifundef|then|endif|then|else|\?do|do|loop|\+loop|next|begin|until|again|while|repeat|comp\'|\'|compile)\])(?= |\n|$)'),
|
||||
NocasePatternRule('builtin', r'(?:constant|2constant|fconstant|variable|2variable|fvariable|create|user|to|defer|is|does>|immediate|compile-only|compile|restrict|interpret|postpone|execute|literal|create-interpret/compile|interpretation>|<interpretation|compilation>|<compilation|\]|lastxt|comp\'|postpone|find-name|name>int|name\?int|name>comp|name>string|state|c;|cvariable|,|2,|f,|c,|\[(?:ifdef|ifundef|then|endif|then|else|\?do|do|loop|\+loop|next|begin|until|again|while|repeat|comp\'|\'|compile)\])(?= |\n|$)'),
|
||||
|
||||
# assembly (*)
|
||||
NocasePatternRule(r'builtin', r'(?:assembler|code|end-code|;code|flush-icache|c,)(?= |\n|$)'),
|
||||
NocasePatternRule('builtin', r'(?:assembler|code|end-code|;code|flush-icache|c,)(?= |\n|$)'),
|
||||
|
||||
# xyz
|
||||
NocasePatternMatchRule(r'x', r'(:)( +)([^ ]+)', r'delimiter', r'spaces',
|
||||
r'function'),
|
||||
PatternRule(r'delimiter', r"[:;\[\]]"),
|
||||
NocasePatternRule(r'number', r"'[a-z](?= |$)"),
|
||||
NocasePatternRule(r'number', r'%?-?[0-1]+\.?(?= |$)'),
|
||||
NocasePatternRule(r'number', r'[&#]?-?[0-9]+\.?(?= |$)'),
|
||||
NocasePatternRule(r'number', r"(?:0x|\$)[0-9a-f]+\.?(?= |$)"),
|
||||
NocasePatternRule(r'number', r'[+-]?[0-9]+\.?e?[+-][0-9]+(?= |$)'),
|
||||
PatternRule(r'forth_word', r'[^ ]+'),
|
||||
PatternRule(r'spaces', r' +'),
|
||||
PatternRule(r'eol', r'\n'),
|
||||
NocasePatternMatchRule('x', r'(:)( +)([^ ]+)', r'delimiter', r'spaces', r'function'),
|
||||
PatternRule('delimiter', r"[:;\[\]]"),
|
||||
NocasePatternRule('number', r"'[a-z](?= |$)"),
|
||||
NocasePatternRule('number', r'%?-?[0-1]+\.?(?= |$)'),
|
||||
NocasePatternRule('number', r'[&#]?-?[0-9]+\.?(?= |$)'),
|
||||
NocasePatternRule('number', r"(?:0x|\$)[0-9a-f]+\.?(?= |$)"),
|
||||
NocasePatternRule('number', r'[+-]?[0-9]+\.?e?[+-][0-9]+(?= |$)'),
|
||||
PatternRule('forth_word', r'[^ ]+'),
|
||||
PatternRule('spaces', r' +'),
|
||||
PatternRule('eol', r'\n'),
|
||||
]
|
||||
|
||||
class GforthStart(Interact):
|
||||
|
@ -77,15 +72,14 @@ class GforthLoadFile(Interact):
|
|||
|
||||
class CodePipeGrammar(Grammar):
|
||||
rules = [
|
||||
PatternRule(r'comment', r"\\(?: .*)?\n$"),
|
||||
PatternRule(r'addr', r'\$[0-9A-F]+'),
|
||||
PatternRule(r'addr2', r'\[[a-z]+\]'),
|
||||
PatternRule('comment', r"\\(?: .*)?\n$"),
|
||||
PatternRule('addr', r'\$[0-9A-F]+'),
|
||||
PatternRule('addr2', r'\[[a-z]+\]'),
|
||||
]
|
||||
|
||||
br = RegionRule('banner', r'^Gforth \d+\.\d+\.\d+', LineGrammar, r"^Type `bye' to exit\n$")
|
||||
class ForthPipeGrammar(Grammar):
|
||||
rules = list(ForthGrammar.rules)
|
||||
br = RegionRule(r'banner', r'^Gforth \d+\.\d+\.\d+', LineGrammar, r"^Type `bye' to exit\n$")
|
||||
ForthPipeGrammar.rules.insert(0, br)
|
||||
rules = [br] + ForthGrammar.rules
|
||||
|
||||
class ForthPipe(Pipe):
|
||||
name = 'forthpipe'
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import commands, os.path, string, sys, traceback
|
||||
import color, completer, default, mode, method, regex, tab
|
||||
import buffer.emul
|
||||
import window
|
||||
from point import Point
|
||||
import os.path
|
||||
from method.shell import Interact
|
||||
from mode import Fundamental
|
||||
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule, NocasePatternRule
|
||||
from tab import Tabber
|
||||
|
||||
class CommentGrammar(Grammar): pass
|
||||
CommentGrammar.rules = [
|
||||
|
@ -41,27 +40,26 @@ class HaskellGrammar(Grammar):
|
|||
PatternRule(r'operator', r'@|!|>@>|>>=|>>|=>|::|->|;|<-|\\\\|\.\.|!!|:|\+\+|\||\.|\\|>=|>|/=|==|<=|<|\|\||&&|\^\^|\*\*|##|\^|/|\*|-|\+|='),
|
||||
]
|
||||
|
||||
class HugsStart(method.shell.Interact):
|
||||
class HugsStart(Interact):
|
||||
args = []
|
||||
def _execute(self, w, **vargs):
|
||||
method.shell.Interact._execute(self, w, bname='*Hugs*', cmd='hugs')
|
||||
class HugsLoadFile(method.shell.Interact):
|
||||
Interact._execute(self, w, bname='*Hugs*', cmd='hugs')
|
||||
class HugsLoadFile(Interact):
|
||||
args = []
|
||||
def _execute(self, w, **vargs):
|
||||
method.shell.Interact._execute(self, w, bname='*Hugs*', cmd='hugs')
|
||||
Interact._execute(self, w, bname='*Hugs*', cmd='hugs')
|
||||
b = w.application.get_buffer_by_name('*Hugs*')
|
||||
path = os.path.realpath(w.buffer.path)
|
||||
b.pipe_write(':load "%s"\n' % path)
|
||||
|
||||
class HaskellTabber(tab.Tabber):
|
||||
class HaskellTabber(Tabber):
|
||||
pass
|
||||
|
||||
class Haskell(mode.Fundamental):
|
||||
class Haskell(Fundamental):
|
||||
name = 'Haskell'
|
||||
extensions = ['.hs']
|
||||
tabwidth = 4
|
||||
commentc = '--'
|
||||
#tabbercls = mode.lisp.LispTabber
|
||||
grammar = HaskellGrammar
|
||||
opentokens = ('delimiter',)
|
||||
opentags = {'(': ')', '{': '}', '[': ']'}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import re, string, struct
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
import color, mode
|
||||
import color
|
||||
from mode import Fundamental
|
||||
from lex import Grammar, PatternRule, RegionRule
|
||||
from method import Method, Argument
|
||||
from method.move import GotoBeginning, GotoEnd
|
||||
|
@ -216,7 +217,7 @@ class ShowAddress(Method):
|
|||
addr = w.buffer.get_address(cy, ix)
|
||||
w.set_error("Cursor's address is 0x%08x" % addr)
|
||||
|
||||
class Hex(mode.Fundamental):
|
||||
class Hex(Fundamental):
|
||||
name = 'Hex'
|
||||
config = {
|
||||
'hex.disinst': 'disinst',
|
||||
|
@ -249,7 +250,7 @@ class Hex(mode.Fundamental):
|
|||
format = "%(flag)s %(bname)-18s (%(mname)s) {%(symbolic)s} %(cursor)s %(perc)s"
|
||||
|
||||
def get_status_names(self):
|
||||
names = mode.Fundamental.get_status_names(self)
|
||||
names = Fundamental.get_status_names(self)
|
||||
if self.symbolic_edit:
|
||||
names['symbolic'] = 'symbolic'
|
||||
else:
|
||||
|
@ -271,7 +272,7 @@ class Hex(mode.Fundamental):
|
|||
return [[lo(s0), hi(s1), lo(s2), lo(s3)]]
|
||||
|
||||
def __init__(self, w):
|
||||
mode.Fundamental.__init__(self, w)
|
||||
Fundamental.__init__(self, w)
|
||||
self.bindings = {}
|
||||
|
||||
self.lmargin = 12
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import os, urllib
|
||||
import color, default, method, mode
|
||||
import os
|
||||
import urllib
|
||||
import default
|
||||
import method
|
||||
from mode import Fundamental
|
||||
from lex import Grammar, PatternRule, RegionRule
|
||||
from mode.xml import TagGrammar
|
||||
from mode.javascript import JavascriptGrammar
|
||||
|
@ -72,7 +75,7 @@ class HtmlCheckSpelling(method.Method):
|
|||
if w.buffer.changed_on_disk():
|
||||
w.buffer.reload()
|
||||
|
||||
class HTML(mode.Fundamental):
|
||||
class HTML(Fundamental):
|
||||
name = 'HTML'
|
||||
extensions = ['.html', '.htm', '.shtml', '.shtm', '.xhtml']
|
||||
grammar = HTMLGrammar
|
||||
|
|
|
@ -1,35 +1,34 @@
|
|||
import code, re, string, StringIO, sys, traceback
|
||||
import color, completer, lex, method, mode
|
||||
from mode import Fundamental
|
||||
from method import Method
|
||||
from lex import Grammar, PatternRule
|
||||
from mode.python import PythonGrammar
|
||||
from point import Point
|
||||
|
||||
def insert_line(w):
|
||||
s = w.buffer.make_string()
|
||||
w.mode.lines.append(s)
|
||||
w.buffer.set_data('')
|
||||
|
||||
class MiniInsertTab(method.Method):
|
||||
class MiniInsertTab(Method):
|
||||
def _execute(self, w, **vargs):
|
||||
w.insert_string_at_cursor(' ' * w.mode.tabwidth)
|
||||
class MiniInsertLine(method.Method):
|
||||
class MiniInsertLine(Method):
|
||||
def _execute(self, w, **vargs):
|
||||
insert_line(w)
|
||||
class MiniInsertComplete(method.Method):
|
||||
class MiniInsertComplete(Method):
|
||||
def execute(self, w, **vargs):
|
||||
insert_line(w)
|
||||
w.buffer.callback('\n'.join(w.mode.lines))
|
||||
w.application.close_mini_buffer()
|
||||
class MiniInsertCancel(method.Method):
|
||||
class MiniInsertCancel(Method):
|
||||
def execute(self, w, **vargs):
|
||||
w.application.close_mini_buffer()
|
||||
|
||||
class InsertMini(mode.Fundamental):
|
||||
class InsertMini(Fundamental):
|
||||
name = 'InsertMini'
|
||||
actions = [MiniInsertLine, MiniInsertComplete, MiniInsertCancel,
|
||||
MiniInsertTab]
|
||||
def __init__(self, w):
|
||||
mode.Fundamental.__init__(self, w)
|
||||
Fundamental.__init__(self, w)
|
||||
self.bindings = {}
|
||||
self.saved_input = ""
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import color, mode
|
||||
from mode import Fundamental
|
||||
from lex import Grammar, PatternRule, RegionRule
|
||||
from mode.perl import StringGrammar, PerlGrammar
|
||||
|
||||
|
@ -9,15 +9,15 @@ class IperlGrammar(Grammar):
|
|||
RegionRule(r'iperl_input', r'^(?:>>>|\.\.>)', PerlGrammar, '\n$'),
|
||||
PatternRule(r'iperl_reserved', r'undef'),
|
||||
]
|
||||
class Iperl(mode.Fundamental):
|
||||
class Iperl(Fundamental):
|
||||
name = 'IPerl'
|
||||
grammar = IperlGrammar()
|
||||
colors = {
|
||||
'iperl_input.start': ('red', 'default', 'bold'),
|
||||
'iperl_reserved': ('magenta', 'default', 'bold'),
|
||||
}
|
||||
def __init__(self, w):
|
||||
mode.Fundamental.__init__(self, w)
|
||||
self.add_bindings('iperl-start', ('M-e',))
|
||||
_bindings = {
|
||||
'iperl-start': ('M-e',),
|
||||
}
|
||||
|
||||
install = Iperl.install
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import code, re, string, StringIO, sys, traceback
|
||||
import buffer, color, completer, lex, method, mode, mode.mini, mode.consolemini, window
|
||||
import re, string
|
||||
import buffer, completer, mode.mini, mode.consolemini
|
||||
from window import Window
|
||||
from method import Method
|
||||
from mode import Fundamental
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
from mode.perl import PerlGrammar
|
||||
from point import Point
|
||||
|
@ -7,7 +10,7 @@ from point import Point
|
|||
PAD = ' '
|
||||
LIMIT = 79
|
||||
|
||||
class IperlExec(method.Method):
|
||||
class IperlExec(Method):
|
||||
def _execute(self, w, **vargs):
|
||||
if w.application.completion_window_is_open():
|
||||
w.application.close_completion_buffer()
|
||||
|
@ -30,7 +33,7 @@ class IperlExec(method.Method):
|
|||
if output:
|
||||
b.insert_string(b.get_buffer_end(), output, force=True)
|
||||
|
||||
class IperlTab(method.Method):
|
||||
class IperlTab(Method):
|
||||
def execute(self, w, **vargs):
|
||||
a = w.application
|
||||
s = w.buffer.make_string()
|
||||
|
@ -54,7 +57,7 @@ class IperlTab(method.Method):
|
|||
w.insert_string_at_cursor(s)
|
||||
mode.mini.use_completion_window(a, s, [word+s for s in candidates])
|
||||
|
||||
class IperlPathStart(method.Method):
|
||||
class IperlPathStart(Method):
|
||||
'''Interactively run perl statements in the context of a buffer'''
|
||||
def _start(self, w, parent, switch=True):
|
||||
a = w.application
|
||||
|
@ -65,7 +68,7 @@ class IperlPathStart(method.Method):
|
|||
if not a.has_buffer_name(name):
|
||||
b = buffer.IperlBuffer(parent, a)
|
||||
a.add_buffer(b)
|
||||
window.Window(b, a)
|
||||
Window(b, a)
|
||||
else:
|
||||
b = a.get_buffer_by_name(name)
|
||||
self.main_buffer = b
|
||||
|
@ -90,7 +93,7 @@ class IperlGotoBeginning(mode.consolemini.ConsoleGotoBeginning):
|
|||
class IperlGotoEnd(mode.consolemini.ConsoleGotoEnd):
|
||||
subbuf = '*IPerl*'
|
||||
|
||||
class IperlMini(mode.Fundamental):
|
||||
class IperlMini(Fundamental):
|
||||
name = 'IperlMini'
|
||||
actions = [IperlExec, IperlTab, IperlStart, IperlPathStart,
|
||||
IperlPageUp, IperlPageDown, IperlGotoBeginning, IperlGotoEnd]
|
||||
|
@ -124,7 +127,7 @@ class IperlMini(mode.Fundamental):
|
|||
return self.window.buffer.method.main_buffer
|
||||
|
||||
def __init__(self, w):
|
||||
mode.Fundamental.__init__(self, w)
|
||||
Fundamental.__init__(self, w)
|
||||
self.history = ['']
|
||||
self.hindex = 0
|
||||
b = self.get_iperl()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import color, mode
|
||||
from mode import Fundamental
|
||||
from lex import Grammar, PatternRule, RegionRule
|
||||
from mode.python import StringGrammar1, StringGrammar2, PythonGrammar
|
||||
|
||||
|
@ -10,15 +10,15 @@ class IpythonGrammar(Grammar):
|
|||
RegionRule(r'ipython_input', r'^(?:>>>|-->)', PythonGrammar, '\n$'),
|
||||
PatternRule(r'ipython_reserved', r'undef'),
|
||||
]
|
||||
class Ipython(mode.Fundamental):
|
||||
class Ipython(Fundamental):
|
||||
name = 'IPython'
|
||||
grammar = IpythonGrammar()
|
||||
colors = {
|
||||
'ipython_input.start': ('red', 'default', 'bold'),
|
||||
'ipython_reserved': ('magenta', 'default', 'bold'),
|
||||
}
|
||||
def __init__(self, w):
|
||||
mode.Fundamental.__init__(self, w)
|
||||
self.add_bindings('ipython-start', ('M-e',))
|
||||
_bindings = {
|
||||
'ipython-start': ('M-e',),
|
||||
}
|
||||
|
||||
install = Ipython.install
|
||||
|
|
66
mode/java.py
66
mode/java.py
|
@ -1,4 +1,4 @@
|
|||
import color, mode, tab
|
||||
import mode, tab
|
||||
import context
|
||||
from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
|
||||
from mode.python import StringGrammar2
|
||||
|
@ -12,27 +12,39 @@ class CommentGrammar(Grammar):
|
|||
PatternRule(r"data", r"(?:[^@*]|\*(?!/))+"),
|
||||
]
|
||||
|
||||
chr1 = '[a-zA-Z_]'
|
||||
chr2 = '[a-zA-Z0-9_]'
|
||||
word1 = chr1 + chr2 + '*'
|
||||
word2 = '(?:' + word1 + r'\.' + ')*' + word1
|
||||
|
||||
class JavaGrammar(Grammar):
|
||||
rules = [
|
||||
PatternRule(r"spaces", r" +"),
|
||||
PatternRule(r'import', r'(?<=import ) *[a-zA-Z0-9_.*]+'),
|
||||
PatternRule(r'package', r'(?<=package ) *[a-zA-Z0-9_.*]+'),
|
||||
PatternMatchRule('x', r'(import)( +)(' + word2 + '(?:\.\*)?)', 'keyword', 'spaces', 'import'),
|
||||
PatternMatchRule('x', r'(package)( +)(' + word2 + ')', 'keyword', 'spaces', 'package'),
|
||||
PatternMatchRule('x', r'(class)( +)(' + word1 + ')', 'keyword', 'spaces', 'java_class'),
|
||||
PatternMatchRule('x', '(new)( +)(' + word2 + ')', 'keyword', 'spaces', 'java_class'),
|
||||
|
||||
RegionRule(r'java_comment', '/\*', CommentGrammar, '\*/'),
|
||||
PatternRule(r'java_comment', r'//.*$'),
|
||||
PatternRule(r'comment', r'//.*$'),
|
||||
|
||||
PatternRule(r'keyword', r"(?:abstract|assert|boolean|break|byte|case|catch|char|class|continue|default|double|do|else|extends|finally|final|float|for|if|implements|import|instanceof|interface|int|long|native|new|package|private|protected|public|return|short|static|switch|super|synchronized|threadsafe|throws|throw|transient|try|void|while)(?![a-zA-Z_])"),
|
||||
PatternRule(r'keyword', r"(?:abstract|assert|break|case|catch|class|continue|default|do|else|extends|finally|final|for|if|implements|import|instanceof|interface|native|new|package|private|protected|public|return|static|switch|super|synchronized|threadsafe|throws|throw|transient|try|while)(?![a-zA-Z_])"),
|
||||
PatternRule(r'java_label', r'[a-zA-Z_][a-zA-Z0-9_]*(?=:)'),
|
||||
|
||||
PatternMatchRule('x', '(' + word2 + ')((?:\[\])?)( +)(' + word1 + ')( *)(\()',
|
||||
'java_type', 'delimiter', 'spaces', 'java_function', 'spaces', 'delimiter'),
|
||||
PatternMatchRule('x', '(' + word2 + ')((?:\[\])?)( +)(' + word1 + ')(?! *\()',
|
||||
'java_type', 'delimiter', 'spaces', 'identifier'),
|
||||
|
||||
PatternRule(r'java_builtin', r"(?:null|true|false|this)"),
|
||||
PatternRule(r'identifier', r"[a-zA-Z_][a-zA-Z0-9_]*"),
|
||||
PatternRule(r"unop", r"\+=|-=|\*=|/=|//=|%=|&=\|\^=|>>=|<<=|\*\*="),
|
||||
PatternRule(r'binop', r"\+|<>|<<|<=|<|-|>>|>=|>|\*\*|&|\*|\||/|\^|==|//|~|!=|%"),
|
||||
PatternRule(r'identifier', word1),
|
||||
PatternRule(r"operator", r"\+=|-=|\*=|/=|//=|%=|&=\|\^=|>>=|<<=|\*\*="),
|
||||
PatternRule(r'operator', r"\+|<>|<<|<=|<|-|>>|>=|>|\*\*|&|\*|\||/|\^|==|//|~|!=|%"),
|
||||
|
||||
PatternRule(r"delimiter", r"->|\.|\(|\)|\[|\]|{|}|@|,|:|`|;|=|\?"),
|
||||
|
||||
PatternRule(r"java_integer", r"(?:0(?![x0-9])|[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?"),
|
||||
PatternRule(r"java_float", r"[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+"),
|
||||
PatternRule(r"integer", r"(?:0(?![x0-9])|[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?"),
|
||||
PatternRule(r"float", r"[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+"),
|
||||
RegionRule(r'string', '"', StringGrammar2, '"'),
|
||||
PatternRule(r'java_char', r"'.'|'\\.'|'\\[0-7]{3}'"),
|
||||
PatternRule(r"eol", r"\n$"),
|
||||
|
@ -44,7 +56,7 @@ CLASS_MATCH = And(Optional(Name('spaces')),
|
|||
Name('spaces'),
|
||||
Match('keyword', 'class'),
|
||||
Name('spaces'),
|
||||
Name('identifier'))
|
||||
Name('java_class'))
|
||||
CLASS_OFFSET = 1
|
||||
METHOD_MATCH = And(Optional(Name('spaces')),
|
||||
Matchs('keyword', ('public', 'protected', 'private')),
|
||||
|
@ -52,7 +64,7 @@ METHOD_MATCH = And(Optional(Name('spaces')),
|
|||
Optional(And(Match('keyword', 'static'), Name('spaces'))),
|
||||
Any(),
|
||||
Name('spaces'),
|
||||
Name('identifier'),
|
||||
Name('java_function'),
|
||||
Optional(Name('spaces')),
|
||||
Match('delimiter', '('))
|
||||
METHOD_OFFSET = 2
|
||||
|
@ -69,10 +81,8 @@ class JavaTabber2(tab.StackTabber2):
|
|||
'java_comment.end': 1}
|
||||
start_free_tokens = {'string.start': 'string.end'}
|
||||
end_free_tokens = {'string.end': 'string.start'}
|
||||
def is_base(self, y):
|
||||
return y == 0
|
||||
def _is_indent(self, t):
|
||||
return t.name == 'spaces'
|
||||
def is_base(self, y): return y == 0
|
||||
def _is_indent(self, t): return t.name == 'spaces'
|
||||
def _is_ignored(self, t):
|
||||
return t.fqname() in ('spaces', 'eol', 'comment', 'comment.start',
|
||||
'comment.data', 'comment.null', 'comment.end')
|
||||
|
@ -134,27 +144,31 @@ class Java(mode.Fundamental):
|
|||
'java_comment.data': ('red', 'default', 'bold'),
|
||||
'java_comment.null': ('red', 'default', 'bold'),
|
||||
'import': ('blue', 'default', 'bold'),
|
||||
'java_class': ('green', 'default', 'bold'),
|
||||
'java_label': ('magenta', 'default', 'bold'),
|
||||
'java_builtin': ('magenta', 'default', 'bold'),
|
||||
'java_char': ('green', 'default', 'bold'),
|
||||
'java_integer': ('green', 'default', 'bold'),
|
||||
'java_float': ('green', 'default', 'bold'),
|
||||
'java_function': ('blue', 'default', 'bold'),
|
||||
'java_type': ('magenta', 'default', 'bold'),
|
||||
}
|
||||
|
||||
_bindings = {
|
||||
'close-paren': (')',),
|
||||
'close-brace': ('}',),
|
||||
'close-bracket': (']',),
|
||||
}
|
||||
|
||||
format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(mark)s %(perc)s [%(func)s]"
|
||||
|
||||
def __init__(self, w):
|
||||
mode.Fundamental.__init__(self, w)
|
||||
self.context = JavaContext(self)
|
||||
|
||||
def get_status_names(self):
|
||||
names = mode.Fundamental.get_status_names(self)
|
||||
c = self.window.logical_cursor()
|
||||
names['func'] = self.get_line_function(c.y)
|
||||
return names
|
||||
|
||||
def __init__(self, w):
|
||||
mode.Fundamental.__init__(self, w)
|
||||
self.add_bindings('close-paren', (')',))
|
||||
self.add_bindings('close-brace', ('}',))
|
||||
self.add_bindings('close-bracket', (']',))
|
||||
self.context = JavaContext(self)
|
||||
|
||||
def get_functions(self):
|
||||
return self.context.get_names()
|
||||
def get_function_names(self):
|
||||
|
|
|
@ -24,32 +24,36 @@ class RegexGrammar(Grammar):
|
|||
PatternRule(r'data', r'[^/\\]+'),
|
||||
]
|
||||
|
||||
chr1 = '[a-zA-Z_]'
|
||||
chr2 = '[a-zA-Z_0-9]'
|
||||
word = chr1 + chr2 + '*'
|
||||
|
||||
class JavascriptGrammar(Grammar):
|
||||
rules = [
|
||||
PatternRule(r'comment', r'//.*$'),
|
||||
RegionRule(r'comment', '/\*', Grammar, '\*/'),
|
||||
PatternRule(r'continuation', r'\\(?= *$)'),
|
||||
|
||||
PatternMatchRule(r'x', r'(function)( +)([a-zA-Z_][a-zA-Z0-9_]*)', 'js_reserved', r'spaces', r'js_function'),
|
||||
PatternMatchRule(r'x', r'(class|new)( +)([a-zA-Z_][a-zA-Z0-9_]*)', 'js_reserved', r'spaces', r'js_class'),
|
||||
PatternMatchRule(r'x', r'(function)( +)('+word+')', 'js_reserved', r'spaces', r'js_function'),
|
||||
PatternMatchRule(r'x', r'(class|new)( +)('+word+')', 'js_reserved', r'spaces', r'js_class'),
|
||||
|
||||
PatternRule(r'js_reserved', r'(?:abstract|as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|get|goto|if|import|implements|include|instanceof|interface|in|is|namespace|native|new|null|package|private|protected|public|return|set|super|switch|synchronized|this|throws|throw|transient|true|try|typeof|use|var|void|volatile|while|with)(?![a-zA-Z0-9_])'),
|
||||
PatternRule(r'js_reserved', r'(?:abstract|as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|get|goto|if|import|implements|include|instanceof|interface|in|is|namespace|native|new|null|package|private|protected|public|return|set|super|switch|synchronized|this|throws|throw|transient|true|try|typeof|use|var|void|volatile|while|with)(?!'+chr2+')'),
|
||||
|
||||
PatternRule(r'identifier', r"[a-zA-Z_][a-zA-Z0-9_]*"),
|
||||
PatternRule(r'identifier', word),
|
||||
PatternRule(r'integer', r"(?:0|[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?"),
|
||||
PatternRule(r'float', r"[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+"),
|
||||
|
||||
PatternRule(r'eol', r'\n'),
|
||||
PatternRule(r'spaces', r' +'),
|
||||
PatternRule(r'delimiter', r'%=|&&=|&=|\(|\)|\*=|\+=|,|-=|\.{3}|\.|/=(?= |$)|::|:|;|<<=|>>=|>>>=|\?|\[|\]|^=|^^=|\{|\}|\|=|\|\|='),
|
||||
|
||||
# fucking javascript!
|
||||
# their lexer grammar requires one-token look-behind in order to know
|
||||
# whether a "/" starts a literal regex, or is part of a mathematical
|
||||
# expression/assignment. so for now we will require either a space or $
|
||||
# after / in order to *not* treat it as a regex. dammit!
|
||||
PatternRule(r'eol', r'\n'),
|
||||
PatternRule(r'spaces', r' +'),
|
||||
PatternRule(r'delimiter', r'%=|&&=|&=|\(|\)|\*=|\+=|,|-=|\.{3}|\.|/=(?= |$)|::|:|;|<<=|>>=|>>>=|\?|\[|\]|^=|^^=|\{|\}|\|=|\|\|='),
|
||||
PatternRule(r'operator', r'!==|!=|!|%|&&|&|\*|\+\+|\+|--|-|/(?= |$)|<<=|<<|<=|<|===|==|=|>>>=|>>>|>>=|>>|>=|>|\\|\|\|'),
|
||||
# expression/assignment.
|
||||
RegionRule('js_regex', "(?<=[\(=:,]) */", RegexGrammar, "/[a-z]*"),
|
||||
PatternRule(r'operator', r'!==|!=|!|%|&&|&|\*|\+\+|\+|--|-|/|<<=|<<|<=|<|===|==|=|>>>=|>>>|>>=|>>|>=|>|\\|\|\|'),
|
||||
|
||||
RegionRule('js_regex', "/", RegexGrammar, "/[a-z]*"),
|
||||
RegionRule('string', "'", StringGrammar1, "'"),
|
||||
RegionRule('string', '"', StringGrammar2, '"'),
|
||||
]
|
||||
|
@ -60,7 +64,7 @@ class JavascriptTabber2(tab.StackTabber2):
|
|||
control_tokens = {'keyword': {'if': 1, 'else': 1, 'while': 1, 'do': 1, 'for': 1}}
|
||||
end_at_eof = False
|
||||
end_at_tokens = {'delimiter': {';': 1}}
|
||||
nocontinue_tokens = {'delimiter': {';': 1},
|
||||
nocontinue_tokens = {'delimiter': {';': 1, ',': 1},
|
||||
'comment': 1,
|
||||
'comment.start': 1,
|
||||
'comment.data': 1,
|
||||
|
@ -68,11 +72,9 @@ class JavascriptTabber2(tab.StackTabber2):
|
|||
start_free_tokens = {'string.start': 'string.end'}
|
||||
end_free_tokens = {'string.end': 'string.start'}
|
||||
def is_base(self, y):
|
||||
if y == 0:
|
||||
return True
|
||||
if y == 0: return True
|
||||
highlighter = self.mode.window.buffer.highlights[self.mode.name]
|
||||
if not highlighter.tokens[y]:
|
||||
return False
|
||||
if not highlighter.tokens[y]: return False
|
||||
t = highlighter.tokens[y][0]
|
||||
return t.name == 'js_reserved' and t.string == 'function'
|
||||
def _is_indent(self, t):
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
import commands, curses, os, sys
|
||||
import color, method, mode
|
||||
import os
|
||||
import sys
|
||||
from mode import Fundamental
|
||||
from method import Method
|
||||
from lex import Grammar, PatternRule, RegionRule
|
||||
from mode.text import TextInsertSpace
|
||||
|
||||
class ArgumentGrammar(Grammar):
|
||||
rules = [PatternRule(r'data', r'[^}]+')]
|
||||
class StringGrammar1(Grammar):
|
||||
rules = [PatternRule(r'data', r"[^']+")]
|
||||
class StringGrammar2(Grammar):
|
||||
rules = [PatternRule(r'data', r"(?:[^']|'(?!'))+")]
|
||||
class ArgumentGrammar(Grammar): rules = [PatternRule(r'data', r'[^}]+')]
|
||||
class StringGrammar1(Grammar): rules = [PatternRule(r'data', r"[^']+")]
|
||||
class StringGrammar2(Grammar): rules = [PatternRule(r'data', r"(?:[^']|'(?!'))+")]
|
||||
|
||||
class LatexGrammar(Grammar):
|
||||
rules = [
|
||||
|
@ -23,7 +22,7 @@ class LatexGrammar(Grammar):
|
|||
PatternRule(r'data', r'[^{}$^_%~#&%\\`]+'),
|
||||
]
|
||||
|
||||
class LatexBuild(method.Method):
|
||||
class LatexBuild(Method):
|
||||
'''Insert a pair of LaTeX-style single-quotes into the buffer'''
|
||||
def _getcmd(self, w):
|
||||
return w.application.config.get('latex.buildcmd')
|
||||
|
@ -78,23 +77,18 @@ class LatexViewPdf(LatexBuildPdf):
|
|||
pdfpath = self._modpath(w, '.pdf')
|
||||
os.execvp(viewcmd, (viewcmd, pdfpath))
|
||||
|
||||
#class LatexCommentRegion(method.CommentRegion):
|
||||
# commentc = '%'
|
||||
#class LatexUncommentRegion(method.UncommentRegion):
|
||||
# commentc = '%'
|
||||
|
||||
class LatexInsertSquotes(method.Method):
|
||||
class LatexInsertSquotes(Method):
|
||||
'''Insert a pair of LaTeX-style single-quotes into the buffer'''
|
||||
def _execute(self, w, **vargs):
|
||||
w.insert_string_at_cursor("`'")
|
||||
w.backward()
|
||||
class LatexInsertDquotes(method.Method):
|
||||
class LatexInsertDquotes(Method):
|
||||
'''Insert a pair of LaTeX-style double-quotes into the buffer'''
|
||||
def _execute(self, w, **vargs):
|
||||
w.insert_string_at_cursor("``''")
|
||||
w.backward()
|
||||
w.backward()
|
||||
class LatexInsertBraces(method.Method):
|
||||
class LatexInsertBraces(Method):
|
||||
'''Insert a pair of curly braces into the buffer'''
|
||||
def _execute(self, w, **vargs):
|
||||
w.insert_string_at_cursor("{}")
|
||||
|
@ -103,7 +97,7 @@ class LatexInsertBraces(method.Method):
|
|||
class LatexInsertSpace(TextInsertSpace):
|
||||
pass
|
||||
|
||||
class LatexCheckSpelling(method.Method):
|
||||
class LatexCheckSpelling(Method):
|
||||
"""Check the spelling of the document via ispell -t"""
|
||||
def _execute(self, w, **vargs):
|
||||
# -x no backup file
|
||||
|
@ -113,7 +107,7 @@ class LatexCheckSpelling(method.Method):
|
|||
if w.buffer.changed_on_disk():
|
||||
w.buffer.reload()
|
||||
|
||||
class Latex(mode.Fundamental):
|
||||
class Latex(Fundamental):
|
||||
name = 'Latex'
|
||||
extensions = ['.latex', '.tex']
|
||||
commentc = '%'
|
||||
|
|
21
mode/lua.py
21
mode/lua.py
|
@ -1,8 +1,13 @@
|
|||
import commands
|
||||
import color, mode, method, tab
|
||||
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
|
||||
from method import Method
|
||||
from mode import Fundamental
|
||||
from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
|
||||
from mode.python import StringGrammar1, StringGrammar2
|
||||
|
||||
chr1 = '[a-zA-Z_]'
|
||||
chr2 = '[a-zA-Z_0-9]'
|
||||
word = chr1 + chr2 + '*'
|
||||
|
||||
class LuaGrammar(Grammar):
|
||||
rules = [
|
||||
PatternRule(r'comment', r'--.*$'),
|
||||
|
@ -12,11 +17,9 @@ class LuaGrammar(Grammar):
|
|||
RegionRule(r'string', r"'", StringGrammar1, r"'"),
|
||||
RegionRule(r'string', r'"', StringGrammar2, r'"'),
|
||||
|
||||
PatternRule(r'keyword', r'(?:while|until|true|then|return|repeat|or|not|nil|local|in|if|function|for|false|end|elseif|else|do|break|and)(?![a-zA-Z0-9_])'),
|
||||
#PatternRule(r'function', r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\()'),
|
||||
PatternRule(r'function', r'(?<=function )[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||
#PatternRule(r'identifier', r'[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||
PatternRule(r'lua_identifier', r'[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||
PatternRule(r'keyword', r'(?:while|until|true|then|return|repeat|or|not|nil|local|in|if|function|for|false|end|elseif|else|do|break|and)(?!'+chr2+')'),
|
||||
PatternMatchRule('x', '(function)( +)('+word+')', 'keyword', 'spaces', 'function'),
|
||||
PatternRule(r'lua_identifier', word),
|
||||
|
||||
PatternRule(r'delimiter', r'(?:[=(){}\[\];:,.])'),
|
||||
PatternRule(r'operator', r'(?:\.\.\.|\.\.|==|~=|<=|>=|<|>)'),
|
||||
|
@ -25,7 +28,7 @@ class LuaGrammar(Grammar):
|
|||
PatternRule(r"float", r"(?<![\.0-9a-zA-Z_])(?:-?[0-9]+\.[0-9]*|-?\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|-?\.[0-9]+)[eE][\+-]?[0-9]+)(?![\.0-9a-zA-Z_])"),
|
||||
]
|
||||
|
||||
class LuaCheckSyntax(method.Method):
|
||||
class LuaCheckSyntax(Method):
|
||||
'''Check the syntax of a lua file'''
|
||||
def _execute(self, w, **vargs):
|
||||
app = w.application
|
||||
|
@ -37,7 +40,7 @@ class LuaCheckSyntax(method.Method):
|
|||
else:
|
||||
app.data_buffer("*Lua-Check-Syntax*", output)
|
||||
|
||||
class Lua(mode.Fundamental):
|
||||
class Lua(Fundamental):
|
||||
name = 'Lua'
|
||||
extensions = ['.lua']
|
||||
#tabbercls = mode.lisp.LispTabber
|
||||
|
|
11
mode/mbox.py
11
mode/mbox.py
|
@ -1,5 +1,6 @@
|
|||
import commands, dirutil, grp, mailbox, method, mode, os.path, pwd, re, sys
|
||||
import mailbox, os.path, re, sys
|
||||
import buffer, default, window
|
||||
from mode import Fundamental
|
||||
from mode.mutt import MuttGrammar
|
||||
from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
|
||||
from point import Point
|
||||
|
@ -200,7 +201,7 @@ class MailListGrammar(Grammar):
|
|||
),
|
||||
]
|
||||
|
||||
class MboxMsg(mode.Fundamental):
|
||||
class MboxMsg(Fundamental):
|
||||
name = 'MboxMsg'
|
||||
colors = {
|
||||
'mail_pgp': ('red', 'default', 'bold'),
|
||||
|
@ -218,9 +219,9 @@ class MboxMsg(mode.Fundamental):
|
|||
actions = []
|
||||
grammar = MailMsgGrammar
|
||||
def __init__(self, w):
|
||||
mode.Fundamental.__init__(self, w)
|
||||
Fundamental.__init__(self, w)
|
||||
|
||||
class Mbox(mode.Fundamental):
|
||||
class Mbox(Fundamental):
|
||||
name = 'Mbox'
|
||||
grammar = MailListGrammar
|
||||
actions = [MboxRefresh, MboxOpenPath, MboxReadMsg]
|
||||
|
@ -235,7 +236,7 @@ class Mbox(mode.Fundamental):
|
|||
'subject': ('default', 'default', 'bold'),
|
||||
}
|
||||
def __init__(self, w):
|
||||
mode.Fundamental.__init__(self, w)
|
||||
Fundamental.__init__(self, w)
|
||||
self.add_bindings('mbox-refresh', ('C-c r',))
|
||||
self.add_bindings('mbox-read-msg', ('RETURN',))
|
||||
|
||||
|
|
Loading…
Reference in New Issue