Beispiel #1
0
 /**
  * Performs a search.
  *
  * @param sc search context
  * @param jump jump to next hit
  */
 final void search(final SearchContext sc, final boolean jump) {
   try {
     rend.search(sc);
     if (!sc.search.isEmpty()) gui.status.setText(Util.info(Text.STRINGS_FOUND_X, sc.nr()));
     if (jump) jump(SearchDir.CURRENT, false);
   } catch (final Exception ex) {
     final String msg = Util.message(ex).replaceAll(Prop.NL + ".*", "");
     gui.status.setError(Text.REGULAR_EXPR + Text.COLS + msg);
   }
 }
Beispiel #2
0
 /**
  * Returns the clipboard text.
  *
  * @return text
  */
 private static String clip() {
   // copy selection to clipboard
   final Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
   final Transferable tr = clip.getContents(null);
   if (tr != null) {
     final ArrayList<Object> contents = BaseXLayout.contents(tr);
     if (!contents.isEmpty()) return contents.get(0).toString();
   } else {
     Util.debug("Clipboard has no contents.");
   }
   return null;
 }
Beispiel #3
0
 /** Reads in the property file. */
 static {
   try {
     final String file = "/completions.properties";
     final InputStream is = TextPanel.class.getResourceAsStream(file);
     if (is == null) {
       Util.errln(file + " not found.");
     } else {
       try (final NewlineInput nli = new NewlineInput(is)) {
         for (String line; (line = nli.readLine()) != null; ) {
           final int i = line.indexOf('=');
           if (i == -1 || line.startsWith("#")) continue;
           final String key = line.substring(0, i), value = line.substring(i + 1);
           if (REPLACE.put(key, value.replace("\\n", "\n")) != null) {
             Util.errln(file + ": " + key + " was assigned twice");
           }
         }
       }
     }
   } catch (final IOException ex) {
     Util.errln(ex);
   }
 }
Beispiel #4
0
 /**
  * Replaces the text.
  *
  * @param rc replace context
  */
 final void replace(final ReplaceContext rc) {
   try {
     final int[] select = rend.replace(rc);
     if (rc.text != null) {
       final boolean sel = editor.selected();
       setText(rc.text);
       editor.select(select[0], select[sel ? 1 : 0]);
       release(Action.CHECK);
     }
     gui.status.setText(Text.STRINGS_REPLACED);
   } catch (final Exception ex) {
     final String msg = Util.message(ex).replaceAll(Prop.NL + ".*", "");
     gui.status.setError(Text.REGULAR_EXPR + Text.COLS + msg);
   }
 }