• Please stop embedding files/images from Discord. Discord has anti-hotlinking logic in place that breaks links to Discord hosted files and images when linked to from anywhere outside of Discord. There are a multitude of file/image hosting sites you can use instead.

    (more info here)
Noxid
Reaction score
0

Profile posts Postings Media Albums About

  • Noxid said:
    How should I set up a JTextPane so that the syntax highlighter can re-colour it when you change the text by typing or pasting something or whatever?

    Uh, lemme think.
    I used the Style class (http://www.exampledepot.com/egs/javax.swing.text/style_HiliteWords2.html) to make syntax highlighting in the Assembler.

    This is what I did to make it activate upon typing:
    Code:
        private void textBoxKeyReleased(java.awt.event.KeyEvent evt) {                                    
            if (useSyntaxColorsCheckBox.isSelected())
                [COLOR="DarkGreen"]syntaxObj1.styleAsmCodeInLine(textBox,textBox.getCaretPosition());[/COLOR]
        }

    Whenever a key on the keyboard is released by the user, I use my syntax object (see file SyntaxColorTools.java in the Assembler source code) to colorize the syntax for the current line (but NOT for the whole document, because that is really slow).

    [I used keyRelease instead of keyPress because keyPress causes chronological issues - checking for a typed character when the character does not exist yet.]

    When a paste occurs, you have to recolor the whole document, or the at the very least, the chunk of text that was pasted.

    This is what I did. I removed the default Ctrl+V action (which is just paste) and replace it with my own action (Paste, and then color syntax).
    Code:
    [B]//INSIDE THE CONSTRUCTOR FOR THE GUI:[/B]
            //Override the paste action (Ctrl+V) with our own system of handling
            //pasting. We need a custom paste action for syntax coloration.
            textBox.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_V,
                                      KeyEvent.CTRL_MASK),"none");

    Custom Ctrl+V action:

    Code:
        private void pasteActionPerformed(java.awt.event.ActionEvent evt) {                                      
            if (isIndentEditorSelected()) {
                makeIndentBoxVisible();
                indentEditorPane.paste();
            } else {
                makeTextBoxVisible();
                textBox.paste();
            }
            [COLOR="Green"]refreshSyntaxColorationBasedOnCheckBox();[/COLOR]
        }

    So basically, you have to write event listeners for KeyReleased and the Ctrl+V shortcut for your textPane, then run those necessary methods.
    Sorry. I usually edit, but I was lazy and didn't have my mouse at the time. :F
    Hey what does the + by your name mean? I thought it meant mod but I know CF isn't one and he has it too.
    I see that you are notactuallyon, but guppy.
    Also early gratz on 2k.

    (you really slaughtered that recovery plan)
    I dunno. It was sort of a weird thought process. I was just thinking about the nerdfighters/vlogbrothers (pretty much the only thing I use youtube for besides music), and how many interesting topics they cover. I considered if I had had the idea first, instead of them, what would have happened, but my brother is not nearly nerdy enough for something like that to sustain itself.

    Hence that comment.


    Obviously what you are saying makes much more sense. I have previously spoken about how awesome my brother is, but in general I think it's a shame that for any opportunities we get, there are infinitely more that we don't.
    Like, in the options menu, how you can adjust the frequency of the instrument.
    Noxid, do you know if Cave Story's org engine supports wave frequencies?
    More importantly, does your hack support them?
    you put it in the facepic thread, not the expand our repetoir thread

    is what ui meany
    Cool! So the giant smoke effect is a function? That makes sense.
    So I just call my own function in place of that. Thanks, nox!
    Oh wait, there's an offset for the death sequence, right? I'm guessing it's in the compendium?
    Hey nox, you gender bender. (Not an insult, I'm talking about your avatar.)
    Anyway, you changed the death animation for king in KS, right?
    How did you do that? Do you create an entity with king's death sprite or something? I'd like to do the same type of thing for MS, since witches don't spontaneously explode.
    Oh, and I'm not trying to steal your death sequence thing (that blood effect is pretty cool).
  • Loading…
  • Loading…
  • Loading…
  • Loading…
Back
Top