Commit 27899565 authored by Jesse van den Kieboom's avatar Jesse van den Kieboom

fixed parsing default list ( allow escaping the list and allow whitespace

	* plugins/snippets/snippets/Parser.py: fixed parsing default list (
	allow escaping the list and allow whitespace
	* plugins/snippets/data/snippets.lang: fixed regex placeholder
	* plugins/snippets/snippets/Placeholder.py: fixed problem with
	removed snippet being entered (updated)
	
	* plugins/snippets/snippets/Manager.py:
	* plugins/snippets/snippets/Document.py:
	* plugins/snippets/data/snippets.xml:
	* plugins/snippets/data/Makefile.am:
	
	Added snippets to be used in snippets :)

svn path=/trunk/; revision=5749
parent d6207090
2007-07-26 Jesse van den Kieboom <jesse@icecrew.nl>
* plugins/snippets/snippets/Parser.py: fixed parsing default list (
allow escaping the list and allow whitespace
* plugins/snippets/data/snippets.lang: fixed regex placeholder
* plugins/snippets/snippets/Placeholder.py: fixed problem with
removed snippet being entered (updated)
* plugins/snippets/snippets/Manager.py:
* plugins/snippets/snippets/Document.py:
* plugins/snippets/data/snippets.xml:
* plugins/snippets/data/Makefile.am:
Added snippets to be used in snippets :)
2007-07-26 Jesse van den Kieboom <jesse@icecrew.nl>
* plugins/snippets/data/snippets.lang:
......
......@@ -16,6 +16,7 @@ snippets_DATA = \
python.xml \
ruby.xml \
sh.xml \
snippets.xml \
tcl.xml \
xml.xml
......
......@@ -132,15 +132,17 @@
</include>
</context>
<context id="regex-placeholder" style-ref="regex-placeholder">
<match>\${\%{tabstop}?(?:(\%{number})|(\%{environment}))/\%{regex-pattern}/\%{regex-pattern}(?:[/]([a-zA-Z]*))?}</match>
<match>(\${)\%{tabstop}?(?:\s*(?:(\%{number})|(\%{environment})))/\%{regex-pattern}/\%{regex-pattern}(?:[/]([a-zA-Z]*))?(})</match>
<include>
<context sub-pattern="2" style-ref="tabstop"/>
<context sub-pattern="3" style-ref="seperator"/>
<context sub-pattern="4" style-ref="tabstop"/>
<context sub-pattern="5" style-ref="environmental-var"/>
<context sub-pattern="6" style-ref="regex-pattern"/>
<context sub-pattern="7" style-ref="replace-pattern"/>
<context sub-pattern="8" style-ref="modifier"/>
<context sub-pattern="1" style-ref="placeholder-bounds"/>
<context sub-pattern="10" style-ref="placeholder-bounds"/>
<context sub-pattern="3" style-ref="tabstop"/>
<context sub-pattern="4" style-ref="seperator"/>
<context sub-pattern="5" style-ref="tabstop"/>
<context sub-pattern="6" style-ref="environmental-var"/>
<context sub-pattern="7" style-ref="regex-pattern"/>
<context sub-pattern="8" style-ref="replace-pattern"/>
<context sub-pattern="9" style-ref="modifier"/>
</include>
</context>
<context id="environmental-variable" style-ref="environmental-var">
......
<?xml version="1.0" encoding="UTF-8"?>
<snippets language="snippets">
<snippet id="simple">
<text><![CDATA[\${${1:n:default}}]]></text>
<description>Simple Placeholder</description>
<tag>simple</tag>
</snippet>
<snippet id="simple-fallback">
<text><![CDATA[\${${1:n:}[${2:default1,default2}]}]]></text>
<description>Simple Fallback Placeholder</description>
<tag>simplef</tag>
</snippet>
<snippet id="shell">
<text><![CDATA[\$(${1:n:} ${2:shell code})]]></text>
<description>Shell Placeholder</description>
<tag>shell</tag>
</snippet>
<snippet id="python">
<text><![CDATA[\$<${1:n:} ${2:[refs]:} return 'python code' >]]></text>
<description>Python Placeholder</description>
<tag>python</tag>
</snippet>
<snippet id="regex">
<text><![CDATA[\${${1:n:} ${2:input}/${3:regex-pattern}/${4:replacement}/${5:modifiers}}]]></text>
<description>Regular Expression Placeholder</description>
<tag>regex</tag>
</snippet>
<snippet id="$-FILENAME">
<text><![CDATA[\$GEDIT_FILENAME]]></text>
<description>Gedit Filename Variable</description>
<tag>$</tag>
</snippet>
<snippet id="$-BASENAME">
<text><![CDATA[\$GEDIT_BASENAME]]></text>
<description>Gedit Basename Variable</description>
<tag>$</tag>
</snippet>
<snippet id="$-SELECTED_TEXT">
<text><![CDATA[\$GEDIT_SELECTED_TEXT]]></text>
<description>Gedit Selected Text Variable</description>
<tag>$</tag>
</snippet>
<snippet id="$-SELECTED_WORD">
<text><![CDATA[\$GEDIT_SELECTED_WORD]]></text>
<description>Gedit Selected Word Variable</description>
<tag>$</tag>
</snippet>
<snippet id="$-DROP_FILENAME">
<text><![CDATA[\$GEDIT_DROP_FILENAME]]></text>
<description>Gedit Drop Filename Variable</description>
<tag>$</tag>
</snippet>
<snippet id="$-DROP_REL_FILENAME">
<text><![CDATA[\$GEDIT_DROP_REL_FILENAME]]></text>
<description>Gedit Drop Relative Filename Variable</description>
<tag>$</tag>
</snippet>
<snippet id="$-DROP_MIME_TYPE">
<text><![CDATA[\$GEDIT_DROP_MIME_TYPE]]></text>
<description>Gedit Drop Mime Type Variable</description>
<tag>$</tag>
</snippet>
</snippets>
......@@ -140,7 +140,9 @@ class Document:
else:
self.language_id = None
self.instance.language_changed(self)
if self.instance:
self.instance.language_changed(self)
Library().ref(self.language_id)
def accelerator_activate(self, keyval, mod):
......
......@@ -33,6 +33,7 @@ from Helper import *
from Library import *
from Importer import *
from Exporter import *
from Document import Document
class Manager:
NAME_COLUMN = 0
......@@ -52,6 +53,7 @@ class Manager:
self.key_press_id = 0
self._temp_export = None
self.tooltips = gtk.Tooltips()
self.snippets_doc = None
self.run()
def get_language_snippets(self, path, name = None):
......@@ -276,9 +278,9 @@ class Manager:
def custom_handler(self, xml, function_name, widget_name, str1, str2, \
int1 , int2):
if function_name == 'create_source_view':
buf = gsv.Buffer()
buf = gedit.Document()
source_view = gsv.View(buf)
source_view = gedit.View(buf)
source_view.set_auto_indent(True)
source_view.set_insert_spaces_instead_of_tabs(False)
source_view.set_smart_home_end(gsv.SMART_HOME_END_AFTER)
......@@ -290,6 +292,7 @@ class Manager:
if lang:
buf.set_highlight(True)
buf.set_language(lang)
self.snippets_doc = Document(None, source_view)
return source_view
else:
......@@ -601,6 +604,9 @@ class Manager:
shutil.rmtree(os.path.dirname(self._temp_export))
self._temp_export = None
if self.snippets_doc:
self.snippets_doc.stop()
self.unref_languages()
self.snippet = None
self.model = None
......
......@@ -154,13 +154,17 @@ class Parser:
return items
def _parse_default(self, default):
match = re.match('\\s*\\[((\\\\]|[^\\]])+)\\]\\s*', default)
match = re.match('^\\s*(\\\\)?(\\[((\\\\]|[^\\]])+)\\]\\s*)$', default)
if not match:
return [default]
groups = match.groups()
return self._parse_list(groups[0])
if groups[0]:
return [groups[1]]
return self._parse_list(groups[2])
def _match_placeholder(self):
text = self.remains()
......@@ -235,7 +239,7 @@ class Parser:
text = self.remains()
content = '((?:\\\\[/]|\\\\}|[^/}])+)'
match = re.match('\\${(?:(%s):)?(%s|\\$([A-Z_]+))?[/]%s[/]%s(?:[/]([a-zA-Z]*))?}' % (self.SREG_ID, self.SREG_ID, content, content), text)
match = re.match('\\${(?:(%s):)?\\s*(%s|\\$([A-Z_]+))?[/]%s[/]%s(?:[/]([a-zA-Z]*))?}' % (self.SREG_ID, self.SREG_ID, content, content), text)
if not match:
return None
......
......@@ -109,6 +109,9 @@ class Placeholder:
# Do something on beginning this placeholder
def enter(self):
if not self.begin or self.begin.get_deleted():
return
self.buf.move_mark(self.buf.get_insert(), self.begin_iter())
if self.end:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment