Indent wrapped lines in Geyser:MiniConsole

Post Reply
xabre
Posts: 45
Joined: Thu Mar 08, 2012 7:19 pm

Indent wrapped lines in Geyser:MiniConsole

Post by xabre »

Hey all,

Was wondering if there's a a way to indent wrapped lines in MiniConsoles?
There's an option in Main Display preferences for it, but works only for Main Window, not for MiniConsoles.
Serached through documentation, there's setWindowWrap(), but nothing about indent.

Any help appreciated, thanks.

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Indent wrapped lines in Geyser:MiniConsole

Post by Jor'Mox »

I think your best bet is going to be storing the original text in a buffer, and then handling word wrapping yourself using that as the source as you write the lines into the MiniConsole.

So, maybe something like this:
Code: [show] | [select all] lua
myBuffer = "original_text"
createBuffer(myBuffer)
setWindowWrap(myBuffer,1000)
myConsole = Geyser.MiniConsole:new({name = "name",x=x,y=y,width=width,height=height})
wrap_len = 100
myConsole:setWrap(wrap_len)
indent = "     "

function wrapNewLine()
   local str = getCurrentLine(myBuffer)
   local a = string.sub(str,1,wrap_len)
   str = string.sub(str,wrap_len+1,#str)
   
   while a ~= "" do
      myConsole:echo(a .. "\n")
      a = indent .. string.sub(str,1,wrap_len - #indent)
      str = string.sub(str,wrap_len - #indent + 1, #str)
   end
end

xabre
Posts: 45
Joined: Thu Mar 08, 2012 7:19 pm

Re: Indent wrapped lines in Geyser:MiniConsole

Post by xabre »

Thanks for the response.
Hmm, was hoping for a quick solution, but seems I'll have to get my hands dirty and do it that or similar way.
Appreciated.

Post Reply