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

39
LINES

< > BotCompany Repo | #1034706 // G22ProjectStoryEditor backup 2

JavaX fragment (include) [tags: use-pretranspiled]

Uses 1485K of libraries. Click here for Pure Java version (35189L/229K).

srecord noeq G22ProjectStoryEditor(G22Utils g22utils) {
  JSyntaxTextFileEditor editor;

  File textFile() { ret g22utils.projectStoryTextFile(); }
  
  IVarWithNotify<S> varText() { ret textFileAsVarWithNotify(textFile()); }
  
  cachedVisualize {
    editor = new JSyntaxTextFileEditor(textFile()).autoSave(true);
    
    // debug modelToToken
    editor.makeSyntaxTextAreaWithSearch = ->
      new RSyntaxTextAreaWithSearch(new RSyntaxTextArea(1, 10) {
        public org.fife.ui.rsyntaxtextarea.Token modelToToken(int ofs) {
          var token = super.modelToToken(ofs);
          printVars("modelToToken", +ofs, +token);
          ret token;
        }
      });
    
    // react to HyperlinkEvent
    // problems:
    // -RSyntaxTextArea only fires these events when ctrl is pressed
    // -RSyntaxTextArea expects the token to be a url with protocol
    // So we'll have to make our own hyperlink mechanism...
    editor.adaptSyntaxTextArea = textArea -> {
      ((RSyntaxDocument) textArea.getDocument()).setSyntaxStyle(new HashRefTokenMaker);
      textArea.addHyperlinkListener(evt -> {
        print("Hyperlink event");
        if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
          infoBox("Link URL: " + evt.getURL());
        }
      });
    };
    ret withTopAndBottomMargin(jRaisedCenteredSection("Project Story",
      editor.visualize()
    ));
  }
}

Author comment

Began life as a copy of #1034688

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

-
Snippet ID: #1034706
Snippet name: G22ProjectStoryEditor backup 2
Eternal ID of this version: #1034706/1
Text MD5: a416017a837d49075e55696424d14f2f
Transpilation MD5: 31f4cd5ca447efa6feccb58ab45652e5
Author: stefan
Category: javax / gazelle 22
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-06 00:00:11
Source code size: 1427 bytes / 39 lines
Pitched / IR pitched: No / No
Views / Downloads: 135 / 194
Referenced in: