Shop OBEX P1 Docs P2 Docs Learn Events
SPIN autoindent? — Parallax Forums

SPIN autoindent?

fkifki Posts: 10
edited 2011-08-11 10:28 in Propeller 1
After hacking SPIN code, i sometimes end up with code, that is indented "enough" for beeing correct, but is no longer easy to read. Is there a tool to keep the code functioning and "re-indenting" with the TABS from the preference settings?

Would it be a feature you'd like too? [in the Propeller Tool]

Or are your spin files always looking nice?

Comments

  • potatoheadpotatohead Posts: 10,261
    edited 2011-08-11 06:09
    In the preferences, have you got Show Block Group Indicators checked?

    If so, the tool will show you how the code is broken into blocks.

    When writing, use the tab stops, and the occasional double or triple space indent. Changes then are generally a coupla key presses to complete.

    There is also a keypress combination that will allow you to move entire blocks of code. I forget what that is though. Somebody here will chime in, or we both can search!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-11 08:13
    fki,

    I'm not sure what you're asking for here. If it's what I think it is, it would be impossible for the IDE to auto-indent your code for you from a block of left-aligned text, because the indentation is the only syntax cue for where the blocks are in the first place.

    Pursuant to potatohead's comment, you can indent/unindent whole chunks of code by selecting multiple lines and pressing TAB to indent, shift-TAB to unindent.

    -Phil
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-08-11 10:13
    Phil, he is asking for a "pretty printer" mode for the Spin tool. It is possible to conform to Spin's indention rules, but produce source that could use some beautifying. Here's an example of a working dec routine.
    PUB dec(value) | i, x
             x := value == NEGX
     if value < 0
        value := {
    }       ||(value+x)                                                      
      ser.tx("-")                                                                    
     i := 1_000_000_000                                                           
    repeat 10                                                                    
       if value => i                                                               
          ser.tx(value / i {
    }   + "0" + x*(i == 1))                                         
                  value //= i                                                              
        result~~                                                                  
       elseif result or i == 1
                   ser.tx("0")                                                                  
     i /= 10
    
  • Heater.Heater. Posts: 21,230
    edited 2011-08-11 10:25
    Dave,
    Great, obfuscated Spin:)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-11 10:28
    Dave,

    Okay, yes, I see what you mean.

    -Phil
Sign In or Register to comment.