File indexing completed on 2024-05-12 16:41:02
0001 // Surround selected text with a TeX command 0002 // Relative cursor position will not be changed. 0003 // 0004 // abc --> \texcommand{abc} 0005 0006 var range = view.selectionRange(); 0007 //print( "range = " + range.toString() ); 0008 0009 if ( range.isValid() ) { 0010 var cmd = kile.input.getLatexCommand("Choose","Choose surrounding LaTeX command:"); 0011 // print("cmd: "+ cmd); 0012 if ( cmd != "" ) { 0013 surroundTexCommand("\\"+cmd,range); 0014 } 0015 } 0016 else { 0017 kile.alert.sorry("No selection found."); 0018 } 0019 0020 function surroundTexCommand(cmd,r) 0021 { 0022 var c = view.cursorPosition(); 0023 0024 document.editBegin(); 0025 view.clearSelection(); 0026 document.insertText(r.end,"}"); 0027 document.insertText(r.start,cmd+"{"); 0028 0029 c.column = c.column + cmd.length + 2; 0030 view.setCursorPosition(c); 0031 document.editEnd(); 0032 }