Page 1 of 2

Setting Word Wrap for MiniConsoles in Geyser

Posted: Sun Apr 28, 2013 2:59 am
by Jor'Mox
I'm trying to transition some miniconsole handling code that I wrote myself to use Geyser, but I'm running into a problem. My code calculated the word wrap value dynamically based on the new size of the miniconsole, so that it fit perfectly every time. But since Geyser handles window resizing on its own, and it doesn't adjust word wrap, I'm trying to figure out how to make that happen.

My best guess as to an approach would be to get the current width of the console, and adjust it from there, but I don't know how to get the width of a miniconsole, inside or outside of Geyser.

Suggestions?

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Sun Apr 28, 2013 3:34 am
by Kalyth
Not sure if this is helpful, but if you had a miniconsole named ChatWindow, you could access the x and y with ChatWindow.x and so forth.

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Sun Apr 28, 2013 3:42 am
by Jor'Mox
Just realized that I can get the width variables for the window and the container it is in. It is in percent (because that is how I set it) but I can work with that.

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Mon Apr 29, 2013 1:01 am
by Jor'Mox
So I ran into a new issue with word wrap. I have several miniconsoles up at once. And one of them uses font size 10, while the others are using font size 8. The ones using font size 8 are set up first, and then the other one. But as soon as I set the font size for the new console, the variable storing the font size for the other mini consoles changes to 10, even though the font as displayed remains at 8.

Any idea what is going on? For now, I'll just store the value I want somewhere else to use for word wrap purposes, but it would be nice to pull the value from the item being referenced.

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Mon Apr 29, 2013 4:41 am
by Vadi
Which variable are you checking?

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Mon Apr 29, 2013 12:54 pm
by Jor'Mox
I'm checking the "fontSize" variable associated with the window. To cut out all the stuff in the middle, here is basically what is happening.
Code: [show] | [select all] lua
chat.window = Geyser.MiniConsole:new({name="chat_window"},chat.container)
chat.window:setFontSize(8)
affects.window = Geyser.MiniConsole:new({name="affects_window"},affects.container)
print(chat.window.fontSize) --> 8
affects.window:setFontSize(10)
print(chat.window.fontSize) --> 10

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Mon Apr 29, 2013 3:41 pm
by kevutian
Make sure both chat.container and affects.container actually properly exist and are unique. That's all I can think of right now.

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Mon Apr 29, 2013 4:14 pm
by Jor'Mox
They do, and they have unique names and positions. The objects are all created and function properly, I just left out the extra details that don't seem to be important.

But as soon as a set the font size for any miniconsole, all of the miniconsoles show that new value as their font size.

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Mon Apr 29, 2013 7:31 pm
by Jor'Mox
I just made a quick alias that demonstrates the problem very clearly, I think. Here is the code.
Code: [show] | [select all] lua
local test1 = Geyser.MiniConsole:new({name = "test1"})
local test2 = Geyser.MiniConsole:new({name = "test2"})
test1:setFontSize(8)
display(test1.fontSize) --> 8
test2:setFontSize(10)
display(test2.fontSize) --> 10
display(test1.fontSize) --> 10

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Tue Apr 30, 2013 6:22 am
by Vadi
Hm, well, with a bit of digging there is an expalanation of how it works, but not why.

Geyser uses containers, and since you haven't specified one explicitly here, it uses the default global one as a container for your miniconsoles. When you set the font size, it propagates this and stores the font size in the top-most container, and calls the relevant Mudlet function for it. So, the fonts while being reported different are as they should be.

Now as to why does it propagate this upwards and stores it, I'm not certain. One would think that it should only propagate it downwards (which I think it does) when you set the font size on a container, but not upwards.