Setting Word Wrap for MiniConsoles in Geyser

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

Setting Word Wrap for MiniConsoles in Geyser

Post 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?

Kalyth
Posts: 5
Joined: Sat Apr 27, 2013 1:48 am

Re: Setting Word Wrap for MiniConsoles in Geyser

Post 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.

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

Re: Setting Word Wrap for MiniConsoles in Geyser

Post 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.

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

Re: Setting Word Wrap for MiniConsoles in Geyser

Post 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.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Setting Word Wrap for MiniConsoles in Geyser

Post by Vadi »

Which variable are you checking?

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

Re: Setting Word Wrap for MiniConsoles in Geyser

Post 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

User avatar
kevutian
Posts: 217
Joined: Fri Aug 20, 2010 8:18 pm
Location: United Kingdom
Contact:

Re: Setting Word Wrap for MiniConsoles in Geyser

Post 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.

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

Re: Setting Word Wrap for MiniConsoles in Geyser

Post 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.

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

Re: Setting Word Wrap for MiniConsoles in Geyser

Post 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

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Setting Word Wrap for MiniConsoles in Geyser

Post 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.

Post Reply