File indexing completed on 2024-05-12 16:41:19

0001 // insert/remove tests
0002 //
0003 // Needs original 'scripting-test.tex' as current tex file opened in Kile.
0004 // Kile should be started from the command line to view the results.
0005 
0006 print();
0007 print( "Test: insert/remove...");
0008 
0009 var line = 9;
0010 var col = 12;
0011 var add = "(ABC) ";
0012 var originalText = "Hi, this is some text...";
0013 var changedText = "Hi, this is " + add + "some text...";
0014 
0015 insertTest(line,col);
0016 
0017 print("finished");
0018 print();
0019 
0020 
0021 function insertTest(line,col)
0022 {
0023         var c1 = new Cursor(line,col);
0024         var c2 = new Cursor(line,col+6);
0025         var r = new Range(line,col,line,col+6);
0026 
0027         document.insertText(line,col,add);
0028         var text1 = document.line(line);
0029         if ( text1 != changedText ) {
0030                 print ("text added 1:  " + text1 + "  expected: "+changedText);
0031         }
0032 
0033         document.removeText(r);
0034         var text2 = document.line(line);
0035         if ( text2 != originalText ) {
0036                 print ("text removed 1:  " + text2 + "  expected: "+originalText);
0037         }
0038 
0039         document.insertText(c1,add);
0040         var text3 = document.line(line);
0041         if ( text3 != changedText ) {
0042                 print ("text added 2:  " + text3 + "  expected: "+changedText);
0043         }
0044 
0045         document.removeText(c1,c2);
0046         var text4 = document.line(line);
0047         if ( text4 != originalText ) {
0048                 print ("text removed 2:  " + text4 + "  expected: "+originalText);
0049         }
0050 
0051 }
0052