options = new Object[6]; options[0] = "h1"; options[1] = "h2"; options[2] = "h3"; options[3] = "h4"; options[4] = "h5"; options[5] = "h6"; text = JOptionPane.showInputDialog(view, "Create menu from headings", "Select level", JOptionPane.QUESTION_MESSAGE, null, options, options[1]); /*String text = Macros.input(view, "Select Heading:");*/ if(text == null || "".equals(text)) return; tag=text; text = ""; int count = 0; StringBuffer buff = new StringBuffer(); for(int i = 0; i < buffer.getLineCount(); i++){ String line = buffer.getLineText(i); if(line.indexOf(text) > -1){ if (count>0) buff.append('\n').append(line.trim()); else buff.append(line.trim()); count++; } } Registers.setRegister('$',buff.toString()); HistoryModel.getModel("clipboard").addItem(buff.toString().substring(1)); view.getStatus().setMessageAndClear("" + count + " lines copied to clipboard"); // paste and select if (textArea.getSelectedText()==null) { // remember caret position startPosition = textArea.getCaretPosition(); } else { // remember selection start if( textArea.getSelectionCount() > 0 ){ sel = textArea.getSelection(0); startPosition = sel.getStart(); } } //paste Registers.paste(textArea,'$',false); // set selection textArea.setSelection(new Selection.Range(startPosition, textArea.getCaretPosition())); // replace h to li and a SearchAndReplace.setSearchString("<"+tag+" id=\"([^\"]+)\">([^<]+)"+text); SearchAndReplace.setReplaceString("\"
  • \"+_2+\"
  • \""); SearchAndReplace.setBeanShellReplace(true); SearchAndReplace.setIgnoreCase(true); SearchAndReplace.setRegexp(true); SearchAndReplace.replace(view);