all modes have been initially ported

--HG--
branch : pmacs2
This commit is contained in:
moculus 2007-06-25 15:59:44 +00:00
parent 1e9e66adb4
commit ad04ba8b41
4 changed files with 108 additions and 39 deletions

View File

@ -7,12 +7,12 @@ import util, window2
from point2 import Point
# modes
# TODO: mode_sql mode_tt
import mode2
import mode_mini, mode_search, mode_replace, mode_which
import mode_console, mode_consolemini
import mode_blame, mode_diff
import mode_c, mode_python, mode_perl, mode_xml, mode_nasm, mode_sh, mode_javascript, mode_sql
import mode_c, mode_python, mode_perl, mode_nasm, mode_sh, mode_javascript, mode_sql
import mode_xml, mode_tt
import mode_life, mode_text, mode_mutt
def run(buffers, jump_to_line=None, init_mode=None):
@ -101,7 +101,7 @@ class Application(object):
'mutt': mode_mutt.Mutt,
'javascript': mode_javascript.Javascript,
'sql': mode_sql.Sql,
#'template': mode_tt.Template,
'template': mode_tt.Template,
}
# these are used in this order to determine which mode to open certain
@ -130,7 +130,7 @@ class Application(object):
'.htm': 'xml',
'.js': 'javascript',
'.sql': 'sql',
#'.tt': 'template'
'.tt': 'template'
}
self.mode_detection = {
'python': 'python',

67
code_examples/body.tt Normal file
View File

@ -0,0 +1,67 @@
<body class="main" onLoad="TBB.init(); TBB.initMouse();">
<div id="wrapper">
<div id="wrapper-bg">
<div id="header">
<div class="spHeaderText">You are logged in as: <strong>[% logged_in_full_name %]</strong></div>
<img src="/images/tbb/The-Benefit-Bank-logo.gif" alt="The Benefit Bank : Connecting Communities to Resources" />
</div>
<div id="nav-main" class="nav">
[% INCLUDE "links.tt" %]
</div>
<div id="translation">
<form action="/bds" name="fmTranslation" id="fmTranslation" method="POST">
<select name="selected_language" class="translate" onChange="document.getElementById('fmTranslation').submit(this)">
[% FOREACH lang = supported_languages %]
[% IF lang == 'en-US' %]
<option value="en-US"[% IF selected_language == lang %] selected[% END %]>English</option>
[% ELSIF lang == 'es' %]
<option value="es"[% IF selected_language == lang %] selected[% END %]>Espa&ntilde;ol</option>
[% ELSIF lang == 'ht' %]
<option value="ht"[% IF selected_language == lang %] selected[% END %]>Krey&ograve;l Ayisyen</option>
[% END %]
[% END %]
</select>
</form>
</div>
<div id="dvMain">
<div id="dvErrorMessages"> </div>
<form action='[% action %]' method='POST' name="fmBDSMain" onSubmit="return TBB.validateFormBDS(this);">
[% body_html %]
</div>
[%# triggers here %]
<div id="dvMainTextNav" dir="rtl">
[% FOREACH trigger = triggers %]
[% IF trigger.type == 'transition' %]
<input type="image" name="Next" src="/images/tbb/imBtNext.gif" class="np"/>
<img src="/images/tbb/imBtHash.gif"/>
<input type="hidden" name="previous_navigation_button_clicked" value=""/>
[% IF trigger.prolonged %]
<input type="hidden" id="prolonged" value="[% trigger.prolonged %]"/>
[% END %]
[% ELSIF trigger.type == 'backtrack' %]
<input type="image" src="/images/tbb/imBtPrev.gif" name="previous_navigation_button" onClick="this.form.previous_navigation_button_clicked.value = 1;" class="np"/>
[% ELSIF type == 'reset' %]
<div style="margin:12px 10px;"><input type="reset" value="Reset Form" class="rfButton"></div>
[% END %]
[% END %]
</div>
[% FOREACH field IN hidden_fields %]
<input type="hidden" name="[% field.name %]" value="[% field.value %]"/>
[% END %]
</form>
[% INCLUDE body_footer.tt %]
</div>
[% INCLUDE debug_footer.tt %]
</div>
[% INCLUDE glos_help.tt %]
</body>

View File

@ -1,33 +1,42 @@
import sets, sys
import color, commands, default, lex, lex_tt, method, mode, point, regex, tab_xml
import color, mode2
from lex2 import Grammar, PatternRule, RegionRule
class Template(mode.Fundamental):
class TagGrammar(Grammar):
rules = [
RegionRule(name=r'string', start=r'(?P<tag>["\'])', grammar=Grammar(), end=r'%(tag)s'),
PatternRule(name=r'namespace', pattern=r'[a-zA-Z_]+:'),
PatternRule(name=r'attrname', pattern=r'[^ =>\n]+(?==)'),
PatternRule(name=r'name', pattern=r'[^ =>\n]+'),
]
class TemplateGrammar(Grammar):
rules = [
RegionRule(name=r'comment', start=r'<!--', grammar=Grammar(), end=r'-->'),
RegionRule(name=r'template', start=r'\[\%', grammar=Grammar(), end=r'%%\]'),
RegionRule(name=r'opentag', start=r'<', grammar=TagGrammar(), end=r'/?>'),
PatternRule(name=r'closetag', pattern=r'< */ *[ =>\n]+ *>'),
]
class Template(mode2.Fundamental):
grammar = TemplateGrammar
def __init__(self, w):
mode.Fundamental.__init__(self, w)
#self.grammar = lex_xml.XMLGrammar()
self.grammar = lex_tt.TTGrammar()
self.lexer = lex.Lexer(self.grammar)
mode2.Fundamental.__init__(self, w)
self.add_bindings('close-paren', (')',))
self.add_bindings('close-brace', ('}',))
self.add_bindings('close-bracket', (']',))
self.default_color = color.build('default', 'default')
self.colors = {
'template': color.build('magenta', 'default'),
'markup': color.build('red', 'default'),
'namespace': color.build('magenta', 'default'),
'opentag': color.build('blue', 'default'),
'nodevalue': color.build('default', 'default'),
'attrname': color.build('cyan', 'default'),
'attrvalue': color.build('green', 'default'),
'closetag': color.build('blue', 'default'),
'comment': color.build('red', 'default'),
'bizzaro': color.build('magenta', 'green'),
'comment': color.build('red', 'default'),
'template.start': color.build('magenta', 'default'),
'template.null': color.build('magenta', 'default'),
'template.end': color.build('magenta', 'default'),
'opentag.start': color.build('default', 'default'),
'opentag.namespace': color.build('magenta', 'default'),
'opentag.name': color.build('blue', 'default'),
'opentag.attrname': color.build('cyan', 'default'),
'opentag.string.start': color.build('green', 'default'),
'opentag.string.null': color.build('green', 'default'),
'opentag.string.end': color.build('green', 'default'),
'opentag.end': color.build('default', 'default'),
}
self.tabber = tab_xml.XMLTabber(self)
def name(self):
return "Template"

View File

@ -1,5 +1,4 @@
import sets, sys
import color, commands, default, lex2, method, mode, point, regex
import color, mode2
from lex2 import Grammar, ConstantRule, PatternRule, RegionRule, DualRegionRule
class TagGrammar(Grammar):
@ -44,18 +43,13 @@ class XMLGrammar(Grammar):
),
]
class XML(mode.Fundamental):
class XML(mode2.Fundamental):
grammar = XMLGrammar
def __init__(self, w):
mode.Fundamental.__init__(self, w)
self.grammar = XMLGrammar()
self.lexer = lex2.Lexer(self.name(), self.grammar)
mode2.Fundamental.__init__(self, w)
self.add_bindings('close-paren', (')',))
self.add_bindings('close-brace', ('}',))
self.add_bindings('close-bracket', (']',))
self.default_color = color.build('default', 'default')
self.colors = {
'comment': color.build('red', 'default'),
'opentag.start': color.build('default', 'default'),
@ -67,6 +61,5 @@ class XML(mode.Fundamental):
'opentag.string.end': color.build('green', 'default'),
'opentag.end': color.build('default', 'default'),
}
def name(self):
return "XML"