2

Is there a menu command or a plugin to format the whole file or the selection?

I tried Correct Indentation, but it did nothing to the following code.

local     x = 'Hello' y = 'world' if y..x == 'worldHello'then  print('OK')    end
shingo
  • 18,436
  • 5
  • 23
  • 42

1 Answers1

1

ZeroBrane Studio will adjust the indentation, but it will not break the lines to do a complete formatting (this is why you don't see any difference on your line of code). You may have to use something like LuaFormatter for this.

Paul Kulchenko
  • 25,884
  • 3
  • 38
  • 56
  • Further question: I decided to add a menu item to run lua-formatter, but I got confused with the source code. I want to output some debug text and I found this object `ide:GetOutput()`. The object seems a wxStyledTextCtrl, but `output:AddText('abc')` printed nothing, only `output:Write('abc')` printed the text. The problem is I could't find `Write` method in the [reference](https://docs.wxwidgets.org/trunk/classwx_styled_text_ctrl.html), why? – shingo May 01 '22 at 11:48
  • :Write is a helper function that you can use. You can also use ide:Print() that will output to the output window. `:AddText` didn't work because the Output window is marked as read-only (to avoid user changing the output directly), so you need to call `SetReadOnly(false)` and then `SetReadOnly(true)`, but it's better to use `ide:Print()` or `ide:GetOutput():Error()`, as it will do all this for you and also maintain markers and other Output elements. – Paul Kulchenko May 01 '22 at 20:48