From: <sun...@us...> - 2008-05-31 16:35:51
|
Revision: 12751 http://jedit.svn.sourceforge.net/jedit/?rev=12751&view=rev Author: sune_simonsen Date: 2008-05-31 09:35:49 -0700 (Sat, 31 May 2008) Log Message: ----------- Tagging for release version 0.32 Added Paths: ----------- plugins/SuperAbbrevs/tags/version0.32/ plugins/SuperAbbrevs/tags/version0.32/SuperAbbrevs.props plugins/SuperAbbrevs/tags/version0.32/superabbrevs/Handler.java plugins/SuperAbbrevs/tags/version0.32/superabbrevs/SuperAbbrevs.java plugins/SuperAbbrevs/tags/version0.32/superabbrevs/TemplateFactory.java plugins/SuperAbbrevs/tags/version0.32/superabbrevs/gui/AbbrevsOptionPane.java plugins/SuperAbbrevs/tags/version0.32/superabbrevs/gui/VariablesOptionPane.java plugins/SuperAbbrevs/tags/version0.32/superabbrevs/lexer/TemplateGeneratorParser.java plugins/SuperAbbrevs/tags/version0.32/superabbrevs/lexer/TemplateParser.java plugins/SuperAbbrevs/tags/version0.32/superabbrevs/template/TransformationField.java Removed Paths: ------------- plugins/SuperAbbrevs/tags/version0.32/SuperAbbrevs.props plugins/SuperAbbrevs/tags/version0.32/doc/ch01.html plugins/SuperAbbrevs/tags/version0.32/doc/ch02.html plugins/SuperAbbrevs/tags/version0.32/doc/ch02s01.html plugins/SuperAbbrevs/tags/version0.32/doc/ch02s02.html plugins/SuperAbbrevs/tags/version0.32/doc/ch02s03.html plugins/SuperAbbrevs/tags/version0.32/doc/ch02s04.html plugins/SuperAbbrevs/tags/version0.32/doc/ch02s05.html plugins/SuperAbbrevs/tags/version0.32/doc/ch02s06.html plugins/SuperAbbrevs/tags/version0.32/doc/ch03.html plugins/SuperAbbrevs/tags/version0.32/doc/ch04.html plugins/SuperAbbrevs/tags/version0.32/doc/description.html plugins/SuperAbbrevs/tags/version0.32/doc/index.html plugins/SuperAbbrevs/tags/version0.32/superabbrevs/Handler.java plugins/SuperAbbrevs/tags/version0.32/superabbrevs/SuperAbbrevs.java plugins/SuperAbbrevs/tags/version0.32/superabbrevs/TemplateFactory.java plugins/SuperAbbrevs/tags/version0.32/superabbrevs/gui/AbbrevsOptionPane.java plugins/SuperAbbrevs/tags/version0.32/superabbrevs/gui/VariablesOptionPane.java plugins/SuperAbbrevs/tags/version0.32/superabbrevs/lexer/TemplateGeneratorParser.java plugins/SuperAbbrevs/tags/version0.32/superabbrevs/lexer/TemplateParser.java plugins/SuperAbbrevs/tags/version0.32/superabbrevs/template/TransformationField.java Copied: plugins/SuperAbbrevs/tags/version0.32 (from rev 10883, plugins/SuperAbbrevs/trunk) Deleted: plugins/SuperAbbrevs/tags/version0.32/SuperAbbrevs.props =================================================================== --- plugins/SuperAbbrevs/trunk/SuperAbbrevs.props 2007-10-12 10:21:43 UTC (rev 10883) +++ plugins/SuperAbbrevs/tags/version0.32/SuperAbbrevs.props 2008-05-31 16:35:49 UTC (rev 12751) @@ -1,53 +0,0 @@ -plugin.SuperAbbrevsPlugin.name=SuperAbbrevs -plugin.SuperAbbrevsPlugin.author=Sune Simonsen -plugin.SuperAbbrevsPlugin.version=0.30 -plugin.SuperAbbrevsPlugin.depend.0=jedit 04.03.12.00 -plugin.SuperAbbrevsPlugin.depend.1=jdk 1.5 -plugin.SuperAbbrevsPlugin.activate=defer -#plugin.SuperAbbrevsPlugin.activate=startup -plugin.SuperAbbrevsPlugin.description= \ - This plug-in enables you to tab-expand an abbreviation with variables in it.\ - After the abbreviation is expanded, you can use the tab-key to jump between\ - the variables. If you change the content of a variable in the abbreviation,\ - all the variables with the same name will change accordingly. This concept \ - is previously know from Eclipse and TextMate. -plugin.QuickNotepadPlugin.longdescription=doc/description.html -plugin.SuperAbbrevsPlugin.docs=doc/index.html - -superabbrevs.label=SuperAbbrevs - -# Option pane -#plugin.SuperAbbrevsPlugin.option-pane=superabbrevs -plugin.SuperAbbrevsPlugin.option-group=superabbrevs.abbreviations \ - superabbrevs.variables - -options.superabbrevs.abbreviations.label=Abbreviations -options.superabbrevs.abbreviations.code=new superabbrevs.gui.AbbrevsOptionPane(view); - -options.superabbrevs.variables.label=Variables -options.superabbrevs.variables.code=new superabbrevs.gui.VariablesOptionPane(view); - -options.superabbrevs.mode=Select mode: -options.superabbrevs.abbreviations.abbrev=Abbreviation -options.superabbrevs.abbreviations.expand=Expansion - -options.superabbrevs.variables.variable=Variable -options.superabbrevs.variables.value=Value - -plugin.SuperAbbrevsPlugin.menu=SuperAbbrevs.tab \ - SuperAbbrevs.shiftTab \ - SuperAbbrevs.showDialog -# SuperAbbrevs.displayModeAbbrevs \ -# SuperAbbrevs.displayAllAbbrevs - -# Menu labels -SuperAbbrevs.tab.label=Tab -SuperAbbrevs.shiftTab.label=Shift Tab -SuperAbbrevs.showDialog.label=Show expansion dialog -SuperAbbrevs.displayModeAbbrevs.label=Display mode abbreviations -SuperAbbrevs.displayAllAbbrevs.label=Display all abbreviations - -SuperAbbrevs.abbrev-editor.template=Template text -SuperAbbrevs.abbrev.showDialogIfNotExists=Show dialog if abbreviation doesn't exist -SuperAbbrevs.tab.shortcut=TAB -SuperAbbrevs.shiftTab.shortcut=S+TAB Copied: plugins/SuperAbbrevs/tags/version0.32/SuperAbbrevs.props (from rev 12746, plugins/SuperAbbrevs/trunk/SuperAbbrevs.props) =================================================================== --- plugins/SuperAbbrevs/tags/version0.32/SuperAbbrevs.props (rev 0) +++ plugins/SuperAbbrevs/tags/version0.32/SuperAbbrevs.props 2008-05-31 16:35:49 UTC (rev 12751) @@ -0,0 +1,53 @@ +plugin.SuperAbbrevsPlugin.name=SuperAbbrevs +plugin.SuperAbbrevsPlugin.author=Sune Simonsen +plugin.SuperAbbrevsPlugin.version=0.32 +plugin.SuperAbbrevsPlugin.depend.0=jedit 04.02.00.00 +plugin.SuperAbbrevsPlugin.depend.1=jdk 1.5 +plugin.SuperAbbrevsPlugin.activate=defer +#plugin.SuperAbbrevsPlugin.activate=startup +plugin.SuperAbbrevsPlugin.description= \ + This plug-in enables you to tab-expand an abbreviation with variables in it. \ + After the abbreviation is expanded, you can use the tab-key to jump between \ + the variables. If you change the content of a variable in the abbreviation, \ + all the variables with the same name will change accordingly. This concept \ + is previously know from Eclipse and TextMate. +plugin.QuickNotepadPlugin.longdescription=doc/description.html +plugin.SuperAbbrevsPlugin.docs=doc/index.html + +superabbrevs.label=SuperAbbrevs + +# Option pane +#plugin.SuperAbbrevsPlugin.option-pane=superabbrevs +plugin.SuperAbbrevsPlugin.option-group=superabbrevs.abbreviations \ + superabbrevs.variables + +options.superabbrevs.abbreviations.label=Abbreviations +options.superabbrevs.abbreviations.code=new superabbrevs.gui.AbbrevsOptionPane(view); + +options.superabbrevs.variables.label=Variables +options.superabbrevs.variables.code=new superabbrevs.gui.VariablesOptionPane(view); + +options.superabbrevs.mode=Select mode: +options.superabbrevs.abbreviations.abbrev=Abbreviation +options.superabbrevs.abbreviations.expand=Expansion + +options.superabbrevs.variables.variable=Variable +options.superabbrevs.variables.value=Value + +plugin.SuperAbbrevsPlugin.menu=SuperAbbrevs.tab \ + SuperAbbrevs.shiftTab \ + SuperAbbrevs.showDialog +# SuperAbbrevs.displayModeAbbrevs \ +# SuperAbbrevs.displayAllAbbrevs + +# Menu labels +SuperAbbrevs.tab.label=Tab +SuperAbbrevs.shiftTab.label=Shift Tab +SuperAbbrevs.showDialog.label=Show expansion dialog +SuperAbbrevs.displayModeAbbrevs.label=Display mode abbreviations +SuperAbbrevs.displayAllAbbrevs.label=Display all abbreviations + +SuperAbbrevs.abbrev-editor.template=Template text +SuperAbbrevs.abbrev.showDialogIfNotExists=Show dialog if abbreviation doesn't exist +SuperAbbrevs.tab.shortcut=TAB +SuperAbbrevs.shiftTab.shortcut=S+TAB Deleted: plugins/SuperAbbrevs/tags/version0.32/doc/ch01.html =================================================================== --- plugins/SuperAbbrevs/trunk/doc/ch01.html 2007-10-12 10:21:43 UTC (rev 10883) +++ plugins/SuperAbbrevs/tags/version0.32/doc/ch01.html 2008-05-31 16:35:49 UTC (rev 12751) @@ -1,17 +0,0 @@ -<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Introduction</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="SuperAbbrevs plugin user's guide"><link rel="up" href="index.html" title="SuperAbbrevs plugin user's guide"><link rel="prev" href="index.html" title="SuperAbbrevs plugin user's guide"><link rel="next" href="ch02.html" title="Using the plugin"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="Introduction"></a>Chapter\xA01.\xA0Introduction</h2></div></div></div><p> - This plugin gives you the ability to expand an abbreviations to userdefined - code template. When expanded you can jump between the variables in the - template using the TAB key. If you change the text of a variable, the text - will change everywhere the variable is placed in the template. - </p><p> - There is already some predefined abbreviations when you install the plugin, - you can find them in the <span class="application">SuperAbbrevs</span> - optionpane. Each mode have a list of defined abbreviations, you can change - between the mode in the dropdown menu at the top of the optionpane, an the - abbreviations associated with the mode will be shown in the table below. - There is a special mode added, <span class="emphasis"><em>global</em></span>, that defines - abbreviations that works across all modes. - </p><p> - You can defined, edit or delete the abbreviations from the optionpane, - this will be explained further in <a href="ch02.html" title="Chapter\xA02.\xA0Using the plugin">Chapter\xA02, <i>Using the plugin</i></a>. - </p></div></body></html> Deleted: plugins/SuperAbbrevs/tags/version0.32/doc/ch02.html =================================================================== --- plugins/SuperAbbrevs/trunk/doc/ch02.html 2007-10-12 10:21:43 UTC (rev 10883) +++ plugins/SuperAbbrevs/tags/version0.32/doc/ch02.html 2008-05-31 16:35:49 UTC (rev 12751) @@ -1 +0,0 @@ -<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Using the plugin</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="SuperAbbrevs plugin user's guide"><link rel="up" href="index.html" title="SuperAbbrevs plugin user's guide"><link rel="prev" href="ch01.html" title="Introduction"><link rel="next" href="ch02s01.html" title="Expand an abbreviation"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="Using%20the%20plugin"></a>Chapter\xA02.\xA0Using the plugin</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><ul><li><span class="sect1"><a href="ch02s01.html">Expand an abbreviation</a></span></li><li><span class="sect1"><a href="ch02s02.html">Expand an abbreviation on a selection</a></span></li><li><span class="sect1"><a href="ch02s03.html">Add a new abbreviation</a></span></li><li><span class="sect1"><a href="ch02s04.html">Add a new abbreviation from the buffer</a></span></li><li><span class="sect1"><a href="ch02s05.html">Edit a existing abbreviation</a></span></li><li><span class="sect1"><a href="ch02s06.html">Add a new abbreviation from the buffer</a></span></li></ul></div></div></body></html> Deleted: plugins/SuperAbbrevs/tags/version0.32/doc/ch02s01.html =================================================================== --- plugins/SuperAbbrevs/trunk/doc/ch02s01.html 2007-10-12 10:21:43 UTC (rev 10883) +++ plugins/SuperAbbrevs/tags/version0.32/doc/ch02s01.html 2008-05-31 16:35:49 UTC (rev 12751) @@ -1,10 +0,0 @@ -<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Expand an abbreviation</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="SuperAbbrevs plugin user's guide"><link rel="up" href="ch02.html" title="Using the plugin"><link rel="prev" href="ch02.html" title="Using the plugin"><link rel="next" href="ch02s02.html" title="Expand an abbreviation on a selection"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="expand"></a>Expand an abbreviation</h2></div></div></div> - To expand an abbreviation, you have to be in the mode the abbreviation is - associated with, and the cursor should be placed after the abbreviation. - Then press the TAB key, the template will be - inserted and the first variable will be selected. If you change the text - of the variable it changes everywhere the variable is placed in the - template. By pressing the TAB key once more, the - next variable is selected. If you want to jump back to a earlier variable - you should just press S+TAB. - </div></body></html> Deleted: plugins/SuperAbbrevs/tags/version0.32/doc/ch02s02.html =================================================================== --- plugins/SuperAbbrevs/trunk/doc/ch02s02.html 2007-10-12 10:21:43 UTC (rev 10883) +++ plugins/SuperAbbrevs/tags/version0.32/doc/ch02s02.html 2008-05-31 16:35:49 UTC (rev 12751) @@ -1,7 +0,0 @@ -<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Expand an abbreviation on a selection</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="SuperAbbrevs plugin user's guide"><link rel="up" href="ch02.html" title="Using the plugin"><link rel="prev" href="ch02s01.html" title="Expand an abbreviation"><link rel="next" href="ch02s03.html" title="Add a new abbreviation"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="expand%20selection"></a>Expand an abbreviation on a selection</h2></div></div></div> - To expand an abbreviation when you have selected some text, you should invoke - the <span><strong class="guimenu">Show expandsion dialog</strong></span> action in the - <span><strong class="guimenu">Plugins</strong></span> menu. Type in the abbreviation and press ENTER. - The abbreviation will be expanded and the selection will be available to - the template generating code. - </div></body></html> Deleted: plugins/SuperAbbrevs/tags/version0.32/doc/ch02s03.html =================================================================== --- plugins/SuperAbbrevs/trunk/doc/ch02s03.html 2007-10-12 10:21:43 UTC (rev 10883) +++ plugins/SuperAbbrevs/tags/version0.32/doc/ch02s03.html 2008-05-31 16:35:49 UTC (rev 12751) @@ -1,8 +0,0 @@ -<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Add a new abbreviation</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="SuperAbbrevs plugin user's guide"><link rel="up" href="ch02.html" title="Using the plugin"><link rel="prev" href="ch02s02.html" title="Expand an abbreviation on a selection"><link rel="next" href="ch02s04.html" title="Add a new abbreviation from the buffer"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="add"></a>Add a new abbreviation</h2></div></div></div> - In the SuperAbbrevs optionpane, find the mode in the dropdown menu, for which - you want to add the abbreviation. Then press the plus button below the - abbreviation table, a abbreviation editor will appear. Type in the - abbreviation and the template according to the syntax explained in <a href="ch03.html" title="Chapter\xA03.\xA0Writing templates">Chapter\xA03, <i>Writing templates</i></a>. Press the Ok button. The abbreviation is not saved - yet, you have to press Apply or the Ok button, at the button of the - optionpane, to save all the changes you made to the abbreviations. - </div></body></html> Deleted: plugins/SuperAbbrevs/tags/version0.32/doc/ch02s04.html =================================================================== --- plugins/SuperAbbrevs/trunk/doc/ch02s04.html 2007-10-12 10:21:43 UTC (rev 10883) +++ plugins/SuperAbbrevs/tags/version0.32/doc/ch02s04.html 2008-05-31 16:35:49 UTC (rev 12751) @@ -1,7 +0,0 @@ -<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Add a new abbreviation from the buffer</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="SuperAbbrevs plugin user's guide"><link rel="up" href="ch02.html" title="Using the plugin"><link rel="prev" href="ch02s03.html" title="Add a new abbreviation"><link rel="next" href="ch02s05.html" title="Edit a existing abbreviation"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="add%20inline"></a>Add a new abbreviation from the buffer</h2></div></div></div> - If you want to add a new abbreviation from the buffer, type the abbreviation and press - S+TAB a abbreviation editor dialog will be shown. This dialog is used the - same way as <a href="ch02s03.html" title="Add a new abbreviation">the section called “Add a new abbreviation”</a>, the only difference is that there is to - buttons instead of the Ok button, one for adding the abbreviation to the - <span class="emphasis"><em>global</em></span> mode and one for the current mode. - </div></body></html> Deleted: plugins/SuperAbbrevs/tags/version0.32/doc/ch02s05.html =================================================================== --- plugins/SuperAbbrevs/trunk/doc/ch02s05.html 2007-10-12 10:21:43 UTC (rev 10883) +++ plugins/SuperAbbrevs/tags/version0.32/doc/ch02s05.html 2008-05-31 16:35:49 UTC (rev 12751) @@ -1,8 +0,0 @@ -<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Edit a existing abbreviation</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="SuperAbbrevs plugin user's guide"><link rel="up" href="ch02.html" title="Using the plugin"><link rel="prev" href="ch02s04.html" title="Add a new abbreviation from the buffer"><link rel="next" href="ch02s06.html" title="Add a new abbreviation from the buffer"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="edit"></a>Edit a existing abbreviation</h2></div></div></div> - To edit an abbreviation, double click it, an abbreviation editor dialog - will appear, Type in the abbreviation and the template according to the - syntax explained in <a href="ch03.html" title="Chapter\xA03.\xA0Writing templates">Chapter\xA03, <i>Writing templates</i></a>. Press the Ok button. - The abbreviation is not saved yet, you have to press Apply or the Ok button, - at the button of the optionpane, to save all the changes you made to the - abbreviations. - </div></body></html> Deleted: plugins/SuperAbbrevs/tags/version0.32/doc/ch02s06.html =================================================================== --- plugins/SuperAbbrevs/trunk/doc/ch02s06.html 2007-10-12 10:21:43 UTC (rev 10883) +++ plugins/SuperAbbrevs/tags/version0.32/doc/ch02s06.html 2008-05-31 16:35:49 UTC (rev 12751) @@ -1,7 +0,0 @@ -<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Add a new abbreviation from the buffer</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="SuperAbbrevs plugin user's guide"><link rel="up" href="ch02.html" title="Using the plugin"><link rel="prev" href="ch02s05.html" title="Edit a existing abbreviation"><link rel="next" href="ch03.html" title="Writing templates"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="edit%20inline"></a>Add a new abbreviation from the buffer</h2></div></div></div> - If you want to edit an abbreviation from the buffer, type the abbreviation - and press S+TAB a abbreviation editor dialog will be shown. This dialog is - used the same way as <a href="ch02s05.html" title="Edit a existing abbreviation">the section called “Edit a existing abbreviation”</a>, the only difference is that there is to - buttons instead of the ok button, one for adding the abbreviation to the - <span class="emphasis"><em>global</em></span> mode and one for the current mode. - </div></body></html> Deleted: plugins/SuperAbbrevs/tags/version0.32/doc/ch03.html =================================================================== --- plugins/SuperAbbrevs/trunk/doc/ch03.html 2007-10-12 10:21:43 UTC (rev 10883) +++ plugins/SuperAbbrevs/tags/version0.32/doc/ch03.html 2008-05-31 16:35:49 UTC (rev 12751) @@ -1,67 +0,0 @@ -<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Writing templates</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="SuperAbbrevs plugin user's guide"><link rel="up" href="index.html" title="SuperAbbrevs plugin user's guide"><link rel="prev" href="ch02s06.html" title="Add a new abbreviation from the buffer"><link rel="next" href="ch04.html" title="Template generation"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="Writing%20templates"></a>Chapter\xA03.\xA0Writing templates</h2></div></div></div><p> - A template can consist of the following things: - </p><div class="itemizedlist"><ul type="disc"><li>Variable - <p> - Variables is the essential part of a template, you write a variable - in a template as ${number:value} where number is the TAB index of the - variable, and value is the text that will be inserted in the - variable when the template is expanded. The value will be inserted - instead of the variable when the template is expanded. - </p><p> - The characters \ { } have to be escaped in the value as \\ \{ \}. - </p></li><li>Variable reference - <p> - You can refere to a variable by inserting $number, where number is - the TAB index of the variable you are referring to. This inserts the - text of the variable instead of the reference. - </p></li><li>Transformation variable reference - <p> - This is a special kind of reference where you can run beanshell code - on the text of the referred variable. You insert it in the template - as ${number=code} where number is the TAB index of the variable you - are referring to, and code is arbitrary beanshell code. In the code - the beanshell variable <span class="emphasis"><em>s</em></span> holds the text of the - referred variable. The functions in the file - <span class="emphasis"><em>.jedit/SuperAbbrevs/abbrevs_functions.bsh</em></span> is also available in the - code. - </p></li><li>The end variable - <p> - A special variable is $end, this variable will always be defined for a - template, and represents the last place the cursor will jump to in the - template. If the $end variable is not explicit defined, it will be - inserted at the end of the template. When you type in the end variable - the template becomes inactive and the TAB key functions as normal. - </p></li><li>Normal text - <p> - Everywhere thing else is just normal text that's inserted and not - manipulated by the template engine. - </p><p> - One thing to be aware of is that there is some character sequences that - have to be escaped. - If you want to write $ in the text you have to escape it as \$. As well - \ should be escapes as \\. - </p></li></ul></div><p> - This example shows you how to make a java field with getter and setters. - The firstUp function makes the first character of the variable uppercase. - </p><p> - </p><pre class="programlisting"> -private ${2:Type} ${1:field}; - -/** - * Getter function for the field $1 - */ -public $2 get${1=firstUp(s)}() { - return $1; -} - -/** - * Setter function for the field $1 - */ -public void set${1=firstUp(s)}($2 $1){ - this.$1 = $1; -} -</pre><p> - </p><p> - The best advice I can give you is to look at the already defined, - templates and play around with them. - </p></div></body></html> Deleted: plugins/SuperAbbrevs/tags/version0.32/doc/ch04.html =================================================================== --- plugins/SuperAbbrevs/trunk/doc/ch04.html 2007-10-12 10:21:43 UTC (rev 10883) +++ plugins/SuperAbbrevs/tags/version0.32/doc/ch04.html 2008-05-31 16:35:49 UTC (rev 12751) @@ -1,29 +0,0 @@ -<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Template generation</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="SuperAbbrevs plugin user's guide"><link rel="up" href="index.html" title="SuperAbbrevs plugin user's guide"><link rel="prev" href="ch03.html" title="Writing templates"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="Template%20generation"></a>Chapter\xA04.\xA0Template generation</h2></div></div></div><p> - This is only for advanced users. - </p><p> - It's possible to generate a template with beanshell code, - you embed code into the template in between <# code #>, the template - is then turned inside out, so all the normal text is turn into print - statements, and the code will be executed. It's possible to print new code - to the template with <#= code #> where the code have to evaluate to - a string. All the functions in the files - <span class="emphasis"><em>.jedit/SuperAbbrevs/template_generation_functions.bsh</em></span> - <span class="emphasis"><em>.jedit/SuperAbbrevs/abbrevs_functions.bsh</em></span> is - available, as well as a variable <span class="emphasis"><em>selection</em></span>, holding - the selection. - </p><p> - This example shows how to generate a HTML multiplying table of 5 rows and - 5 columns, not that usefull but only imagination hold you back. - </p><p> - </p><pre class="programlisting"> -<table> -<# for(i=0; i<=5; i++){ #> - <tr> - <# for(j=0; j<=5; j++){ #> - <td><#= i*j #></td> - <# } #> - </tr> -<# } #> -</table> -</pre><p> - </p></div></body></html> Deleted: plugins/SuperAbbrevs/tags/version0.32/doc/description.html =================================================================== --- plugins/SuperAbbrevs/trunk/doc/description.html 2007-10-12 10:21:43 UTC (rev 10883) +++ plugins/SuperAbbrevs/tags/version0.32/doc/description.html 2008-05-31 16:35:49 UTC (rev 12751) @@ -1,14 +0,0 @@ -<p> This plug-in enables you to <i>tab</i>-expand an abbreviation with variables -in it. After the abbreviation is expanded, you can use the <i>tab</i>-key to -jump between the variables. If you change the content of a variable in the -abbreviation, all the variables with the same name will change accordingly. It -is also possible to make variables that changes their content depending on the -content of another variable. The user can define his own abbreviation for each -mode supported by jEdit in the SuperAbbrevs option-pane. -</p> - -<p> -This concept is previously know from <a -href="http://www.eclipse.org/">Eclipse</a> and <a -href="http://www.macromates.com/">TextMate</a>. -</p> Deleted: plugins/SuperAbbrevs/tags/version0.32/doc/index.html =================================================================== --- plugins/SuperAbbrevs/trunk/doc/index.html 2007-10-12 10:21:43 UTC (rev 10883) +++ plugins/SuperAbbrevs/tags/version0.32/doc/index.html 2008-05-31 16:35:49 UTC (rev 12751) @@ -1,9 +0,0 @@ -<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>SuperAbbrevs plugin user's guide</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="SuperAbbrevs plugin user's guide"><link rel="next" href="ch01.html" title="Introduction"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" lang="en"><div class="titlepage"><div><div><h1 class="title"><a name="id2504741"></a>SuperAbbrevs plugin user's guide</h1></div><div><p class="copyright">Copyright \xA9 2005, 2010 Sune Simonsen</p></div><div><div class="legalnotice"><a name="id2504772"></a><p class="legalnotice-title"><b>Legal Notice</b></p><p> - Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.1 or - any later version published by the Free Software Foundation; with no - "Invariant Sections", "Front-Cover Texts" or - "Back-Cover Texts", each as defined in the license. A copy - of the license can be found in the file <code class="filename">COPYING.txt</code> - included with jEdit. - </p></div></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><ul><li><span class="chapter"><a href="ch01.html">1. Introduction</a></span></li><li><span class="chapter"><a href="ch02.html">2. Using the plugin</a></span><ul><li><span class="sect1"><a href="ch02s01.html">Expand an abbreviation</a></span></li><li><span class="sect1"><a href="ch02s02.html">Expand an abbreviation on a selection</a></span></li><li><span class="sect1"><a href="ch02s03.html">Add a new abbreviation</a></span></li><li><span class="sect1"><a href="ch02s04.html">Add a new abbreviation from the buffer</a></span></li><li><span class="sect1"><a href="ch02s05.html">Edit a existing abbreviation</a></span></li><li><span class="sect1"><a href="ch02s06.html">Add a new abbreviation from the buffer</a></span></li></ul></li><li><span class="chapter"><a href="ch03.html">3. Writing templates</a></span></li><li><span class="chapter"><a href="ch04.html">4. Template generation</a></span></li></ul></div></div></body></html> Deleted: plugins/SuperAbbrevs/tags/version0.32/superabbrevs/Handler.java =================================================================== --- plugins/SuperAbbrevs/trunk/superabbrevs/Handler.java 2007-10-12 10:21:43 UTC (rev 10883) +++ plugins/SuperAbbrevs/tags/version0.32/superabbrevs/Handler.java 2008-05-31 16:35:49 UTC (rev 12751) @@ -1,151 +0,0 @@ -package superabbrevs; - -import org.gjt.sp.jedit.buffer.*; -import org.gjt.sp.jedit.Buffer; -import java.util.*; -import org.gjt.sp.jedit.textarea.JEditTextArea; -import superabbrevs.template.*; - -public class Handler extends BufferChangeAdapter { - private boolean disabled; - private JEditTextArea textArea; - private boolean justEdited = false; - private int caret; - private int oldTemplateLength; - private Buffer buffer; - private boolean inCompoundEdit = false; - - //{{{ field Template template - private Template template; - /** - * Getter function for the field template - */ - public Template getTemplate() { - return template; - } - //}}} - - public Handler(Template template, JEditTextArea textArea, Buffer buffer){ - this.textArea = textArea; - //buffer = textArea.getBuffer(); - this.buffer = buffer; - this.template = template; - } - - public boolean justEdited(){ - return justEdited; - } - - public boolean isDisabled(){ - return disabled; - } - - public void contentInserted(Buffer buffer, int startLine, int offset, - int numLines, int length){ - - if (!disabled){ - String insertedText = buffer.getText(offset, length); - - try{ - - if(justEdited){ - offset = caret; - oldTemplateLength += length; - } else { - oldTemplateLength = template.getLength()+length; - } - - int fieldOffset = template.getCurrentField().getOffset(); - - template.insert(offset,insertedText); - - int offsetChanged = template.getCurrentField().getOffset() - fieldOffset; - caret = offset + offsetChanged + length; - - justEdited = true; - } catch (WriteOutsideTemplateException e) { - removeHandler(buffer); - //System.out.println("Handler removed "+e.getMessage()); - } - } - } - - public void contentRemoved(Buffer buffer, int startLine, int offset, - int numLines, int length){ - - if (!disabled){ - try{ - oldTemplateLength = template.getLength()-length; - - int fieldOffset = template.getCurrentField().getOffset(); - template.delete(offset,length); - int offsetChanged = template.getCurrentField().getOffset() - fieldOffset; - caret = offset + offsetChanged; - - justEdited = true; - - textArea.setCaretPosition(caret); - } catch (WriteOutsideTemplateException e) { - removeHandler(buffer); - //System.out.println("Handler removed "+e.getMessage()); - } - } - } - - /** - * Method postEdit() - */ - public void postEdit() { - disabled = true; - - buffer.writeLock(); - - TemplateCaretListener listener = TemplateCaretListener.removeCaretListener(textArea); - Handler handler = removeHandler(buffer); - - //remove the old templape - buffer.remove(template.getOffset(),oldTemplateLength); - - //insert the new templape - buffer.insert(template.getOffset(),template.toString()); - - putHandler(buffer,handler); - TemplateCaretListener.putCaretListener(textArea,listener); - - buffer.writeUnlock(); - - textArea.setCaretPosition(caret); - - disabled = false; - - justEdited = false; - } - - //{{{ Handler management - - private static Hashtable handlers = new Hashtable(); - - public static void putHandler(Buffer buffer, Handler t){ - Handler h = getHandler(buffer); - buffer.removeBufferChangeListener(h); - buffer.addBufferChangeListener(t); - handlers.put(buffer,t); - } - - public static Handler getHandler(Buffer buffer){ - return (Handler)handlers.get(buffer); - } - - public static Handler removeHandler(Buffer buffer){ - Handler h = getHandler(buffer); - buffer.removeBufferChangeListener(h); - handlers.remove(buffer); - return h; - } - - public static boolean enabled(Buffer buffer){ - return null != handlers.get(buffer); - } - - //}}} -} Copied: plugins/SuperAbbrevs/tags/version0.32/superabbrevs/Handler.java (from rev 12743, plugins/SuperAbbrevs/trunk/superabbrevs/Handler.java) =================================================================== --- plugins/SuperAbbrevs/tags/version0.32/superabbrevs/Handler.java (rev 0) +++ plugins/SuperAbbrevs/tags/version0.32/superabbrevs/Handler.java 2008-05-31 16:35:49 UTC (rev 12751) @@ -0,0 +1,151 @@ +package superabbrevs; + +import org.gjt.sp.jedit.buffer.*; +import org.gjt.sp.jedit.Buffer; +import java.util.*; +import org.gjt.sp.jedit.textarea.JEditTextArea; +import superabbrevs.template.*; + +public class Handler extends BufferChangeAdapter { + private boolean disabled; + private JEditTextArea textArea; + private boolean justEdited = false; + private int caret; + private int oldTemplateLength; + private Buffer buffer; + private boolean inCompoundEdit = false; + + //{{{ field Template template + private Template template; + /** + * Getter function for the field template + */ + public Template getTemplate() { + return template; + } + //}}} + + public Handler(Template template, JEditTextArea textArea, Buffer buffer){ + this.textArea = textArea; + //buffer = textArea.getBuffer(); + this.buffer = buffer; + this.template = template; + } + + public boolean justEdited(){ + return justEdited; + } + + public boolean isDisabled(){ + return disabled; + } + + public void contentInserted(Buffer buffer, int startLine, int offset, + int numLines, int length){ + + if (!disabled){ + String insertedText = buffer.getText(offset, length); + + try{ + + if(justEdited){ + offset = caret; + oldTemplateLength += length; + } else { + oldTemplateLength = template.getLength()+length; + } + + int fieldOffset = template.getCurrentField().getOffset(); + + template.insert(offset,insertedText); + + int offsetChanged = template.getCurrentField().getOffset() - fieldOffset; + caret = offset + offsetChanged + length; + + justEdited = true; + } catch (WriteOutsideTemplateException e) { + removeHandler(buffer); + //System.out.println("Handler removed "+e.getMessage()); + } + } + } + + public void contentRemoved(Buffer buffer, int startLine, int offset, + int numLines, int length){ + + if (!disabled){ + try{ + oldTemplateLength = template.getLength()-length; + + int fieldOffset = template.getCurrentField().getOffset(); + template.delete(offset,length); + int offsetChanged = template.getCurrentField().getOffset() - fieldOffset; + caret = offset + offsetChanged; + + justEdited = true; + + textArea.setCaretPosition(caret); + } catch (WriteOutsideTemplateException e) { + removeHandler(buffer); + //System.out.println("Handler removed "+e.getMessage()); + } + } + } + + /** + * Method postEdit() + */ + public void postEdit() { + disabled = true; + + buffer.writeLock(); + + TemplateCaretListener listener = TemplateCaretListener.removeCaretListener(textArea); + Handler handler = removeHandler(buffer); + + //remove the old template + buffer.remove(template.getOffset(),oldTemplateLength); + + //insert the new template + buffer.insert(template.getOffset(),template.toString()); + + putHandler(buffer,handler); + TemplateCaretListener.putCaretListener(textArea,listener); + + buffer.writeUnlock(); + + textArea.setCaretPosition(caret); + + disabled = false; + + justEdited = false; + } + + //{{{ Handler management + + private static Hashtable handlers = new Hashtable(); + + public static void putHandler(Buffer buffer, Handler t){ + Handler h = getHandler(buffer); + buffer.removeBufferChangeListener(h); + buffer.addBufferChangeListener(t); + handlers.put(buffer,t); + } + + public static Handler getHandler(Buffer buffer){ + return (Handler)handlers.get(buffer); + } + + public static Handler removeHandler(Buffer buffer){ + Handler h = getHandler(buffer); + buffer.removeBufferChangeListener(h); + handlers.remove(buffer); + return h; + } + + public static boolean enabled(Buffer buffer){ + return null != handlers.get(buffer); + } + + //}}} +} Deleted: plugins/SuperAbbrevs/tags/version0.32/superabbrevs/SuperAbbrevs.java =================================================================== --- plugins/SuperAbbrevs/trunk/superabbrevs/SuperAbbrevs.java 2007-10-12 10:21:43 UTC (rev 10883) +++ plugins/SuperAbbrevs/tags/version0.32/superabbrevs/SuperAbbrevs.java 2008-05-31 16:35:49 UTC (rev 12751) @@ -1,490 +0,0 @@ -// jedit mode line :folding=explicit:collapseFolds=1: -package superabbrevs; -import java.util.*; -import java.io.*; -import org.gjt.sp.jedit.View; -import org.gjt.sp.jedit.bsh.*; -import org.gjt.sp.jedit.textarea.JEditTextArea; -import org.gjt.sp.jedit.textarea.Selection; -import org.gjt.sp.jedit.Buffer; -import superabbrevs.gui.AddAbbrevDialog; -import superabbrevs.template.*; -import javax.swing.JOptionPane; - - -/************************************************************** - * This class needs serious refactoring * - **************************************************************/ -public class SuperAbbrevs { - - //{{{ load and save abbrevs - - // caching of the abbreviations - private static Hashtable modeAbbrevs = new Hashtable(); - - /** - * Adds an abbreviation to the global abbreviation list. - * @param abbrev The abbreviation - * @param expansion The expansion - */ - public static void addGlobalAbbrev(String abbrev, String expansion){ - addModeAbbrev("global",abbrev,expansion); - } - - /** - * Adds a mode-specific abbrev. - * @param mode The edit mode - * @param abbrev The abbrev - * @param expansion The expansion - */ - public static void addModeAbbrev(String mode, String abbrev, String expansion){ - Hashtable abbrevs = (Hashtable)modeAbbrevs.get(mode); - - if (abbrevs==null){ - // try to read abbrevs from file - abbrevs = SuperAbbrevsIO.readModeFile(mode); - - if (abbrevs == null){ - // if the abbrevs is not defined, define them - abbrevs = new Hashtable(); - } - modeAbbrevs.put(mode,abbrevs); - } - - abbrevs.put(abbrev,expansion); - - SuperAbbrevsIO.writeModeFile(mode,abbrevs); - } - - public static void saveAbbrevs(String mode, Hashtable abbrevs){ - modeAbbrevs.put(mode,abbrevs); - SuperAbbrevsIO.writeModeFile(mode,abbrevs); - } - - public static Hashtable loadAbbrevs(String mode){ - Hashtable abbrevs = (Hashtable)modeAbbrevs.get(mode); - if(abbrevs == null){ - abbrevs = SuperAbbrevsIO.readModeFile(mode); - // cache abbrevs - if (abbrevs != null) modeAbbrevs.put(mode,abbrevs); - } - return abbrevs; - } - - private static String getTemplateString(String mode, String abbrev) { - - // get the template of the abbreviation in the current mode - Hashtable abbrevs = loadAbbrevs(mode); - - if (abbrevs == null || !abbrevs.containsKey(abbrev)){ - // if the template doesn't exists try the global mode - abbrevs = loadAbbrevs("global"); - } - - if (abbrevs != null){ - return (String)abbrevs.get(abbrev); - } else { - return null; - } - } - - //}}} - - //{{{ load and save abbrevs - - // caching of the variables - private static Hashtable variables = null; - - public static void saveVariables(Hashtable variables){ - SuperAbbrevs.variables = variables; - SuperAbbrevsIO.writeModeFile("global.variables",variables); - } - - public static Hashtable loadVariables(){ - if(variables == null){ - variables = SuperAbbrevsIO.readModeFile("global.variables"); - } - return variables; - } - - //}}} - - //{{{ key handlers - - /** - * Method tab(View view, JEditTextArea textArea, Buffer buffer) - * The method that desides what action should be taken for the tab key - */ - public static void tab(View view, JEditTextArea textArea, Buffer buffer) { - - if (!textArea.isEditable()){ - // beep if the textarea is not editable - textArea.getToolkit().beep(); - - } else if(Handler.enabled(buffer)){ - // If we already is in template mode, jump to the next field - nextAbbrev(textArea,buffer); - } else if(0 < textArea.getSelectionCount()){ - // If there is a selection in the buffer use the default behavior - // for the tab key - textArea.insertTabAndIndent(); - } else { - // get the abbrevation before the caret - String abbrev = getAbbrev(textArea, buffer); - - // if the abbreviation is empty we use the default behavior for the - // tab key - if (abbrev.trim().equals("")){ - textArea.insertTabAndIndent(); - return; - } - - String mode = getMode(textArea, buffer); - - String template = getTemplateString(mode, abbrev); - - if(template!=null){ - // remove the abbrevation from the buffer - removeAbbrev(textArea, buffer, abbrev); - - Hashtable modeVariables = loadVariables(); - - // Expand the abbreviation - expandAbbrev(view, template, modeVariables); - } else { - // If there no template exist use the default behavior - // for the tab key - textArea.insertTabAndIndent(); - } - } - } - - /** - * Method shiftTab(View view, JEditTextArea textArea, Buffer buffer) - * desides what action to take for the shift tab key - */ - public static void shiftTab(View view, JEditTextArea textArea, Buffer buffer) { - - if (Handler.enabled(buffer)){ - // If we already is in template mode, jump to the previous field - SuperAbbrevs.prevAbbrev(textArea,buffer); - } else if(0 < textArea.getSelectionCount()){ - // If there is a selection in the buffer use the default behavior - // for the shift tab key - textArea.shiftIndentLeft(); - } else { - String abbrev = getAbbrev(textArea, buffer); - if (!abbrev.trim().equals("")){ - Hashtable abbrevs = loadAbbrevs(getMode(textArea, buffer)); - - String expansion = ""; - if (abbrevs != null && abbrevs.get(abbrev) != null){ - expansion = (String)abbrevs.get(abbrev); - } - - AddAbbrevDialog dialog = - new AddAbbrevDialog(view,abbrev,expansion); - } else { - textArea.shiftIndentLeft(); - } - } - } - - //}}} - - //{{{ expand abbreviations - - public static void expandAbbrev(View view) { - Buffer buffer = view.getBuffer(); - JEditTextArea textArea = view.getTextArea(); - - if (!textArea.isEditable()){ - // beep if the textarea is not editable - textArea.getToolkit().beep(); - } else if(Handler.enabled(buffer)){ - // If we already is in template mode, beep - textArea.getToolkit().beep(); - } else { - // get the abbrevation before the caret - String abbrev = getAbbrev(textArea, buffer); - - // if the abbreviation is empty, beep - if (abbrev.trim().equals("")){ - textArea.getToolkit().beep(); - return; - } - - String mode = getMode(textArea, buffer); - - String template = getTemplateString(mode, abbrev); - - if(template!=null){ - // remove the abbrevation from the buffer - removeAbbrev(textArea, buffer, abbrev); - - Hashtable modeVariables = loadVariables(); - - // Expand the abbreviation - expandAbbrev(view, template, modeVariables); - } else { - // If there no template exist, beep - textArea.getToolkit().beep(); - } - } - } - - /** - * Expands the abbrev at the caret position in the specified - * view. - * @param view The view - */ - public static void expandAbbrev(View view, String template, - Hashtable variables){ - - Buffer buffer = view.getBuffer(); - JEditTextArea textArea = view.getTextArea(); - - // the offset of the caret in the full text - int caretPos = textArea.getCaretPosition(); - - // indent the template as the current line - String indent = getIndent(textArea, buffer); - - try{ - Interpreter interpreter = new Interpreter(); - - String selection = ""; - if(textArea.getSelectionCount() == 1){ - selection = textArea.getSelectedText(); - //escape all \ - selection = selection.replaceAll("\\\\","\\\\\\\\"); - textArea.setSelectedText(""); - // the offset of the caret in the full text - caretPos = textArea.getCaretPosition(); - } - - interpreter.set("filename", buffer.getName()); - interpreter.set("selection", selection); - - // put the user defined variables into the interpreter - putVariables(interpreter,variables); - - Template t = TemplateFactory.createTemplate(template, interpreter, indent); - t.setOffset(caretPos); - - // insert the template in the buffer - textArea.setSelectedText(t.toString(), false); - - // select the current field in the template - selectField(textArea, t.getCurrentField()); - - Handler h = new Handler(t,textArea,buffer); - Handler.putHandler(buffer,h); - - TemplateCaretListener.putCaretListener(textArea, new TemplateCaretListener()); - } catch ( TargetError e ) { - // The script threw an exception - System.out.println("TargetError"); - System.out.println(e.getMessage()); - } catch ( ParseException e ) { - // Parsing error - System.out.println("ParseException"); - System.out.println(e.getMessage()); - } catch ( EvalError e ) { - // General Error evaluating script - System.out.println("EvalError"); - System.out.println(e.getErrorLineNumber()); - System.out.println(e.getMessage()); - } catch ( IOException e){ - // Input output error - System.out.println("IOException"); - System.out.println(e.getMessage()); - } - } - - //}}} - - //{{{ show abbreviations dialog - - /** - * Method showAbbrevDialog(View view, JEditTextArea textArea, Buffer buffer) - * show a dialog to type in the abbrev - */ - public static void showAbbrevDialog(View view, JEditTextArea textArea, Buffer buffer) { - // TODO replace with a live search - - if(!textArea.isEditable() || - 1 < textArea.getSelectionCount() || - Handler.enabled(buffer)){ - - textArea.getToolkit().beep(); - return; - } - - String abbrev = JOptionPane.showInputDialog(view, "Type in an abbreviation", "Abbreviation Input", JOptionPane.INFORMATION_MESSAGE); - if(abbrev != null && !abbrev.trim().equals("")){ - - String mode = getMode(textArea, buffer); - - String template = getTemplateString(mode, abbrev); - if(template!=null){ - Hashtable variables = loadVariables(); - expandAbbrev(view,template,variables); - } - } - } - - //}}} - - //{{{ abbreviation navigation - - public static void nextAbbrev(JEditTextArea textArea, Buffer buffer){ - Handler h = Handler.getHandler(buffer); - Template t = h.getTemplate(); - - if (t != null){ - TemplateCaretListener listener = - TemplateCaretListener.removeCaretListener(textArea); - t.nextField(); - SelectableField f = t.getCurrentField(); - if (f!=null){ - int start = f.getOffset(); - int end = start + f.getLength(); - textArea.setCaretPosition(end); - textArea.addToSelection(new Selection.Range(start,end)); - } - TemplateCaretListener.putCaretListener(textArea,listener); - } - - } - - public static void prevAbbrev(JEditTextArea textArea, Buffer buffer){ - Handler h = Handler.getHandler(buffer); - Template t = h.getTemplate(); - - if (t != null){ - TemplateCaretListener listener = - TemplateCaretListener.removeCaretListener(textArea); - t.prevField(); - SelectableField f = t.getCurrentField(); - if (f!=null){ - int start = f.getOffset(); - int end = start + f.getLength(); - textArea.setCaretPosition(end); - textArea.addToSelection(new Selection.Range(start,end)); - } - TemplateCaretListener.putCaretListener(textArea,listener); - } - } - - //}}} - - //{{{ Text area helper methods - - public static String getMode(JEditTextArea textArea, Buffer buffer){ - // the offset of the caret in the full text - int caretPos = textArea.getCaretPosition(); - - // a string indication the mode of the current buffer - return buffer.getRuleSetAtOffset(caretPos).getModeName(); - } - - /** - * Method selectField(JEditTextArea textArea, SelectableField field) - * Select the field in the buffer - */ - public static void selectField(JEditTextArea textArea, SelectableField field) { - int start = field.getOffset(); - int end = start + field.getLength(); - textArea.setCaretPosition(end); - textArea.addToSelection(new Selection.Range(start,end)); - } - - /** - * Get the abbreviation before the caret - */ - private static String getAbbrev(JEditTextArea textArea, Buffer buffer){ - // in the following i will refere to the line where the caret resides - // as the current line. - - // the line number of the current line - int line = textArea.getCaretLine(); - // the start position of the current line in the full text - int lineStart = buffer.getLineStartOffset(line); - // the offset of the caret in the full text - int caretPos = textArea.getCaretPosition(); - // the offset of the caret in the current line - int caretPosition = caretPos - lineStart; - - // the text on the current line - String lineText = buffer.getLineText(line); - - int i=caretPosition-1; - while(0<=i && Character.isJavaIdentifierPart(lineText.charAt(i))){ - i--; - } - return lineText.substring(i+1,caretPosition); - } - - private static String getIndent(JEditTextArea textArea, Buffer buffer){ - // the line number of the current line - int lineNumber = textArea.getCaretLine(); - - // the text on the current line - String line = buffer.getLineText(lineNumber); - - int i=0; - String output = ""; - while(i<line.length() && (line.charAt(i)==' ' || line.charAt(i)=='\t')){ - output = output + line.substring(i,i+1); - i++; - } - return output; - } - - /** - * Method removeAbbrev(Buffer buffer, String abbrev) - * Removes the abbreviation from the buffer - */ - public static void removeAbbrev(JEditTextArea textArea, Buffer buffer, - String abbrev) { - // the offset of the caret in the full text - int caretPos = textArea.getCaretPosition(); - - int templateStart = caretPos - abbrev.length(); - // remove the abbreviation - buffer.remove(templateStart,abbrev.length()); - } - - //}}} - //{{{ Defaults - - public static void makeDefaults(){ - SuperAbbrevsIO.createAbbrevsDir(); - SuperAbbrevsIO.removeOldMacros(); - SuperAbbrevsIO.writeDefaultAbbrevs(); - SuperAbbrevsIO.writeDefaultVariables(); - SuperAbbrevsIO.writeDefaultAbbrevFunctions(); - SuperAbbrevsIO.writeDefaultTemplateGenerationFunctions(); - } - - //}}} - - //{{{ put user defined variables into interpreter - - private static void putVariables(Interpreter interpreter,Hashtable variables) - throws EvalError { - if(variables != null){ - Iterator iter = variables.entrySet().iterator(); - while(iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - String name = (String)entry.getKey(); - String value = (String)entry.getValue(); - - interpreter.set(name,value); - } - } - } - - //}}} -} Copied: plugins/SuperAbbrevs/tags/version0.32/superabbrevs/SuperAbbrevs.java (from rev 12745, plugins/SuperAbbrevs/trunk/superabbrevs/SuperAbbrevs.java) =================================================================== --- plugins/SuperAbbrevs/tags/version0.32/superabbrevs/SuperAbbrevs.java (rev 0) +++ plugins/SuperAbbrevs/tags/version0.32/superabbrevs/SuperAbbrevs.java 2008-05-31 16:35:49 UTC (rev 12751) @@ -0,0 +1,508 @@ +// jedit mode line :folding=explicit:collapseFolds=1: +package superabbrevs; +import java.util.*; +import java.io.*; +import org.gjt.sp.jedit.View; +import org.gjt.sp.jedit.bsh.*; +import org.gjt.sp.jedit.textarea.JEditTextArea; +import org.gjt.sp.jedit.textarea.Selection; +import org.gjt.sp.jedit.Buffer; +import superabbrevs.gui.AddAbbrevDialog; +import superabbrevs.template.*; +import javax.swing.JOptionPane; + + +/************************************************************** + * This class needs serious refactoring * + **************************************************************/ +public class SuperAbbrevs { + + //{{{ load and save abbrevs + + // caching of the abbreviations + private static Hashtable modeAbbrevs = new Hashtable(); + + /** + * Adds an abbreviation to the global abbreviation list. + * @param abbrev The abbreviation + * @param expansion The expansion + */ + public static void addGlobalAbbrev(String abbrev, String expansion){ + addModeAbbrev("global",abbrev,expansion); + } + + /** + * Adds a mode-specific abbrev. + * @param mode The edit mode + * @param abbrev The abbrev + * @param expansion The expansion + */ + public static void addModeAbbrev(String mode, String abbrev, String expansion){ + Hashtable abbrevs = (Hashtable)modeAbbrevs.get(mode); + + if (abbrevs==null){ + // try to read abbrevs from file + abbrevs = SuperAbbrevsIO.readModeFile(mode); + + if (abbrevs == null){ + // if the abbrevs is not defined, define them + abbrevs = new Hashtable(); + } + modeAbbrevs.put(mode,abbrevs); + } + + abbrevs.put(abbrev,expansion); + + SuperAbbrevsIO.writeModeFile(mode,abbrevs); + } + + public static void saveAbbrevs(String mode, Hashtable abbrevs){ + modeAbbrevs.put(mode,abbrevs); + SuperAbbrevsIO.writeModeFile(mode,abbrevs); + } + + public static Hashtable loadAbbrevs(String mode){ + Hashtable abbrevs = (Hashtable)modeAbbrevs.get(mode); + if(abbrevs == null){ + abbrevs = SuperAbbrevsIO.readModeFile(mode); + // cache abbrevs + if (abbrevs != null) modeAbbrevs.put(mode,abbrevs); + } + return abbrevs; + } + + private static String getTemplateString(String mode, String abbrev) { + + // get the template of the abbreviation in the current mode + Hashtable abbrevs = loadAbbrevs(mode); + + if (abbrevs == null || !abbrevs.containsKey(abbrev)){ + // if the template doesn't exists try the global mode + abbrevs = loadAbbrevs("global"); + } + + if (abbrevs != null){ + return (String)abbrevs.get(abbrev); + } else { + return null; + } + } + + //}}} + + //{{{ load and save abbrevs + + // caching of the variables + private static Hashtable variables = null; + + public static void saveVariables(Hashtable variables){ + SuperAbbrevs.variables = variables; + SuperAbbrevsIO.writeModeFile("global.variables",variables); + } + + public static Hashtable loadVariables(){ + if(variables == null){ + variables = SuperAbbrevsIO.readModeFile("global.variables"); + } + return variables; + } + + //}}} + + //{{{ key handlers + + /** + * Method tab(View view, JEditTextArea textArea, Buffer buffer) + * The method that desides what action should be taken for the tab key + */ + public static void tab(View view, JEditTextArea textArea, Buffer buffer) { + + if (!textArea.isEditable()){ + // beep if the textarea is not editable + textArea.getToolkit().beep(); + + } else if(Handler.enabled(buffer)){ + // If we already is in template mode, jump to the next field + nextAbbrev(textArea,buffer); + } else if(0 < textArea.getSelectionCount()){ + // If there is a selection in the buffer use the default behavior + // for the tab key + textArea.insertTabAndIndent(); + } else { + // get the abbrevation before the caret + String abbrev = getAbbrev(textArea, buffer); + + // if the abbreviation is empty we use the default behavior for the + // tab key + if (abbrev.trim().equals("")){ + textArea.insertTabAndIndent(); + return; + } + + String mode = getMode(textArea, buffer); + + String template = getTemplateString(mode, abbrev); + + if(buffer.getBooleanProperty("noTabs")) { + // we will replace tab with spaces + int tabSize = buffer.getTabSize(); + template = template.replaceAll("\t", spaces(tabSize)); + } + + if(template!=null){ + // remove the abbrevation from the buffer + removeAbbrev(textArea, buffer, abbrev); + + Hashtable modeVariables = loadVariables(); + + // Expand the abbreviation + expandAbbrev(view, template, modeVariables); + } else { + // If there no template exist use the default behavior + // for the tab key + textArea.insertTabAndIndent(); + } + } + } + + /** + * @return a string containing the number of spaces specified by the given + * size. + */ + private static String spaces(int size) { + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < size; i++) { + buf.append(" "); + } + return buf.toString(); + } + + /** + * Method shiftTab(View view, JEditTextArea textArea, Buffer buffer) + * desides what action to take for the shift tab key + */ + public static void shiftTab(View view, JEditTextArea textArea, Buffer buffer) { + + if (Handler.enabled(buffer)){ + // If we already is in template mode, jump to the previous field + SuperAbbrevs.prevAbbrev(textArea,buffer); + } else if(0 < textArea.getSelectionCount()){ + // If there is a selection in the buffer use the default behavior + // for the shift tab key + textArea.shiftIndentLeft(); + } else { + String abbrev = getAbbrev(textArea, buffer); + if (!abbrev.... [truncated message content] |