diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | ce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch) | |
tree | 5ac38a06f3dde268dc7927dc155896926aaf7012 /kate/scripts | |
download | tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kate/scripts')
-rw-r--r-- | kate/scripts/Makefile.am | 5 | ||||
-rw-r--r-- | kate/scripts/jstest.desktop | 119 | ||||
-rw-r--r-- | kate/scripts/jstest.js | 26 | ||||
-rw-r--r-- | kate/scripts/script-indent-c-char.js | 30 | ||||
-rw-r--r-- | kate/scripts/script-indent-c-newline.js | 113 | ||||
-rw-r--r-- | kate/scripts/script-indent-c-test.js | 180 | ||||
-rw-r--r-- | kate/scripts/script-indent-c1-test.lua | 154 | ||||
-rw-r--r-- | kate/scripts/sort.js | 18 | ||||
-rw-r--r-- | kate/scripts/test.js | 16 | ||||
-rw-r--r-- | kate/scripts/test_selectioniface.js | 26 |
10 files changed, 687 insertions, 0 deletions
diff --git a/kate/scripts/Makefile.am b/kate/scripts/Makefile.am new file mode 100644 index 000000000..b30da48af --- /dev/null +++ b/kate/scripts/Makefile.am @@ -0,0 +1,5 @@ +scriptskatedir = $(kde_datadir)/katepart/scripts +scriptskate_DATA = jstest.desktop jstest.js script-indent-c-newline.js script-indent-c-char.js sort.js + +indentscriptskatedir = $(kde_datadir)/katepart/scripts/indent +indentscriptskate_DATA = script-indent-c-test.js script-indent-c1-test.lua diff --git a/kate/scripts/jstest.desktop b/kate/scripts/jstest.desktop new file mode 100644 index 000000000..28619d871 --- /dev/null +++ b/kate/scripts/jstest.desktop @@ -0,0 +1,119 @@ +[Desktop Entry] +Name=Kate Part JavaScript Test +Name[af]=Kate Deel Javaskript Toets +Name[be]=Праверка сцэнараў JavaScript для Kate +Name[ca]=Prova de la peça JavaScript de Kate +Name[cs]=Kate Part JavaScript test +Name[csb]=Test JavaScript - dzélu Kate +Name[de]=JavaScript-Test für Kate-Komponente +Name[el]=Έλεγχος JavaScript του Kate Part +Name[eo]=Ĝavaskripta testo por Kate dokumenta rigardilo +Name[es]=Prueba JavaScript de Kate Part +Name[et]=Kate komponendi JavaScripti test +Name[eu]=Kate zatiaren JavaScript proba +Name[fa]=آزمون دستنوشتۀ جاوا Kate Part +Name[fi]=Kate Part JavaScript -testi +Name[fr]=Test du module JavaScript pour Kate +Name[fy]=Kate-part JavaSkript-test +Name[ga]=Tástáil JavaScript do Pháirt Kate +Name[gl]=Comprobar Kate Part JavaScript +Name[he]=בדיקת JavaScript של רכיב Kate +Name[hr]=Kate Part JavaScript test +Name[hu]=Kate objektum, Javascript-teszt +Name[id]=Tes JavaScript untuk Part Kate +Name[is]=Kate hluti JavaScript prófun +Name[it]=Prova componente JavaScript per Kate +Name[ja]=Kate Part JavaScript テスト +Name[ka]=JavaScript-ის შემოწმება Kate-ში +Name[kk]=JavaScript скрипттерді Kate редакторында тексеру +Name[km]=ការសាកល្បង Kate Part JavaScript +Name[lb]=Kate Part JavaScript-Test +Name[lt]=Kate Part JavaScript testas +Name[ms]=Ujian JavaScript Bahagian Kate +Name[nb]=Kate Part JavaScript-test +Name[nds]=Kate-Part JavaScript-Test +Name[ne]=केट भाग जाभा स्क्रिप्ट परीक्षण +Name[nl]=Kate-part JavaScript-test +Name[nn]=Kate Part JavaScript-test +Name[pa]=Kate Part JavaScript ਜਾਂਚ +Name[pl]=Test JavaScript osadzalnej części Kate +Name[pt]=Teste de JavaScript do Componente do Kate +Name[pt_BR]=Teste do componente JavaScript do Kate +Name[ro]=Test JavaScript pentru componenta Kate +Name[ru]=Проверка скриптов JavaScript в Kate +Name[rw]=Igerageza rya JavaScript Igice Kate +Name[se]=Kate Part JavaScript-geahččaleapmi +Name[sl]=Test JavaScripta za del Kate +Name[sr]=Проба JavaScript-а Kate-иног дела +Name[sr@Latn]=Proba JavaScript-a Kate-inog dela +Name[sv]=Test av Javaskript för Kates delprogram +Name[ta]=கேட் பகுதி ஜாவாஸ்கிரிப்ட் சோதனை +Name[te]=కేట్ భాగం జావాస్క్రిప్ట్ పరీక్ష +Name[tg]=Санҷиши Қисми Kate-и JavaScript +Name[th]=ทดสอบจาวาสคริปต์ของ Kate +Name[tt]=Kate Part JavaScript Sınaw +Name[uk]=Перевірка скриптів JavaScript в компоненті Kate +Name[vi]=Thử ra JavaScript phần Kate +Name[zh_CN]=Kate 部件 JavaScript 测试 +Comment=Script for testing kate part's scripting +Comment[af]=Skript om te toets of Kate se skript masjien werk +Comment[be]=Сцэнар праверкі для Kate +Comment[bg]=Скрипт за тестване на модулите за поддръжка на скриптове +Comment[bs]=Skripta za testiranje podrške Kate part-a za skriptiranje +Comment[ca]=Guió per a provar l'escriptat de les peces Kate +Comment[cs]=Skript pro test skriptování Kate +Comment[csb]=Skript do testowaniô mòżnotë skriptów Kate +Comment[da]=Script til at teste katepart scripter +Comment[de]=Ein Skript zum Testen der Skriptfunktionalität der Kate-Komponente +Comment[el]=Σενάριο για έλεγχο του scripting του Kate Part +Comment[eo]=Skripto por testi la skriptan kapablon de katepart (dokumento kaj rigardilo) +Comment[es]=Guión para probar el part de scripting de kate +Comment[et]=Skript Kate komponendi skriptimisomaduste testimiseks +Comment[eu]=Script-a Kate zatiaren script-ak probatzeko. +Comment[fa]=دستنوشته برای آزمون دستنوشتههایKate Part +Comment[fi]=Skripti kate partin skriptien testaukseen +Comment[fr]=Script testant le module de scripting de Kate +Comment[fy]=Skript foar it testen fan Kate-part's skriptmooglikheid +Comment[gl]=Guión para probar os guións das partes de kate +Comment[he]=תסריט לבדיקה של יכולות התסריט של Kate +Comment[hr]=Skripta za ispitivanje izvršavanje skripti pri 'kate part' +Comment[hu]=Szkript a Kate objektum szkriptkezelőjének ellenőrzéséhez +Comment[id]=Skrip untuk menguji skripting part kate +Comment[is]=Skrifta til að prófa skriftueiginleika Kate hluta +Comment[it]=Script per provare il componente di scripting di kate +Comment[ja]=kate part のスクリプトをテストするためのスクリプト +Comment[ka]=სკრიპტი Kate-ში სკრიპტების შესამოწმებლად +Comment[kk]=Kate редакторында скрипттерді тексеру скрипті +Comment[km]=ស្គ្រីបសម្រាប់សាកល្បងការសរសេររបស់ kate part +Comment[lb]=Skript fir d'Skriptfunktioune vum Kate part ze testen +Comment[lt]=Scenarijus Kate komponento scenarijų rašymo patikrai +Comment[ms]=Skrip untuk menguji penskripan bahagian kate +Comment[nb]=Skript til å teste kate parts skripting +Comment[nds]=En Skript, dat Kate-Part sien Skriptkönen pröven schall +Comment[ne]=केट भागको स्क्रिप्टिङ परीक्षणका लागि स्क्रिप्ट +Comment[nl]=Script voor het testen van Kate-part's scriptmogelijkheid +Comment[nn]=Skript for testing av Kate part-skriptinga +Comment[pa]=kate part ਦੀ ਸਕ੍ਰਿਪਟਿੰਗ ਦੀ ਜਾਂਚ ਲਈ ਸਕ੍ਰਿਪਟ +Comment[pl]=Skrypt do testowania możliwości skryptów Kate +Comment[pt]=Um programa para testar a programação do componente do Kate +Comment[pt_BR]=Script para testes da parte de scripts do kate +Comment[ro]=Script pentru testarea părţii de scripting din Kate +Comment[ru]=Скрипт для проверки поддержки скриптов в Kate +Comment[rw]=Inyandikoporogaramu yo kugenzura kwandika kode by'igice cya kate. +Comment[se]=Skripta mii geahččala Kate part-skriptema +Comment[sk]=Skript pre testovanie skriptovania Kate Part +Comment[sl]=Skript za testiranje delovanja skriptov za del Kate +Comment[sr]=Скрипта за испробавање скриптовања Kate-иног дела +Comment[sr@Latn]=Skripta za isprobavanje skriptovanja Kate-inog dela +Comment[sv]=Skript för att testa skripthantering i Kates delprogram +Comment[ta]=கேட் பகுதியின் எழுத்தாக்க சோதனைக்கான குறுநிரல் +Comment[te]=కేట్ భాగంపు స్క్రిప్టింగ్ ను పరీక్షించుటకు వాడు ఒక స్క్రిప్ట్ +Comment[tg]=Скрипт барои санҷидани скриптгузории қисми kate +Comment[th]=สคริปต์สำหรับทดสอบการเขียนสคริปต์ในส่วนของ Kate +Comment[tt]=Kate Part'nıñ ämerleklären sınawçı qoral +Comment[uk]=Скрипт для перевірки підтримки скриптів в компоненті Kate +Comment[vi]=Tập lệnh để thử ra khả năng điều khiển bằng tập lệnh của phần Kate. +Comment[zh_CN]=测试 kate 部件脚本的脚本 +Comment[zh_TW]=測試 kate part 的文稿 +X-Kate-Command=jstest +X-Kate-Help=<p>Usage: <code>jstest</code></p> diff --git a/kate/scripts/jstest.js b/kate/scripts/jstest.js new file mode 100644 index 000000000..cdde8a00d --- /dev/null +++ b/kate/scripts/jstest.js @@ -0,0 +1,26 @@ +// If you select some text before running the script, this line will be overwritten. +if ( view.hasSelection() ) +{ + document.removeText( 0, 0, 0, document.lineLength(0) ); + document.insertText( 0, 0, "// initial selection: " + view.selectionStartLine + "," + view.selectionStartColumn + " - " + view.selectionEndLine + "," + view.selectionEndColumn ); +} +// test selection interface +view.selectAll(); +view.setSelection( 0, 0, 0, 20 ); +view.clearSelection(); + +// insert some text and select that +var line = document.lines(); +document.insertLine( line, "foo" ); +document.insertText( line, 0, "// This is a new line" ); +view.setSelection( line, 0, line, document.lineLength(line) ); +// Delete that text +view.removeSelectedText(); + +// insert some text and select that +var line = document.lines(); +document.insertLine( line, "bar"); +document.insertText( line, 0, "// This is a new line" ); +view.setSelection( line, 0, line, document.lineLength(line) ); + +document.insertText( line, document.lineLength( line ), " Selection is " + view.selectionStartLine + "," + view.selectionStartColumn + " - " + view.selectionEndLine + "," + view.selectionEndColumn ); diff --git a/kate/scripts/script-indent-c-char.js b/kate/scripts/script-indent-c-char.js new file mode 100644 index 000000000..975d77edc --- /dev/null +++ b/kate/scripts/script-indent-c-char.js @@ -0,0 +1,30 @@ +var tabWidth = 4; +var spaceIndent = true; +var indentWidth = 4; + +var line = view.cursorLine(); +var col = view.cursorColumn(); + +var textLine = document.textLine( line ); +var prevLine = document.textLine( line - 1 ); + +var prevIndent = prevLine.match(/^\s*/); +var addIndent = ""; + +function unindent() +{ +// if ( +} + +// unindent } and {, if not in a comment +if ( textLine.search( /^\s*\/\// ) == -1 ) +{ + if ( textLine.charAt( col-1 ) == '}' || textLine.charAt( col-1 ) == '{') + { + if ( textLine.search(/^\s\s\s\s/) != -1) + { + document.removeText( line, 0, line, tabWidth ); + view.setCursorPositionReal( line, col - tabWidth ); + } + } +} diff --git a/kate/scripts/script-indent-c-newline.js b/kate/scripts/script-indent-c-newline.js new file mode 100644 index 000000000..ade711a3e --- /dev/null +++ b/kate/scripts/script-indent-c-newline.js @@ -0,0 +1,113 @@ +var tabWidth = 4; +var spaceIndent = true; +var indentWidth = 4; + +var strIndentCharacters = " "; +var strIndentFiller = ""; + +var intStartLine = view.cursorLine(); +var intStartColumn = view.cursorColumn(); + +var strTextLine = document.textLine( intStartLine ); +var strPrevLine = document.textLine( intStartLine - 1 ); + +var addIndent = ""; + +function firstNonSpace( _text ) +{ + for( _i=0; _i < _text.length; _i++ ) + { + _ch = _text.charAt( _i ); + if( _ch != ' ' && _ch != '\t' ) + return _i; + } + + return -1; +} + +function lastNonSpace( _text ) +{ + for( _i=_text.length - 1; _i >= 0; _i-- ) + { + _ch = _text.charAt( _i ); + if( _ch != ' ' && _ch != '\t' ) + return _i; + } + + return -1; +} + + +// if previous line ends with a '{' increase indent level +// if ( prevLine.search( /{\s*$/ ) != -1 ) +// { +// if ( spaceIndent ) +// addIndent = " "; +// else +// addIndent = "\t"; +// } +// else +{ + var intCurrentLine = intStartLine; + var openParenCount = 0; + var openBraceCount = 0; + + label_while: + while ( intCurrentLine > 0 ) + { + intCurrentLine--; + + strCurrentLine = document.textLine( intCurrentLine ); + intLastChar = lastNonSpace( strCurrentLine ); + intFirstChar = firstNonSpace( strCurrentLine ) ; + + if ( strCurrentLine.search( /\/\// ) == -1 ) + { + + // look through line backwards for interesting characters + for( intCurrentChar = intLastChar; intCurrentChar >= intFirstChar; --intCurrentChar ) + { + ch = strCurrentLine.charAt( intCurrentChar ); + switch( ch ) + { + case '(': case '[': + if( ++openParenCount > 0 ) + break label_while; //return calcIndentInBracket( begin, cur, pos ); + break; + case ')': case ']': openParenCount--; break; + case '{': + if( ++openBraceCount > 0 ) + break label_while; //return calcIndentInBrace( begin, cur, pos ); + break; + case '}': openBraceCount--; lookingForScopeKeywords = false; break; + case ';': + if( openParenCount == 0 ) + lookingForScopeKeywords = false; + break; + } + } + } + } + + strIndentFiller += strCurrentLine.match(/^\s+/); + if ( strIndentFiller == "null" ) + strIndentFiller = ""; + + debug( "line: " + intCurrentLine); + debug( openParenCount + ", " + openBraceCount); + + while( openParenCount > 0 ) + { + openParenCount--; + strIndentFiller += strIndentCharacters; + } + + while( openBraceCount > 0 ) + { + openBraceCount--; + strIndentFiller += strIndentCharacters; + } +} + +document.insertText( intStartLine, 0, strIndentFiller ); +view.setCursorPositionReal( intStartLine, document.textLine( intStartLine ).length ); diff --git a/kate/scripts/script-indent-c-test.js b/kate/scripts/script-indent-c-test.js new file mode 100644 index 000000000..5d506ca67 --- /dev/null +++ b/kate/scripts/script-indent-c-test.js @@ -0,0 +1,180 @@ +/**KATE + *NAME: C style indenter + *COPYRIGHT: + *Based on work Copyright 2005 by Dominik Haumann + *Copyright 2005 by Joseph Wenninger + *Here will be the license text, Dominik has to choose + * The following line is not empty + * + *An empty line ends this block + * + *VERSION: 0.1 + *ANUNKNOWNKEYWORD: Version has to be in the format major.minor (both numbers) + *IGNOREALSO: All keywords, except COPYRIGHT are expected to have their data on one line + *UNKNOWN: unknown keywords are simply ignored from the information parser + *CURRENTLY_KNOWN_KEYWORDS: NAME,VERSION, COPYRIGHT + *INFORMATION: This block has to begin in the first line at the first character position + *INFORMATION: It is optional, but at least all files within the kde cvs, + *INFORMATION: which are ment for publishing are supposed to have at least the + *INFORMATION: COPYRIGHT block + *INFORMATION: These files have to be stored as UTF8 + **/ + +/* +function indentChar() // also possible +{*/ + +function indentChar(c) +{ + var tabWidth = 4; + var spaceIndent = true; + var indentWidth = 4; + + + var line = view.cursorLine(); + var col = view.cursorColumn(); + + var textLine = document.textLine( line ); + var prevLine = document.textLine( line - 1 ); + + var prevIndent = prevLine.match(/^\s*/); + var addIndent = ""; + + function unindent() + { + // if ( + } + + // unindent } and {, if not in a comment + if ( textLine.search( /^\s*\/\// ) == -1 ) + { + if ( /*textLine.charAt( col-1 )*/ c == '}' || /*textLine.c( col-1 )*/ c == '{') + { + if ( textLine.search(/^\s\s\s\s/) != -1) + { + document.removeText( line, 0, line, tabWidth ); + view.setCursorPositionReal( line, col - tabWidth ); + } + } + } + +} + + +function firstNonSpace( _text ) +{ + for( _i=0; _i < _text.length; _i++ ) + { + _ch = _text.charAt( _i ); + if( _ch != ' ' && _ch != '\t' ) + return _i; + } + + return -1; +} + +function lastNonSpace( _text ) +{ + for( _i=_text.length - 1; _i >= 0; _i-- ) + { + _ch = _text.charAt( _i ); + if( _ch != ' ' && _ch != '\t' ) + return _i; + } + + return -1; +} + +function indentNewLine() +{ + var tabWidth = 4; + var spaceIndent = true; + var indentWidth = 4; + + var strIndentCharacters = " "; + var strIndentFiller = ""; + + var intStartLine = view.cursorLine(); + var intStartColumn = view.cursorColumn(); + + var strTextLine = document.textLine( intStartLine ); + var strPrevLine = document.textLine( intStartLine - 1 ); + + var addIndent = ""; + // if previous line ends with a '{' increase indent level + // if ( prevLine.search( /{\s*$/ ) != -1 ) + // { + // if ( spaceIndent ) + // addIndent = " "; + // else + // addIndent = "\t"; + // } + // else + { + var intCurrentLine = intStartLine; + var openParenCount = 0; + var openBraceCount = 0; + + label_while: + while ( intCurrentLine > 0 ) + { + intCurrentLine--; + + strCurrentLine = document.textLine( intCurrentLine ); + intLastChar = lastNonSpace( strCurrentLine ); + intFirstChar = firstNonSpace( strCurrentLine ) ; + + if ( strCurrentLine.search( /\/\// ) == -1 ) + { + + // look through line backwards for interesting characters + for( intCurrentChar = intLastChar; intCurrentChar >= intFirstChar; --intCurrentChar ) + { + ch = strCurrentLine.charAt( intCurrentChar ); + switch( ch ) + { + case '(': case '[': + if( ++openParenCount > 0 ) + break label_while; //return calcIndentInBracket( begin, cur, pos ); + break; + case ')': case ']': openParenCount--; break; + case '{': + if( ++openBraceCount > 0 ) + break label_while; //return calcIndentInBrace( begin, cur, pos ); + break; + case '}': openBraceCount--; lookingForScopeKeywords = false; break; + case ';': + if( openParenCount == 0 ) + lookingForScopeKeywords = false; + break; + } + } + } + } + + strIndentFiller += strCurrentLine.match(/^\s+/); + if ( strIndentFiller == "null" ) + strIndentFiller = ""; + + debug( "line: " + intCurrentLine); + debug( openParenCount + ", " + openBraceCount); + + while( openParenCount > 0 ) + { + openParenCount--; + strIndentFiller += strIndentCharacters; + } + + while( openBraceCount > 0 ) + { + openBraceCount--; + strIndentFiller += strIndentCharacters; + } + } + + document.insertText( intStartLine, 0, strIndentFiller ); + view.setCursorPositionReal( intStartLine, document.textLine( intStartLine ).length ); +} + +indenter.onchar=indentChar +indenter.onnewline=indentNewLine
\ No newline at end of file diff --git a/kate/scripts/script-indent-c1-test.lua b/kate/scripts/script-indent-c1-test.lua new file mode 100644 index 000000000..d2593b962 --- /dev/null +++ b/kate/scripts/script-indent-c1-test.lua @@ -0,0 +1,154 @@ +function indentChar(c) + katedebug("LUA indentChar has been called") + local tabWidth = 4 + local spaceIndent = true + local indentWidth = 4 + + local line=view.cursorLine() + local col=view.cursorColumn() + local textLine=document.textLine(line) + local prevLine=document.textLine(line-1); + + --local prevIndent=prevLine.match("^%s*") + --local addIndent="" + + + -- unindent } and {, if not in a comment + + if not(string.find(textLine,"^%s*//")) then + katedebug("no comment") + katedebug(c); + if (c=="}") or (c=="{") then + katedebug("} or { found"); + if (string.find(textLine,"^%s%s%s%s")) then + katedebug("removing one indentation level"); + document.removeText(line,0,line,tabWidth) + view.setCursorPositionReal(line,col-tabWidth) + else + katedebug("no indentation found"); + end + end + else + katedebug("in comment"); + end +end + + + + + +function indentNewLine() + local tabWidth = 4; + local spaceIndent = true; + local indentWidth = 4; + + local strIndentCharacters = " "; + local strIndentFiller = ""; + + local intStartLine, intStartColumn= view.cursorPosition(); + + local strTextLine = document.textLine( intStartLine ); + local strPrevLine = document.textLine( intStartLine - 1 ); + + local addIndent = ""; + + + local intCurrentLine = intStartLine; + local openParenCount = 0; + local openBraceCount = 0; + + + + function firstNonSpace( text ) + local pos=string.find(text,"[^%s]") + if pos then + return pos + else + return -1 + end + end + + function lastNonSpace (text) + local pos=string.find(text,"[^%s]%s*$") + if pos then + return pos + else + return -1 + end + end + + local strCurrentLine="" + local intCurrentLine=intStartLine + katedebug(intStartLine .. "-" .. intStartColumn) + function label_while() + katedebug("label_while has been entered: intCurrentLine" .. intCurrentLine) + while (intCurrentLine>0) do + --katedebug("intCurrentLine:" ..intCurrentLine) + intCurrentLine=intCurrentLine-1 + strCurrentLine=document.textLine(intCurrentLine) + intLastChar= lastNonSpace(strCurrentLine) + intFirstChar=firstNonSpace(strCurrentLine) + if not (string.find(strCurrentLine,"//")) then + for intCurrentChar=intLastChar,intFirstChar,-1 do + ch=string.sub(strCurrentLine,intCurrentChar,intCurrentChar) + if (ch=="(") or (ch=="[") then + openParenCount=openParenCount+1 + if (openParenCount>0) then + return label_while() + end + elseif (ch==")") or (ch=="]") then + openParenCount=openParenCount-1 + elseif (ch=="{") then + openBraceCount=openBraceCount+1 + if openBraceCount>0 then + return label_while() + end + elseif (ch=="}") then + openBraceCount=openBraceCount-1 + elseif (ch==";") then + if (openParenCount==0) then + lookingForScopeKeywords=false + end + end + end + end + end + end + + label_while() + + + + katedebug( "line: " .. intCurrentLine) + katedebug( openParenCount .. ", " .. openBraceCount) + + local ok,match=pcall(function () return string.sub(strCurrentLine,string.find(strCurrentLine,"^%s+")) end) + if ok then + katedebug("Line HAD leading whitespaces") + strIndentFiller=match + else + katedebug("Line had NO leading whitespaces") + strIndentFiller="" + end + + + while( openParenCount > 0 ) do + openParenCount=openParenCount-1 + strIndentFiller = strIndentFiller .. strIndentCharacters + end + + while( openBraceCount > 0 ) do + openBraceCount=openBraceCount-1; + strIndentFiller = strIndentFiller .. strIndentCharacters + end + + document.insertText( intStartLine, 0, strIndentFiller ) + view.setCursorPositionReal( intStartLine, string.len(document.textLine( intStartLine ))) +end + + + + + +indenter.register(indenter.OnChar,indentChar) +indenter.register(indenter.OnNewline,indentNewLine)
\ No newline at end of file diff --git a/kate/scripts/sort.js b/kate/scripts/sort.js new file mode 100644 index 000000000..41f2145fb --- /dev/null +++ b/kate/scripts/sort.js @@ -0,0 +1,18 @@ +if( view.hasSelection() ) +{ + start = view.selectionStartLine; + end = view.selectionEndLine; + + txt = document.textRange( start, 0, end, document.lineLength( end ) ); + + repl = txt.split("\n"); + repl.sort(); + txt = repl.join("\n"); + + view.clearSelection(); + + document.editBegin(); + document.removeText( start, 0, end, document.lineLength( end ) ); + document.insertText( start, 0, txt ); + document.editEnd(); +}
\ No newline at end of file diff --git a/kate/scripts/test.js b/kate/scripts/test.js new file mode 100644 index 000000000..acc3b94e3 --- /dev/null +++ b/kate/scripts/test.js @@ -0,0 +1,16 @@ +var test = 1; + +var start = document.lines () + +document.editBegin(); + +for (var t = 0; t < 100; t++) +{ + document.insertLine (start+t, document.lineLength(0)); + document.insertText (start+t, 0, " muh"); + document.insertText (start+t, 0, view.cursorLine()); + document.insertText (start+t, 0, "// "); +} + +document.editEnd(); + diff --git a/kate/scripts/test_selectioniface.js b/kate/scripts/test_selectioniface.js new file mode 100644 index 000000000..c447976bb --- /dev/null +++ b/kate/scripts/test_selectioniface.js @@ -0,0 +1,26 @@ +// If you select some text before running the script, this line will be overwritten. +if ( view.hasSelection() ) +{ + document.removeText( 0, 0, 0, document.lineLength(0) ); + document.insertText( 0, 0, "// initial selection: " + view.selectionStartLine + "," + view.selectionStartColumn + " - " + view.selectionEndLine + "," + view.selectionEndColumn ); +} +// test selection interface +view.selectAll(); +view.setSelection( 0, 0, 0, 20 ); +view.clearSelection(); + +// insert some text and select that +var line = document.lines(); +document.insertLine( line, "foo" ); +document.insertText( line, 0, "// This is a new line" ); +view.setSelection( line, 0, line, document.lineLength(line) ); +// Delete that text +view.removeSelectedText(); + +// insert some text and select that +var line = document.lines(); +document.insertLine( line, "bar" ); +document.insertText( line, 0, "// This is a new line" ); +view.setSelection( line, 0, line, document.lineLength(line) ); + +document.insertText( line, document.lineLength( line ), " Selection is " + view.selectionStartLine + "," + view.selectionStartColumn + " - " + view.selectionEndLine + "," + view.selectionEndColumn ); |