Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    DWC 3.2, gcode editor issue

    Scheduled Pinned Locked Moved
    Duet Web Control
    5
    6
    374
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • garyd9undefined
      garyd9
      last edited by

      Conditional gcode (at least with DSF) is very sensitive to the difference between spaces and tabs for conditional blocks of code. For that reason, if the DWC gcode editor is going to autoindent on new lines, it needs to either differentiate between space and tab characters, or it needs to automatically replace 'tab' characters with spaces.

      For example, assume I type the following in the gcode editor. All characters are as typed, with special keys using angled braces (ie: <backspace>, <tab>, <return>):

      while true<return>
      <tab>echo "test 1"<return>
      echo "test 2"<return>

      What happens above is that after the line that echo's "test 1", the gcode editor is helpfully auto-indenting the next line. However, it's NOT using a tab character to indent, and instead inserting 4 spaces. The resulting gcode LOOKS okay and with proper indenting, but it's NOT because the echo of "test 1" is preceded by a single tab character and the echo of "test 2" is preceded by 4 space characters.

      This results in some very odd things happening when running conditional gcode that appears to be perfect (and debugging it isn't fun.)

      Suggestion: Either the gcode editor should copy the characters used to indent the previous line, OR it should re-write TAB characters to sequences of spaces (which is probably easier than re-writing sequences of spaces to tabs.) Or, perhaps it should use it's syntax highlighting to change the background color of TAB characters to make it obvious that something is different...

      "I'm not saying that you are wrong - I'm just trying to fit it into my real world simulated experience."

      1 Reply Last reply Reply Quote 2
      • T3P3Tonyundefined
        T3P3Tony administrators
        last edited by

        hi @garyd9 thanks for pointing this out. I hope its a relatively easy firx for @chrishamm

        Personally it think replacing tabs with 4 (or use configurable) number of spaces is probably best.

        I think this does not come up as much as it might because its not normal to type a <tab> character in a browser, at least on windows, as tab moves the focus. I know DWC's code editor does allow for tab capture and insertion, but people may be conditioned not to tab in a browser!

        www.duet3d.com

        1 Reply Last reply Reply Quote 0
        • jay_s_ukundefined
          jay_s_uk
          last edited by

          I use tabs a lot in the gcode editor. Especially for lining up the comments.
          I think it may get used more than expected, especially by coders used to using tabs for indents.

          Owns various duet boards and is the main wiki maintainer for the Teamgloomy LPC/STM32 port of RRF. Assume I'm running whatever the latest beta/stable build is

          1 Reply Last reply Reply Quote 0
          • T3P3Tonyundefined
            T3P3Tony administrators
            last edited by

            Fair enough! anyway I have logged it:
            https://github.com/Duet3D/DuetWebControl/issues/321

            T3P3 created this issue in Duet3D/DuetWebControl

            closed Whitespace Consistency in DWC gcode editor #321

            www.duet3d.com

            1 Reply Last reply Reply Quote 1
            • DaveAundefined
              DaveA
              last edited by

              Would there be any possibility to have the DWC use an external editor such as NotePad++? In the Arduino IDE you can elect to use any editor you like.

              1 Reply Last reply Reply Quote 0
              • chrishammundefined
                chrishamm administrators
                last edited by

                Thanks for pointing this out. I've got a change for DSF ready so it will treat tabs just like RRF (i.e. to add up to 4 spaces to the current indentation level). I'll try to change the new editor to auto-insert tabs if the last line contains tabs, too.

                Duet software engineer

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Unless otherwise noted, all forum content is licensed under CC-BY-SA