Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

44
LINES

< > BotCompany Repo | #1008123 // Use External Editor For Snippet Editing [dev.]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (3179L/22K/81K).

!7

sS snippetID = #1008122;
sS editorCommand = "idea"; //"jedit";
static File tempFile;

p {
  if (nempty(args)) snippetID = fsI(args[0]);
  tempFile = getProgramFile(parseSnippetID(snippetID) + ".javax");
  S text = loadSnippet(snippetID);
  saveTextFile(tempFile, text);
  long lastMod = tempFile.lastModified();
  nohup(editorCommand + " " + platformQuote(tempFile));
  print("Launched editor. Watching file for changes...");
  repeat with ms sleep 100 {
    long mod = tempFile.lastModified();
    if (mod != lastMod) loading {
      long newMod = mod;
      int mods = 0;
      do {
        sleep(100);
        newMod = tempFile.lastModified();
        ++mods;
      } while (newMod != mod);
      if (mods > 1) warn("Editor doesn't save atomically. Mod count: " + mods);
      JWindow box = infoBox("Uploading...");
      S newText = loadTextFile(tempFile);
      try {
        lastMod = newMod;
        if (neq(text, newText)) {
          print("EDITING " + snippetID + " (" + l(text) + " -> " + l(newText) + " chars)");
          text = newText;
          editSnippet(snippetID, text);
          infoBox("UPLOADED " + snippetWithTitle(snippetID));
        }
      } catch e {
        infoBox(e);
      } finally {
        text = newText;
        disposeWindow(box);
      }
    }
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1008123
Snippet name: Use External Editor For Snippet Editing [dev.]
Eternal ID of this version: #1008123/14
Text MD5: ff4b27a1d2c59ace157ccf66d2dd6820
Transpilation MD5: 5ac7fe2d16c28e82222f17be8b78eb6e
Author: stefan
Category: javax / editing
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-05-27 13:27:41
Source code size: 1337 bytes / 44 lines
Pitched / IR pitched: No / No
Views / Downloads: 466 / 523
Version history: 13 change(s)
Referenced in: [show references]