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

New snippets language file

	* plugins/snippets/data/snippets.lang: 
	* plugins/snippets/data/Makefile.am:
	
	New snippets language file
	
	* plugins/snippets/snippets/WindowHelper.py:
	* plugins/snippets/snippets/Manager.py:
	
	Make use of the new snippets language

svn path=/trunk/; revision=5748
parent 1351e6c4
2007-07-26 Jesse van den Kieboom <jesse@icecrew.nl>
* plugins/snippets/data/snippets.lang:
* plugins/snippets/data/Makefile.am:
New snippets language file
* plugins/snippets/snippets/WindowHelper.py:
* plugins/snippets/snippets/Manager.py:
Make use of the new snippets language
2007-07-26 Jesse van den Kieboom <jesse@icecrew.nl>
* plugins/snippets/snippets/Library.py: fixed bug with override not
......
......@@ -21,4 +21,9 @@ snippets_DATA = \
snippetsdir = $(datadir)/gedit-2/plugins/snippets
EXTRA_DIST = $(snippets_DATA)
lang_DATA = \
snippets.lang
langdir = $(datadir)/gtksourceview-2.0/language-specs
EXTRA_DIST = $(snippets_DATA) $(lang_DATA)
<?xml version="1.0"?>
<!--
Author: Jesse van den Kieboom <jesse@icecrew.nl>
Copyright (C) 2007-2008 Jesse van den Kieboom <jesse@icecrew.nl>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
-->
<language id="snippets" _name="Snippets" hidden="true" version="2.0">
<styles>
<style id="placeholder-bounds" _name="Placeholder begin and end" map-to="def:function"/>
<style id="default-value" _name="Default Value" map-to="def:string"/>
<style id="single-placeholder" _name="Single Placeholder" map-to="def:decimal"/>
<style id="shell-placeholder" _name="Shell Placeholder" map-to="def:preprocessor"/>
<style id="python-placeholder" _name="Python Placeholder" map-to="def:preprocessor"/>
<style id="regex-placeholder" _name="Regular Expression Placeholder" map-to="def:preprocessor"/>
<style id="tabstop" _name="Tabstop" map-to="def:decimal"/>
<style id="placeholder-ref" _name="Placeholder Reference" map-to="def:decimal"/>
<style id="placeholder-def" _name="Placeholder Default" map-to="def:string"/>
<style id="escape" _name="Escape" map-to="def:escape"/>
<style id="environmental-var" _name="Environmental Variable" map-to="def:string"/>
<style id="seperator" _name="Seperator" map-to="def:shebang"/>
<style id="regex-pattern" _name="Regular Expression Pattern" map-to="def:string"/>
<style id="replace-pattern" _name="Regular Expression Replace Pattern" map-to="def:string"/>
<style id="modifier" _name="Modifier" map-to="def:keyword"/>
</styles>
<definitions>
<define-regex id="number">[0-9]+</define-regex>
<define-regex id="tabstop">\s*((\%{number})(:))</define-regex>
<define-regex id="number-list" extended="true">\s*(\[(\%{number}(,\%{number})*)\](:))</define-regex>
<define-regex id="environment">\$[A-Z_]+</define-regex>
<define-regex id="regex-pattern">((?:\\[/]|\\}|[^/}])+)</define-regex>
<context id="escape" style-ref="escape">
<match>\\\$</match>
</context>
<context id="single-placeholder" style-ref="single-placeholder">
<match>\$\%{number}|\${\%{number}}</match>
</context>
<context id="simple-placeholder-def" style-ref="default-value">
<start>\${\%{tabstop}</start>
<end>}</end>
<include>
<context sub-pattern="0" style-ref="placeholder-bounds" where="start"/>
<context sub-pattern="0" style-ref="placeholder-bounds" where="end"/>
<context sub-pattern="2" where="start" style-ref="tabstop"/>
<context sub-pattern="3" where="start" style-ref="seperator"/>
<context>
<match>\\}</match>
</context>
<context ref="escape"/>
<context ref="environmental-variable"/>
</include>
</context>
<context id="simple-placeholder">
<include>
<context ref="single-placeholder"/>
<context ref="simple-placeholder-def"/>
</include>
</context>
<context id="shell-placeholder-contents">
<include>
<context ref="escape"/>
<context ref="environmental-variable"/>
<context ref="single-placeholder"/>
</include>
</context>
<context id="shell-placeholder">
<include>
<context style-ref="shell-placeholder">
<start>\$\(\%{tabstop}?</start>
<end>\)</end>
<include>
<context sub-pattern="0" style-ref="placeholder-bounds" where="start"/>
<context sub-pattern="0" style-ref="placeholder-bounds" where="end"/>
<context sub-pattern="2" where="start" style-ref="tabstop"/>
<context sub-pattern="3" where="start" style-ref="seperator"/>
<context ref="shell-placeholder-contents"/>
<context>
<match>\\}</match>
</context>
</include>
</context>
<context style-ref="shell-placeholder">
<start>`\%{tabstop}?</start>
<end>`</end>
<include>
<context sub-pattern="0" style-ref="placeholder-bounds" where="start"/>
<context sub-pattern="0" style-ref="placeholder-bounds" where="end"/>
<context sub-pattern="2" where="start" style-ref="tabstop"/>
<context sub-pattern="3" where="start" style-ref="seperator"/>
<context ref="shell-placeholder-contents"/>
<context>
<match>\\`</match>
</context>
</include>
</context>
</include>
</context>
<context id="python-placeholder">
<start>\$&lt;\%{tabstop}?\%{number-list}?</start>
<end>&gt;</end>
<include>
<context sub-pattern="0" style-ref="placeholder-bounds" where="start"/>
<context sub-pattern="0" style-ref="placeholder-bounds" where="end"/>
<context sub-pattern="2" where="start" style-ref="tabstop"/>
<context sub-pattern="3" where="start" style-ref="seperator"/>
<context sub-pattern="5" where="start" style-ref="tabstop"/>
<context sub-pattern="7" where="start" style-ref="seperator"/>
<context>
<match>\\&gt;</match>
</context>
<context ref="escape"/>
<context ref="environmental-variable"/>
<context ref="single-placeholder"/>
<context ref="python:python"/>
</include>
</context>
<context id="regex-placeholder" style-ref="regex-placeholder">
<match>\${\%{tabstop}?(?:(\%{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"/>
</include>
</context>
<context id="environmental-variable" style-ref="environmental-var">
<match>\%{environment}</match>
</context>
<context id="snippets">
<include>
<context ref="escape"/>
<context ref="regex-placeholder"/>
<context ref="simple-placeholder"/>
<context ref="shell-placeholder"/>
<context ref="python-placeholder"/>
<context ref="environmental-variable"/>
</include>
</context>
</definitions>
</language>
......@@ -117,7 +117,7 @@ class Manager:
self.model = gtk.TreeStore(str, str, object)
self.model.set_sort_column_id(self.SORT_COLUMN, gtk.SORT_ASCENDING)
manager = gedit.get_language_manager()
langs = manager.list_languages()
langs = gedit.language_manager_list_languages_sorted(manager, True)
piter = self.model.append(None, (_('Global'), '', None))
# Add dummy node
......@@ -277,12 +277,19 @@ class Manager:
int1 , int2):
if function_name == 'create_source_view':
buf = gsv.Buffer()
buf.set_highlight(True)
source_view = gsv.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)
source_view.set_tabs_width(4)
manager = gedit.get_language_manager()
lang = manager.get_language_by_id('snippets')
if lang:
buf.set_highlight(True)
buf.set_language(lang)
return source_view
else:
......@@ -321,13 +328,10 @@ class Manager:
entry.connect('focus-out-event', self.on_entry_drop_targets_focus_out)
entry.connect('drag-data-received', self.on_entry_drop_targets_drag_data_received)
#entry.drag_dest_set(gtk.DEST_DEFAULT_ALL, self.dnd_target_list, gtk.gdk.ACTION_COPY)
lst = entry.drag_dest_get_target_list()
lst = gtk.target_list_add_uri_targets(entry.drag_dest_get_target_list(), self.TARGET_URI)
entry.drag_dest_set_target_list(lst)
#entry.
self.dlg = self['dialog_snippets']
def __getitem__(self, key):
......@@ -496,8 +500,6 @@ class Manager:
selection = self.tree_view.get_selection()
(model, paths) = selection.get_selected_rows()
#(model, piter) = self.tree_view.get_selection().get_selected()
if len(paths) == 1:
piter = model.get_iter(paths[0])
parent = model.iter_parent(piter)
......@@ -526,10 +528,6 @@ class Manager:
self['combo_drop_targets'].child.set_text(', '.join(self.snippet['drop-targets']))
buf = self['source_view_snippet'].get_buffer()
lang = self.model.get_value(self.model.get_iter( \
self.language_path), self.OBJ_COLUMN)
buf.set_language(lang)
buf.set_text(self.snippet['text'])
self.tooltips.enable()
......
......@@ -70,7 +70,7 @@ class WindowHelper:
self.action_group = gtk.ActionGroup("GeditSnippetPluginActions")
self.action_group.set_translation_domain('gedit')
self.action_group.add_actions([('Snippets', None,
self.action_group.add_actions([('ManageSnippets', None,
_('Manage _Snippets...'), \
None, _('Manage snippets'), \
self.on_action_snippets_activate)])
......@@ -78,7 +78,7 @@ class WindowHelper:
self.merge_id = manager.new_merge_id()
manager.insert_action_group(self.action_group, -1)
manager.add_ui(self.merge_id, '/MenuBar/ToolsMenu/ToolsOps_5', \
'Snippets', 'Snippets', gtk.UI_MANAGER_MENUITEM, False)
'ManageSnippets', 'ManageSnippets', gtk.UI_MANAGER_MENUITEM, False)
def remove_menu(self):
manager = self.window.get_ui_manager()
......
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