Home Coding, Scripting, Shaders

Code blocks

I was deep in the site plumbing doing some prep work (shhh) and figured I'd try to fix our ugly code blocks. Not sure if I really made it better :flushed:
... open to sugggestions.

Before:



Now:


Replies

  • poopipe
    Options
    Offline / Send Message
    poopipe grand marshal polycounter
    I'm not sure the pink sits well against the grey in either example. Reducing the contrast between line colors is a solid idea but I think you've gone too close to 0.5 and you risk making the keywords etc. hard to pick out. 


  • Pac_187
    Options
    Offline / Send Message
    Pac_187 polycounter lvl 11
    Keeping it dark is always welcome on my side.

    The alternating rows are kinda irritating/too prominent. Right now they totally kill the curly brace in the second line.
    Line numbers are only written every 5th line, they should be written in every line.
    Highlighted text (especially the red/pink) is hard to read on the dark background.

    On the other hand I don't really know how useful this highlighting really is in a forum.
    I think a lot of effort needs to be put in, in order to make it properly work (just think about supporting different languages!)
    It might be easier to have the codeblock display the code with a monospaced font and that's it.

    I even fail to get it running on my end, as you can see:
    fn doStuff = (<br>&nbsp;&nbsp;&nbsp; local sel = selection as array<br>&nbsp;&nbsp;&nbsp; if ((mod sel.count 2) > 0) then <br>&nbsp;&nbsp;&nbsp; (<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "selection not devideable by two"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return undefined<br>&nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp;&nbsp; local offset = sel.count/2<br>&nbsp;&nbsp;&nbsp; for i=1 to offset do <br>&nbsp;&nbsp;&nbsp; (<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print ("Replacing '" + sel[i].name + "' with '" + sel[i + offset].name + "'")<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; replaceInstances sel[i] sel[i + offset]<br>&nbsp;&nbsp;&nbsp; )<br>)

  • Klunk
    Options
    Offline / Send Message
    Klunk ngon master
    can you lose the alternating background colours ?
  • Eric Chadwick
    Options
    Offline / Send Message
    Good suggestions. Seems better now. I don't have control over line numbering, unfortunately.
    I could go through every text-color style and make them the same dark gray, but that's probably a lot of work.


  • Eric Chadwick
    Options
    Offline / Send Message
    1. Format dropdown, choose Code.
    2. Paste some code.
    3. Preview (looks OK)
    4. Post Reply
    import MaxPlus
    
    somethingHappened = False
    
    
    def doSomething():
        global somethingHappened
        somethingHappened = True
        print "I sleep all night and I work all day!"
    
    
    def printAction(a):
        print "id ", a.Id
        print "button text ", a.ButtonText
        print "menu text ", a.MenuText
        print "description ", a.Description
        print "category ", a.Category
        print "checked ", a.Checked
        print "indeterminate ", a.Indeterminate
        print "visible ", a.Visible
        print "enabled ", a.Enabled
        print "dynamic ", a.Dynamic
        print "shortcut ", a.Shortcut
    
    action = MaxPlus.ActionFactory.Create(
        'Do something', 'Python demo', doSomething)
    printAction(action)
    
    assert(not somethingHappened)
    action.Execute()
    assert(somethingHappened)
    action.Execute()
    assert(somethingHappened)

    If you want to copy stuff out of an existing codeblock and put it in a new codeblock in your reply, it seems to need an extra step:
    1. Copy the contents of someone's codeblock.
    2. Format dropdown, choose Code. 
    3. Toggle HTML View. 
    4. Paste in between code and /code.
    import MaxPlus somethingHappened = False def doSomething(): global somethingHappened somethingHappened = True print "I sleep all night and I work all day!" def printAction(a): print "id ", a.Id print "button text ", a.ButtonText print "menu text ", a.MenuText print "description ", a.Description print "category ", a.Category print "checked ", a.Checked print "indeterminate ", a.Indeterminate print "visible ", a.Visible print "enabled ", a.Enabled print "dynamic ", a.Dynamic print "shortcut ", a.Shortcut action = MaxPlus.ActionFactory.Create( 'Do something', 'Python demo', doSomething) printAction(action) assert(not somethingHappened) action.Execute() assert(somethingHappened) action.Execute() assert(somethingHappened) If you don't do that, it kind of barfs:
    1. Copy the contents of someone's codeblock.
    2. Format dropdown, choose Code. 
    3. Paste.
    1. import MaxPlus
    2. somethingHappened = False
    3. def doSomething():
    4. global somethingHappened
    5. somethingHappened = True
    6. print "I sleep all night and I work all day!"
    7. def printAction(a):
    8. print "id ", a.Id
    9. print "button text ", a.ButtonText
    10. print "menu text ", a.MenuText
    11. print "description ", a.Description
    12. print "category ", a.Category
    13. print "checked ", a.Checked
    14. print "indeterminate ", a.Indeterminate
    15. print "visible ", a.Visible
    16. print "enabled ", a.Enabled
    17. print "dynamic ", a.Dynamic
    18. print "shortcut ", a.Shortcut
    19. action = MaxPlus.ActionFactory.Create(
    20. 'Do something', 'Python demo', doSomething)
    21. printAction(action)
    22. assert(not somethingHappened)
    23. action.Execute()
    24. assert(somethingHappened)
    25. action.Execute()
    26. assert(somethingHappened)

  • Pac_187
    Options
    Offline / Send Message
    Pac_187 polycounter lvl 11
    Idk this whole html toggle thing is super annoying.

    I can only get the code thing to work if I:
    1. Format -> Code
    2. Go to HTML View
    3. Paste code between code /code
    4. Hit Preview
    5. Reply

    Also the list above^ is a numbered list, but it doesn't show like this in the preview as you can see on the screenshot down below:



    I'm on Firefox if that makes any sense.
  • Eric Chadwick
    Options
    Offline / Send Message
    Yeah I get the same, here on Windows/Chrome. Sorry there's not much I can do about it. Vanilla hasn't been a great host for us, and we have a plan for moving, but we're a bit hamstrung for a variety of reasons as far as actually making it happen.
  • Pac_187
    Options
    Offline / Send Message
    Pac_187 polycounter lvl 11
    I see.
    None the less, thank you Eric for taking the initiative to improve codeblock, the changes so far look better :)
  • onionhead_o
    Options
    Offline / Send Message
    onionhead_o polycounter lvl 16
    thank you for addressing the Code issue
  • Eric Chadwick
    Options
    Offline / Send Message
    Sure! Petting the sweaty stuff, that's how we roll. 
Sign In or Register to comment.