diff --git a/lib/resource-0.6/abstract/TestHTML.gf b/lib/resource-0.6/abstract/TestHTML.gf new file mode 100644 index 000000000..356f71d75 --- /dev/null +++ b/lib/resource-0.6/abstract/TestHTML.gf @@ -0,0 +1,12 @@ +abstract TestHTML = Structural ** { + +-- a random sample of lexicon to test resource grammar with + +cat HTMLdoc; HTMLtag; + +fun + htmlText: HTMLtag -> HTMLtag -> HTMLdoc; + head, body: HTMLtag; + +} ; + diff --git a/lib/resource-0.6/russian/TestHTMLrus.gf b/lib/resource-0.6/russian/TestHTMLrus.gf new file mode 100644 index 000000000..8ccf8a87d --- /dev/null +++ b/lib/resource-0.6/russian/TestHTMLrus.gf @@ -0,0 +1,16 @@ +-- use this path to read the grammar from the same directory +--# -path=.:../abstract:../../prelude +concrete TestHTMLrus of TestHTML = StructuralRus ** open SyntaxRus in { + +flags + coding=utf8 ; + startcat=HTMLdoc ; lexer=text ; parser=chart ; unlexer=text ; + +-- a random sample from the lexicon + +lin + body = {s= "
" ++"Это тело" ++ " "}; + head = {s= " " ++ "Это голова \" ++ " "}; + htmlText x y = {s= " "++ x.s ++ " " ++ y.s ++ " "}; + +}; diff --git a/src/JavaGUI/GFEditor2.java b/src/JavaGUI/GFEditor2.java index bd7830220..f1c162bc4 100644 --- a/src/JavaGUI/GFEditor2.java +++ b/src/JavaGUI/GFEditor2.java @@ -32,12 +32,17 @@ public class GFEditor2 extends JFrame implements ActionListener, CaretListener, public MouseEvent m2; public static String selectedText=""; + // XML parsing: public static boolean debug = false; + // pop-up/mouse handling: public static boolean debug3 = false; + // linearization marking: public static boolean debug2 = true; + public static boolean selectionCheck = false; public static LinPosition focusPosition ; public static String stringToAppend = ""; + //stack for storing the current position: public static Vector currentPosition = new Vector(); public static int selStart = -1; @@ -1803,17 +1808,22 @@ public class GFEditor2 extends JFrame implements ActionListener, CaretListener, }//not null selection } + /* + s - string to append + selectionStart, selectionEnd - selection coordinates + (focus tag is already cut) + */ public static void appendMarked(String s, int selectionStart, int selectionEnd) { if (s.length()>0) { if (debug2) + { System.out.println("STRING: "+s); - if (debug2) System.out.println("where selection start is: "+selectionStart); - if (debug2) System.out.println("where selection end is: "+selectionEnd); - if (debug2&&(selectionStart>-1)) - System.out.println("where selection is: "+s.substring(selectionStart,selectionEnd)); + if ((selectionStart>-1)&&(selectionEnd>selectionStart)) + System.out.println("where selection is: "+s.substring(selectionStart,selectionEnd)); + } currentLength = 0; newLength=0; oldLength = output.getText().length(); @@ -1821,15 +1831,15 @@ public class GFEditor2 extends JFrame implements ActionListener, CaretListener, restString = s; int m2, m1; LinPosition position ; -// if ((selectionStart>-1)&&(selectionEnd>=selectionStart)) + if (selectionStart>-1) { selStart = selectionStart; selEnd = selectionEnd; if (debug2) - System.out.println("SELECTION: " + selStart + " "+selEnd+ "TOTAL: "+s.length()); + System.out.println("SELECTION: " + selStart + " "+selEnd+ "TOTAL: "+s.length()); if (selEnd>selStart) - selectionCheck = (s.substring(selStart, selEnd).indexOf("<")==-1); + selectionCheck = (getCharacter(s.substring(selStart, selEnd),"<",0)==-1); l = restString.indexOf("