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).

1  
!7
2  
3  
sS snippetID = #1008122;
4  
sS editorCommand = "idea"; //"jedit";
5  
static File tempFile;
6  
7  
p {
8  
  if (nempty(args)) snippetID = fsI(args[0]);
9  
  tempFile = getProgramFile(parseSnippetID(snippetID) + ".javax");
10  
  S text = loadSnippet(snippetID);
11  
  saveTextFile(tempFile, text);
12  
  long lastMod = tempFile.lastModified();
13  
  nohup(editorCommand + " " + platformQuote(tempFile));
14  
  print("Launched editor. Watching file for changes...");
15  
  repeat with ms sleep 100 {
16  
    long mod = tempFile.lastModified();
17  
    if (mod != lastMod) loading {
18  
      long newMod = mod;
19  
      int mods = 0;
20  
      do {
21  
        sleep(100);
22  
        newMod = tempFile.lastModified();
23  
        ++mods;
24  
      } while (newMod != mod);
25  
      if (mods > 1) warn("Editor doesn't save atomically. Mod count: " + mods);
26  
      JWindow box = infoBox("Uploading...");
27  
      S newText = loadTextFile(tempFile);
28  
      try {
29  
        lastMod = newMod;
30  
        if (neq(text, newText)) {
31  
          print("EDITING " + snippetID + " (" + l(text) + " -> " + l(newText) + " chars)");
32  
          text = newText;
33  
          editSnippet(snippetID, text);
34  
          infoBox("UPLOADED " + snippetWithTitle(snippetID));
35  
        }
36  
      } catch e {
37  
        infoBox(e);
38  
      } finally {
39  
        text = newText;
40  
        disposeWindow(box);
41  
      }
42  
    }
43  
  }
44  
}

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: 469 / 530
Version history: 13 change(s)
Referenced in: [show references]