From 215ee372b0f2ae4d99e5f73d8aea89ac8b9062c2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Rekucki?= Date: Mon, 21 Sep 2009 13:57:10 +0200 Subject: [PATCH] =?utf8?q?Autokorekta:=20inteligentne=20wstawianie=20tagow?= =?utf8?q?,=20usuwanie=20spacji=20po=20i=20przed=20iterpunkcj=C4=85.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- apps/toolbar/fixtures/przyciski.xml | 50 ++++++++++++++++------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/apps/toolbar/fixtures/przyciski.xml b/apps/toolbar/fixtures/przyciski.xml index f359d669..737ef313 100755 --- a/apps/toolbar/fixtures/przyciski.xml +++ b/apps/toolbar/fixtures/przyciski.xml @@ -148,7 +148,7 @@ Podstawowa basic_correction - [["fulltextregexp", {"exprs": [["\ufeff", ""], ["$[\\s]*\\d+[\\s]*^", ""], ["-\\s*^", ""], ["\\,\\.\\.|\\.\\,\\.|\\.\\.\\,", "..."]]}], ["lineregexp", {"exprs": [["^\\s+|\\s+$", ""], ["\\s+", " "], ["(,,)\\s+|\\s+(\")", "$1"], ["(\\d)[\u2014-](\\d)", "$1--$2"], ["\u2014", "---"], ["<(/?)P([aert])", "<$1p$2"], ["([^\\.])(\\s*)</p", "$1.$2</p"]]}]] + [["fulltextregexp", {"exprs": [["\ufeff", ""], ["$[\\s]*\\d+[\\s]*^", ""], ["-\\s*^", ""], ["\\,\\.\\.|\\.\\,\\.|\\.\\.\\,", "..."]]}], ["lineregexp", {"exprs": [["^\\s+|\\s+$", ""], ["\\s+", " "], ["(,,)\\s+|\\s+(\")", "$1"], ["(\\d)[\u2014-](\\d)", "$1--$2"], ["\u2014", "---"], ["<(/?)P([aert])", "<$1p$2"], ["([^\\.])(\\s*)</p", "$1.$2</p"], ["([,\\.:;!\\?])([^\\s\\\\])", "$1 $2"], ["([^\\s])\\s+([,\\.:;!\\?])", "$1$2"]]}]] macro @@ -990,7 +990,7 @@ Zamień dywiz zamien_dywiz - {"exprs": [["(\\s)-(\\s)", "$1---$2"], ["^(\\s*)-(\\s)", "$1---$2"], ["(\\s)-(\\s*)$", "$1---$2"], ["(\\d)[\u2014-](\\d)", "$1--$2"], ["\u2014", "---"]]} + {"exprs": [["(\\s)-(\\s)", "$1---$2"], ["^(\\s*)-(\\s)", "$1---$2"], ["(\\s)-(\\s*)$", "$1---$2"], ["(\\d)[\u2014\u2013\u2010-](\\d)", "$1--$2"], ["\u2014\u2013\u2010", "---"]]} lineregexp @@ -1015,39 +1015,45 @@ var texteditor = panel.texteditor; - var text = texteditor.selection(); - -var out = '<'+params.tag; - +var start_tag = '<'+params.tag; for (var attr in params.attrs) { - - out += ' '+attr+'="' + params.attrs[attr] + '"'; - + start_tag += ' '+attr+'="' + params.attrs[attr] + '"'; }; +start_tag += '>'; +var end_tag = '</'+params.tag+'>'; -out += '>'; - -out += text; - -out += '</' + params.tag + '>'; - - +// tokenize +var output = '' +var token = '' +for(var index=0; index < text.length; index++) +{ + if (text[index].match(/\s/)) { // whitespace + token += text[index]; + } + else { // character + output += token; + if(output == token) output += start_tag; + token = '' + output += text[index]; + } +} -texteditor.replaceSelection(out); +if( output[output.length-1] == '\\' ) { + output = output.substr(0, output.length-1) + end_tag + '\\'; +} else { + output += end_tag; +} +output += token; +texteditor.replaceSelection(output); if (text.length == 0) { - var pos = texteditor.cursorPosition(); - texteditor.selectLines(pos.line, pos.character + params.tag.length + 2); - } - - panel.fireEvent('contentChanged'); -- 2.20.1