editors

changeset 11:6dd6e48ae896

add to clips def, add a space2tab script for PSPad
author m b <eltronis@gmail.com>
date Sun May 23 04:13:44 2010 +0000 (2010-05-23)
parents 876144e443d2
children 86c44acdeb0d
files PSPad/Colors/euphoria.INI PSPad/Context/euphoria.DEF PSPad/Syntax/euphoria.ini PSPad/script/JScript/Duplicate.js PSPad/script/JScript/dupe.js PSPad/script/VBScript/ConvertIndent.vbs
line diff
     1.1 --- a/PSPad/Colors/euphoria.INI	Sat May 22 04:28:32 2010 +0000
     1.2 +++ b/PSPad/Colors/euphoria.INI	Sun May 23 04:13:44 2010 +0000
     1.3 @@ -1,5 +1,5 @@
     1.4  [html5]
     1.5 -Comment=000080001FFFFFFF010
     1.6 +Comment=00FF00001FFFFFFF010
     1.7  Django Template=000040801FFFFFFF000
     1.8  Escape Ampersand=000080001FFFFFFF100
     1.9  Identifier=1FFFFFFF1FFFFFFF000
    1.10 @@ -39,7 +39,7 @@
    1.11  Area A Identifier=008080001FFFFFFF100
    1.12  Boolean value=000080001FFFFFFF000
    1.13  Brackets=1FFFFFFF1FFFFFFF000
    1.14 -Comment=000080001FFFFFFF010
    1.15 +Comment=008080801FFFFFFF010
    1.16  Debugging Lines=008080801FFFFFFF000
    1.17  Identifier=1FFFFFFF1FFFFFFF000
    1.18  Indicator Area=000000FF1FFFFFFF000
    1.19 @@ -52,7 +52,7 @@
    1.20  Tag Area=000000801FFFFFFF000
    1.21  
    1.22  [MS-DOS Batch]
    1.23 -Comment=000080001FFFFFFF010
    1.24 +Comment=008000001FFFFFFF010
    1.25  Identifier=1FFFFFFF1FFFFFFF000
    1.26  Key=1FFFFFFF1FFFFFFF100
    1.27  Label=000000801FFFFFFF100
    1.28 @@ -64,7 +64,7 @@
    1.29  
    1.30  [Cascading Style Sheet]
    1.31  Color Value=1FFFFFFF1FFFFFFF000
    1.32 -Comment=000080001FFFFFFF010
    1.33 +Comment=008080801FFFFFFF010
    1.34  Number=008000801FFFFFFF000
    1.35  Property=1FFFFFFF1FFFFFFF100
    1.36  Reserved Word=000000801FFFFFFF100
    1.37 @@ -76,7 +76,7 @@
    1.38  Value=00FF00001FFFFFFF000
    1.39  
    1.40  [Fortran]
    1.41 -Comment=000080001FFFFFFF010
    1.42 +Comment=00FF00001FFFFFFF010
    1.43  Identifier=1FFFFFFF1FFFFFFF000
    1.44  Number=1FFFFFFF1FFFFFFF000
    1.45  Reserved Word=1FFFFFFF1FFFFFFF100
    1.46 @@ -107,7 +107,7 @@
    1.47  Value=008000001FFFFFFF000
    1.48  
    1.49  [XHTML]
    1.50 -Comment=000080001FFFFFFF010
    1.51 +Comment=000080001FFFFFFF000
    1.52  Django Template=000040801FFFFFFF000
    1.53  Escape Ampersand=000080001FFFFFFF100
    1.54  Identifier=1FFFFFFF1FFFFFFF100
    1.55 @@ -130,7 +130,7 @@
    1.56  Text=1FFFFFFF1FFFFFFF000
    1.57  
    1.58  [Inno Setup Script]
    1.59 -Comment=000080001FFFFFFF010
    1.60 +Comment=008080801FFFFFFF010
    1.61  Directive=008000801FFFFFFF000
    1.62  Identifier=1FFFFFFF1FFFFFFF000
    1.63  Illegal Char=1FFFFFFF1FFFFFFF000
    1.64 @@ -167,24 +167,24 @@
    1.65  
    1.66  [KiXtart]
    1.67  Command=00FF35351FFFFFFF100
    1.68 -Comment=000080001FFFFFFF010
    1.69 +Comment=008080801FFFFFFF010
    1.70  Function=003C1AFF1FFFFFFF100
    1.71  Identifier=1FFFFFFF1FFFFFFF000
    1.72  Label=00FF00801FFFFFFF001
    1.73  Macro=000074E81FFFFFFF100
    1.74 -Number=008000001FFFFFFF000
    1.75 +Number=000080001FFFFFFF100
    1.76  Parameter=000000801FFFFFFF100
    1.77  Space=008080001FFFFFFF000
    1.78 -String=000000801FFFFFFF000
    1.79 -Symbol=1FFFFFFF1FFFFFFF000
    1.80 -Variable=1FFFFFFF1FFFFFFF000
    1.81 +String=00468C001FFFFFFF000
    1.82 +Symbol=00FF00801FFFFFFF100
    1.83 +Variable=1FFFFFFF1FFFFFFF100
    1.84  Key=1FFFFFFF1FFFFFFF100
    1.85  Miscellaneous=1FFFFFFF1FFFFFFF000
    1.86  
    1.87  [Object Pascal]
    1.88  Assembler=000000FF1FFFFFFF000
    1.89  Character=1FFFFFFF1FFFFFFF000
    1.90 -Comment=000080001FFFFFFF010
    1.91 +Comment=00FF00001FFFFFFF010
    1.92  Data Type=1FFFFFFF1FFFFFFF000
    1.93  Float=1FFFFFFF1FFFFFFF000
    1.94  Hexadecimal=1FFFFFFF1FFFFFFF000
    1.95 @@ -197,7 +197,7 @@
    1.96  Symbol=1FFFFFFF1FFFFFFF000
    1.97  
    1.98  [Perl]
    1.99 -Comment=000080001FFFFFFF010
   1.100 +Comment=008080801FFFFFFF010
   1.101  Identifier=1FFFFFFF1FFFFFFF000
   1.102  Illegal Char=1FFFFFFF1FFFFFFF000
   1.103  Number=008000001FFFFFFF000
   1.104 @@ -210,7 +210,7 @@
   1.105  Variable=000000801FFFFFFF000
   1.106  
   1.107  [PHP]
   1.108 -Comment=000080001FFFFFFF010
   1.109 +Comment=008080801FFFFFFF010
   1.110  Documentation=00C080801FFFFFFF010
   1.111  Identifier=1FFFFFFF1FFFFFFF000
   1.112  Number=008000001FFFFFFF000
   1.113 @@ -221,7 +221,7 @@
   1.114  Variable=00FF00001FFFFFFF000
   1.115  
   1.116  [Python]
   1.117 -Comment=000080001FFFFFFF010
   1.118 +Comment=000000FF1FFFFFFF000
   1.119  Documentation=000080001FFFFFFF000
   1.120  Float=1FFFFFFF1FFFFFFF000
   1.121  Hexadecimal=1FFFFFFF1FFFFFFF000
   1.122 @@ -278,24 +278,24 @@
   1.123  Options=1FFFFFFF1FFFFFFF000
   1.124  PathName=1FFFFFFF1FFFFFFF000
   1.125  Reserved Word=1FFFFFFF1FFFFFFF100
   1.126 -Second Reserved Word=008000801FFFFFFF110
   1.127 -Space=008080001FFFFFFF000
   1.128 +Second Reserved Word=008000801FFFFFFF100
   1.129 +Space=008080001FFFFFFF010
   1.130  String=000000801FFFFFFF000
   1.131  Symbol=1FFFFFFF1FFFFFFF000
   1.132  Tix keywords=008000001FFFFFFF110
   1.133  Variable=1FFFFFFF1FFFFFFF000
   1.134  
   1.135  [TeX]
   1.136 -Comment=000080001FFFFFFF010
   1.137 -Math Mode=000080801FFFFFFF100
   1.138 -Round Bracket=000000FF1FFFFFFF100
   1.139 +Comment=008080801FFFFFFF000
   1.140 +Math Mode=000080001FFFFFFF000
   1.141 +Round Bracket=000000FF1FFFFFFF000
   1.142  Space=008080001FFFFFFF000
   1.143  Square Bracket=008000801FFFFFFF000
   1.144 -TeX Command=00FF000000FFFFFF100
   1.145 +TeX Command=00FF000000FFFFFF000
   1.146  Text=000000001FFFFFFF000
   1.147  
   1.148  [UNIX Shell Script]
   1.149 -Comment=000080001FFFFFFF010
   1.150 +Comment=000080001FFFFFFF000
   1.151  Identifier=1FFFFFFF1FFFFFFF000
   1.152  Number=00FF00001FFFFFFF000
   1.153  Reserved Word=008000001FFFFFFF100
   1.154 @@ -306,15 +306,15 @@
   1.155  Variable=008000801FFFFFFF000
   1.156  
   1.157  [MS VBScript]
   1.158 -Comment=000080001FFFFFFF010
   1.159 +Comment=000080001FFFFFFF000
   1.160  Constant=006F00DD1FFFFFFF000
   1.161  Identifier=1FFFFFFF1FFFFFFF000
   1.162 -Number=00FF00001FFFFFFF000
   1.163 -Reserved Word=1FFFFFFF1FFFFFFF100
   1.164 +Number=004848481FFFFFFF000
   1.165 +Reserved Word=00FF00001FFFFFFF000
   1.166  Space=008080001FFFFFFF000
   1.167  String=000000801FFFFFFF000
   1.168  Symbol=1FFFFFFF1FFFFFFF000
   1.169 -System Functions and Variables=008000401FFFFFFF100
   1.170 +System Functions and Variables=008000801FFFFFFF000
   1.171  
   1.172  [Visual Basic]
   1.173  Comment=000080001FFFFFFF010
   1.174 @@ -364,7 +364,7 @@
   1.175  Symbol=1FFFFFFF1FFFFFFF000
   1.176  
   1.177  [<not assigned>]
   1.178 -Comment=000080001FFFFFFF010
   1.179 +Comment=00FF00001FFFFFFF010
   1.180  Identifier=1FFFFFFF1FFFFFFF000
   1.181  Key=1FFFFFFF1FFFFFFF100
   1.182  Key words 2=1FFFFFFF1FFFFFFF100
   1.183 @@ -395,18 +395,18 @@
   1.184  Comment=006029EF1FFFFFFF010
   1.185  Identifier=1FFFFFFF1FFFFFFF000
   1.186  Key=00D869491FFFFFFF100
   1.187 -Key words 2=00DA307C1FFFFFFF100
   1.188 -Key words 3=0030D8CB1FFFFFFF100
   1.189 +Key words 2=0030BCDA1FFFFFFF100
   1.190 +Key words 3=006864401FFFFFFF100
   1.191  Label=006D94671FFFFFFF000
   1.192  Number=004A00001FFFFFFF000
   1.193  Preprocessor=008080001FFFFFFF010
   1.194 -Reserved Word=005E2B221FFFFFFF100
   1.195 +Reserved Word=00F000781FFFFFFF100
   1.196  Space=008080001FFFFFFF000
   1.197  String=000080001FFFFFFF000
   1.198  Symbol=1FFFFFFF1FFFFFFF000
   1.199  
   1.200  [POV-Ray]
   1.201 -Comment=000080001FFFFFFF010
   1.202 +Comment=00FF00001FFFFFFF010
   1.203  Identifier=1FFFFFFF1FFFFFFF000
   1.204  Key=1FFFFFFF1FFFFFFF100
   1.205  Key words 2=1FFFFFFF1FFFFFFF100
   1.206 @@ -419,3 +419,17 @@
   1.207  String=000080001FFFFFFF000
   1.208  Symbol=1FFFFFFF1FFFFFFF000
   1.209  
   1.210 +[TXN]
   1.211 +Comment=00FF00001FFFFFFF010
   1.212 +Identifier=1FFFFFFF1FFFFFFF000
   1.213 +Key=1FFFFFFF1FFFFFFF100
   1.214 +Key words 2=1FFFFFFF1FFFFFFF100
   1.215 +Key words 3=1FFFFFFF1FFFFFFF100
   1.216 +Label=000000FF1FFFFFFF000
   1.217 +Number=008000001FFFFFFF000
   1.218 +Preprocessor=008080001FFFFFFF010
   1.219 +Reserved Word=000000801FFFFFFF100
   1.220 +Space=008080001FFFFFFF000
   1.221 +String=000080001FFFFFFF000
   1.222 +Symbol=1FFFFFFF1FFFFFFF000
   1.223 +
     2.1 --- a/PSPad/Context/euphoria.DEF	Sat May 22 04:28:32 2010 +0000
     2.2 +++ b/PSPad/Context/euphoria.DEF	Sun May 23 04:13:44 2010 +0000
     2.3 @@ -1,37 +1,129 @@
     2.4  ; PSPad clip definition file for Euphoria 4
     2.5 +; http://openeuphoria.org/wiki/wiki.cgi
     2.6  ; Author: ne1    Update: 5.20.2010, needs work
     2.7 +;; from Arena def
     2.8 +;;   (black)
     2.9 +;; B (blue)  keywords
    2.10 +;; D (dark gray)
    2.11 +;; F (fuchsia)  routines
    2.12 +;; G (green)
    2.13 +;; M (maroon)  math/stdlib
    2.14 +;; N (navy)
    2.15 +;; P (purple)  builtins
    2.16 +;; R (red)  comments
    2.17 +;;
    2.18 +[CLIP SETTINGS]
    2.19 +;;CursorChar=^
    2.20 +;;SelectionChar=
    2.21 +CursorChar=|
    2.22 +SelectionChar=
    2.23 +
    2.24  [Macro definition]
    2.25 -%ype%=@C ???
    2.26 -[HEADER | Insert header ]
    2.27 +%condition%=@C Condition:,,x<y,x<y;x>y;x=y;x<=y;x>=y;equal(x,y),
    2.28 +%conditiondef%=@C WORD:,,WIN32, WIN32;UNIX;UNITTEST,
    2.29 +%without%=@C statement:,,trace, type_check;inline;profile,
    2.30 +%include%=@C statement:,,std/cmdline.e, std/cmdline.e;std/console.e;std/convert.e;std/datetime.e;std/dll.e;std/eds.e;std/error.e;std/eumem.e;std/filesys.e;std/flags.e;std/get.e;std/graphcst.e;std/graphics.e;std/image.e;std/io.e;std/lcid.e;std/locale.e;std/localeconv.e;std/machine.e;std/map.e;std/math.e;std/memory.e;std/mouse.e;std/net/common.e;std/net/dns.e;std/net/http.e;std/os.e;std/pipeio.e;std/pretty.e;std/primes.e;std/regex.e;std/safe.e;std/search.e;std/sequence.e;std/serialize.e;std/sets.e;std/socket.e;std/sort.e;std/stack.e;std/stats.e;std/task.e;std/text.e;std/types.e;std/unicode.e;std/unittest.e;std/utils.e;std/wildcard.e;std/win32/msgbox.e;euphoria/keywords.e;euphoria/tokenize.e;euphoria/info.e;euphoria/syncolor4.e,
    2.31 +
    2.32 +
    2.33 +[_\n |R line break]*Ctrl+Enter
    2.34 +\n
    2.35 +\n|
    2.36 +
    2.37 +[-- |R -- comment]
    2.38 +-- |
    2.39 +[-- TODO FIXME |R -- comment TODO FIXME]
    2.40 +--  TODO FIXME |
    2.41 +[/*...*/ |R /*comment */  ]
    2.42 +/* | */
    2.43 +
    2.44 +[/*\n...\n*/ |R comment /* ... */ ]
    2.45 +/*
    2.46 + |
    2.47 +*/
    2.48 +[include|B include statement]
    2.49 +include %include%|
    2.50 +[without|B without statement]
    2.51 +without %without%|
    2.52 +[printf|P printf ()]
    2.53 +printf(1,"%s%d",{|})
    2.54 +
    2.55 +[if|B if statement]
    2.56 +if %condition% | then
    2.57 +elsif  then
    2.58 +else
    2.59 +end if
    2.60 +
    2.61 +[ifdef|B ifdef statement]
    2.62 +ifdef %conditiondef%| then
    2.63 +elsifdef  then
    2.64 +elsedef
    2.65 +end ifdef
    2.66 +
    2.67 +[switch|B switch statement]
    2.68 +switch | with	fallthru do
    2.69 +  case then
    2.70 +	break
    2.71 +  case else
    2.72 +		fallthru
    2.73 +end switch
    2.74 +
    2.75 +[for i|B for i ... statement]
    2.76 +for i= 1| to 10 by 2 do
    2.77 +	continue
    2.78 +end for
    2.79 +
    2.80 +[loop|B loop...until statement]
    2.81 +loop do
    2.82 +
    2.83 +	until |
    2.84 +end loop
    2.85 +
    2.86 +[while|B while  statement]
    2.87 +while | with entry with label "" do
    2.88 +	entry print "entry"
    2.89 +	exit ""
    2.90 +end while
    2.91 +
    2.92 +[HEADER |R Insert header ]
    2.93  -------------------
    2.94 --- Macro:		%FullFileName%
    2.95 +-- File:		%FullFileName%
    2.96  -- Author: 	%UserName% / %Company%
    2.97  -- Date:		%Date%
    2.98  -- Comment:	|
    2.99  -------------------
   2.100 -[abs | Returns the absolute value of a number]
   2.101 -abs(|number)
   2.102 -[acos | Returns the arccosine of a number]
   2.103 -acos(|number)
   2.104 -[asin | Returns the arcsine of a number]
   2.105 -asin(|number)
   2.106 -[atan | Returns the arctangent of a number]
   2.107 -atan(|number)
   2.108 -[ceil | Returns the smallest integer greater than or equal to its numeric argument]
   2.109 -ceil(|number)
   2.110 -[function | function definition]
   2.111 -public function |()
   2.112 +[function |F function definition]
   2.113 +public function |(integer f)
   2.114 +	return f
   2.115 +end function
   2.116  
   2.117 -end function
   2.118 -[procedure | procedure definition]
   2.119 -public procedure |()
   2.120 +[procedure |F procedure definition]
   2.121 +public procedure |()
   2.122 +end procedure
   2.123  
   2.124 -end procedure
   2.125 -[TRACE | trace ]
   2.126 +[TRACE |D trace ]
   2.127  with|out trace  --
   2.128  
   2.129 -[TRACE3 | trace3 ]
   2.130 -trace(|3) --0123 \n
   2.131 +[TRACE3 |D trace3 ]
   2.132 +trace(|3) --0123
   2.133 +[label |B label ]
   2.134 +label "|"
   2.135 +[goto |B goto ]
   2.136 +goto "|"
   2.137 +
   2.138 +[abs |M Returns the absolute value of a number]
   2.139 +abs(|number)
   2.140 +[acos |M Returns the arccosine of a number]
   2.141 +acos(|number)
   2.142 +[asin |M Returns the arcsine of a number]
   2.143 +asin(|number)
   2.144 +[atan |M Returns the arctangent of a number]
   2.145 +atan(|number)
   2.146 +[ceil |M Returns the smallest integer greater than or equal to its numeric argument]
   2.147 +ceil(|number)
   2.148 +[floor |M Returns the largest integer greater than or equal to its numeric argument]
   2.149 +floor(|number)
   2.150 +[repeat |M repeat]
   2.151 +repeat(0,|number)
   2.152  
   2.153  [Keywords]
   2.154  include std/cmdline.e
   2.155 @@ -97,7 +189,15 @@
   2.156  without profile
   2.157  with profile_time
   2.158  without profile_time
   2.159 -
   2.160 +end for
   2.161 +end function
   2.162 +end if
   2.163 +end ifdef
   2.164 +end loop
   2.165 +end procedure
   2.166 +end switch
   2.167 +end type
   2.168 +end while
   2.169  
   2.170  boolean
   2.171  continue
     3.1 --- a/PSPad/Syntax/euphoria.ini	Sat May 22 04:28:32 2010 +0000
     3.2 +++ b/PSPad/Syntax/euphoria.ini	Sun May 23 04:13:44 2010 +0000
     3.3 @@ -1,5 +1,6 @@
     3.4 -;PSPad user HighLighter definition file
     3.5 -;Euphoria 4.0b3+ and selected stdlib routines
     3.6 +;PSPad user HighLighter definition file Euphoria 4
     3.7 +; http://openeuphoria.org/wiki/wiki.cgi
     3.8 +;4.0b3+ and selected stdlib routines
     3.9  [Settings]
    3.10  Name=Euphoria
    3.11  HTMLGroup=0
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/PSPad/script/JScript/Duplicate.js	Sun May 23 04:13:44 2010 +0000
     4.3 @@ -0,0 +1,24 @@
     4.4 +// from the pspad forum new excention thread
     4.5 +// created : 13.12.2007 // author : Michael Vlasov // // You may distribute this script freely, but please keep this header intact.
     4.6 +//*******************************************************************************
     4.7 +var MODULE_NAME = "_Duplicate";
     4.8 +var MODULE_VER = "1.0";
     4.9 +var MODULE_TITLE = "Duplicate selection or current line, if no selection";
    4.10 +function Init() {
    4.11 +    menuName = "&" + MODULE_NAME;
    4.12 +    addMenuItem(menuName, "", "main", "CTRL+D");
    4.13 +}
    4.14 +function main() {
    4.15 +    var ed = newEditor();
    4.16 +    ed.assignActiveEditor();
    4.17 +    var selection = ed.selText();
    4.18 +    if (selection != "") {
    4.19 +        ed.selText(selection + selection);
    4.20 +    } else {
    4.21 +        selection = ed.lineText();
    4.22 +        var saveCaretX = ed.caretX();
    4.23 +        ed.caretX(selection.length + 1);
    4.24 +        ed.selText("\r\n" + selection);
    4.25 +        ed.caretX(saveCaretX);
    4.26 +    }
    4.27 +}
    4.28 \ No newline at end of file
     5.1 --- a/PSPad/script/JScript/dupe.js	Sat May 22 04:28:32 2010 +0000
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,32 +0,0 @@
     5.4 -// JavaScript Document
     5.5 -//*******************************************************************************
     5.6 -//	filename   : dupe.js
     5.7 -//	description: duplicate selected text or lines
     5.8 -//	created    : 5.19.2010
     5.9 -//	author     : ne1
    5.10 -//
    5.11 -//	You may distribute this script freely, but please keep this header intact.
    5.12 -//*******************************************************************************
    5.13 -var MODULE_NAME  = "_duplicate";
    5.14 -var MODULE_VER   = "0.1";
    5.15 -var MODULE_TITLE = "duplicate selected text or lines";
    5.16 -function Init() {
    5.17 -    menuName = "&" + MODULE_NAME;
    5.18 -//     subMenu = "&" + "Edit";
    5.19 -    subMenu = "";
    5.20 -    addMenuItem(menuName, subMenu, "main", "CTRL+ALT+D");
    5.21 -}
    5.22 -
    5.23 -function main()
    5.24 -{
    5.25 -	var	ed = neweditor();
    5.26 -	ed.assignActiveEditor();
    5.27 -	var text = new String(ed.lineText());
    5.28 -	var curx = ed.caretX();
    5.29 -	var symb = ed.selText();
    5.30 -
    5.31 -  ed.selText(symb)
    5.32 -  ed.selText(symb)
    5.33 -
    5.34 -}
    5.35 -
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/PSPad/script/VBScript/ConvertIndent.vbs	Sun May 23 04:13:44 2010 +0000
     6.3 @@ -0,0 +1,111 @@
     6.4 +'  Convert Indent Tabs to Spaces or Spaces to Tabs
     6.5 +'
     6.6 +' Posted by: phdesigner | Date: 04/30/2008 05:17 | IP: IP Logged
     6.7 +'
     6.8 +' This script converts the indent from tabs to spaces or spaces to tabs.
     6.9 +'
    6.10 +' PSPad does have an internal tabs to spaces function under Edit > Special Conversion but this changes ALL tabs to spaces, my script only converts leading tabs on a line to spaces.
    6.11 +'
    6.12 +' Download zip by copy and pasting this into your browser:
    6.13 +' (http://www.phdesign.com.au/download/convertindent_1_0.zip)
    6.14 +'
    6.15 +' Or save this code as a ConvertIndent.vbs in PSPad\Script\VBScript folder
    6.16 +
    6.17 +
    6.18 +'********************************************************************
    6.19 +' Author: Paul Heasley
    6.20 +' Website: www.phdesign.com.au
    6.21 +' Copyright (C) 2007 Paul Heasley
    6.22 +' Date: 19 February 2007
    6.23 +' Purpose: Converts indentation from spaces to tabs or visa versa.
    6.24 +'
    6.25 +'********************************************************************
    6.26 +
    6.27 +Const module_name = "ConvertIndent"
    6.28 +Const module_ver = "1.0"
    6.29 +
    6.30 +Const intMaxLineLength = "999999"
    6.31 +
    6.32 +Sub Init
    6.33 +addMenuItem "Convert Indent to Spaces", "", "Tab2Spaces"
    6.34 +addMenuItem "Convert Indent to Tabs", "", "Spaces2Tab"
    6.35 +End Sub
    6.36 +
    6.37 +Sub Tab2Spaces
    6.38 +Dim aryLines
    6.39 +Dim intIndent, i, j
    6.40 +
    6.41 +intIndent = GetIndentWidth
    6.42 +If Len(intIndent) = 0 Then Exit Sub
    6.43 +aryLines = Split(HandleSelText(""), vbCrLf)
    6.44 +
    6.45 +For i = LBound(aryLines) To UBound(aryLines)
    6.46 +'Set a maximum line length to avoid infinite loop
    6.47 +For j = 1 To intMaxLineLength
    6.48 +If Mid(aryLines(i), j, 1) = vbTab Then
    6.49 +aryLines(i) = Left(aryLines(i), j - 1) & Space(intIndent) & Mid(aryLines(i), j + 1)
    6.50 +'Adjust for the new length of the string
    6.51 +j = j + (intIndent - 1)
    6.52 +ElseIf Mid(aryLines(i), j, intIndent) = Space(intIndent) Then
    6.53 +j = j + (intIndent - 1)
    6.54 +Else
    6.55 +Exit For
    6.56 +End If
    6.57 +Next
    6.58 +Next
    6.59 +
    6.60 +HandleSelText Join(aryLines, vbCrLf)
    6.61 +End Sub
    6.62 +
    6.63 +Sub Spaces2Tab
    6.64 +Dim aryLines
    6.65 +Dim intIndent, i, j
    6.66 +
    6.67 +intIndent = GetIndentWidth
    6.68 +If Len(intIndent) = 0 Then Exit Sub
    6.69 +aryLines = Split(HandleSelText(""), vbCrLf)
    6.70 +
    6.71 +For i = LBound(aryLines) To UBound(aryLines)
    6.72 +'Set a maximum line length to avoid infinite loop
    6.73 +For j = 1 To intMaxLineLength
    6.74 +If Mid(aryLines(i), j, intIndent) = Space(intIndent) Then
    6.75 +aryLines(i) = Left(aryLines(i), j - 1) & vbTab & Mid(aryLines(i), j + intIndent)
    6.76 +ElseIf Mid(aryLines(i), j, 1) <> vbTab Then
    6.77 +Exit For
    6.78 +End If
    6.79 +Next
    6.80 +Next
    6.81 +
    6.82 +HandleSelText Join(aryLines, vbCrLf)
    6.83 +End Sub
    6.84 +
    6.85 +Private Function GetIndentWidth
    6.86 +GetIndentWidth = InputBox("Enter Indent Width", module_name, "4")
    6.87 +
    6.88 +If Not IsNumeric(GetIndentWidth) Then
    6.89 +MsgBox "Invalid indent width. Indent width must be numeric.", vbExclamation, module_name
    6.90 +GetIndentWidth = ""
    6.91 +End If
    6.92 +End Function
    6.93 +
    6.94 +Private Function HandleSelText(strText)
    6.95 +Dim objEditor
    6.96 +
    6.97 +On Error Resume Next
    6.98 +
    6.99 +Set objEditor = newEditor()
   6.100 +objEditor.assignActiveEditor
   6.101 +
   6.102 +If strText = "" Then
   6.103 +'Get selected text
   6.104 +HandleSelText = objEditor.selText
   6.105 +If HandleSelText = "" Then
   6.106 +'No text was select. Get all text and select it.
   6.107 +HandleSelText = objEditor.Text
   6.108 +objEditor.command "ecSelectAll"
   6.109 +End If
   6.110 +Else
   6.111 +'Set selected text
   6.112 +objEditor.selText strText
   6.113 +End If
   6.114 +End Function
   6.115 \ No newline at end of file

SCM Home | OpenEuphoria.org Home