It is currently March 28th, 2024, 10:31 pm

Proof of Concept: Scroll a text file in a window.

Discuss the use of Lua in Script measures.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Proof of Concept: Scroll a text file in a window.

Post by jsmorley »

Just something you guys can tear apart to see one approach to scrolling a long text file in a short meter...

Requires the latest beta of Rainmeter
LuaScrollText.rmskin
7-30-2011 12-59-29 AM.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: Proof of Concept: Scroll a text file in a window.

Post by Seahorse »

Sweet, cue shoe-horn & Lyrics skin... :D

Dumb question time, this appears to expect a file input rather than a measure:

Code: Select all

FileToRead = "";
will the underlying logic work with:

Code: Select all

MeasureName = "";
and changes to:

Code: Select all

sFileToRead = PROPERTIES.FileToRead
	
	hReadingFile = io.input(sFileToRead)
or is there more to it than that?
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Proof of Concept: Scroll a text file in a window.

Post by jsmorley »

This really is geared toward opening and reading a file with a lot of "lines" in it and allowing you to scroll through the lines. Like a notes files or todo list or log file or things like that.

To have it work with a single chunk of data from a "measure" would take a completely different approach at the top, as you would need to get the measure's data, then use Lua to break it into "lines" based on length, linefeeds embedded in the data, something, and put those "lines" into a table so you can use table "index numbers" to display some number of lines at a time. Once you have a table full of lines of data, then the rest of the approach would work fine.

So while this does demonstrate a concept of using a table and a movable "starting" and "ending" point to allow scrolling as desired through lines of data you read from something and put in a table, it isn't going to allow scrolling through a single, large chunk of data like the return from a measure without some additional work.

This concept of a movable "starting" and "ending" point that you can use to move lots of information though a single smaller display could probably be used in a lot of other ways. You might have a list of 20 images, and create a "frame" with meters in it for say 4 images at a time. Then you could use a scrolling function like this to have those 4 meters display any of the 20 by scrolling up and down through a table containing the names. So in theory you could have a launcher skin that shows 4 icons at a time and allows you to scroll up and down (or left and right) through an unlimited number of items to launch while keeping the overall launcher skin small.

What you want to envision is: You are standing at a window in your house, watching a train go by. You only see as much of the train at a time as it passes by as will fit in your view though the window. The "lines" in the table are the cars of the train. You can see any 2 of the cars at a time, no matter how long the train is. Ok, trains don't really "back up" much, but damn it, I like this analogy and I'm sticking to it.

Image
User avatar
KreAch3R
Posts: 608
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Proof of Concept: Scroll a text file in a window.

Post by KreAch3R »

I love when your answer post is that huge, you know it's gonna be good. :) Please Consider writing every now and then an article about one rainmeter usage. We can always learn something.

On subject, how can we accomplish the schrolling "window" with images (or launcher icons)? It seems that the lua script reads a file. Should I write the image file names in it, and then use an Image DISPLAY meter instead of a TEXT one?

Besides that, I wanted to do a little repositioning, but I have problems with the MeterPosition meter.
Look at screenshot:
Image

As you can tell, I moved it to the other side and then made the height of the scrollbar smaller. Then, at the beginning, I had the meter MeterPosition hidden under the other meters, when it reached the ends. I dirty solved the upper one with this:

Code: Select all

[MeterPosition]
Meter=Image
SolidColor=100,100,100,255
X=r
Y=(#PosY#+10)
W=10
H=2
DynamicVariables=1
But I don't know what should I do with the other one. Do I have to mess with the lua script?

Thanks anyway for the skin.
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Proof of Concept: Scroll a text file in a window.

Post by jsmorley »

KreAch3R wrote:I love when your answer post is that huge, you know it's gonna be good. :) Please Consider writing every now and then an article about one rainmeter usage. We can always learn something.

On subject, how can we accomplish the schrolling "window" with images (or launcher icons)? It seems that the lua script reads a file. Should I write the image file names in it, and then use an Image DISPLAY meter instead of a TEXT one?

Besides that, I wanted to do a little repositioning, but I have problems with the MeterPosition meter.
Look at screenshot:
Image

As you can tell, I moved it to the other side and then made the height of the scrollbar smaller. Then, at the beginning, I had the meter MeterPosition hidden under the other meters, when it reached the ends. I dirty solved the upper one with this:

Code: Select all

[MeterPosition]
Meter=Image
SolidColor=100,100,100,255
X=r
Y=(#PosY#+10)
W=10
H=2
DynamicVariables=1
But I don't know what should I do with the other one. Do I have to mess with the lua script?

Thanks anyway for the skin.
As to using images, I would probably do something where I passed the image names as variables or in the settings of the script measure, then in the lua script get the names and stick them in a table. I'm going to leave it to you to mess with the Lua and see how to do that, I don't really want this little example skin to turn into something I need to spend days on going back and forth into making it something completely different, I only pointed out the image thing as a "possible" way to use the overall thinking.

I hate to be a jerk, but when I "release" a skin on deviantART I sign up to support it. When I put some little stub here as a "proof of concept", my goal is that others tear it apart and figure it out if they want to use the approach in their own skins. I'm glad to answer questions about how something I did works, but not ongoing "walk me through doing this in my skin" discussions. I hope you understand.

As to the position of the "position pointer" at and how it knows how much to move on each click and when it is at the bottom, yeah, that is in the Lua script. It's a formula that takes into account the amount of pixels between top and bottom, the total number of elements in the table to scroll through, and the current "starting" point in the table.
User avatar
KreAch3R
Posts: 608
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Proof of Concept: Scroll a text file in a window.

Post by KreAch3R »

Thanks jsmorley, I understand. :) I will look into it, and start messing with lua. Maybe I am a bit overdue :P
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Proof of Concept: Scroll a text file in a window.

Post by jsmorley »

KreAch3R wrote:Thanks jsmorley, I understand. :) I will look into it, and start messing with lua. Maybe I am a bit overdue :P
Partly it is just that we are in the middle of some major changes in Rainmeter's beta, and my head is kinda down on that right now. In general though, although I prefer not to "joint write" someone else's skin, I am happy to try to help if you post (as code or .zip as appropriate) an entire skin you are working on and ask "this part is acting weird, can you take a look at it?".

Do, do mess with Lua in Rainmeter. It actually is really fun. Start small and work up to more complicated things. It's really not a hard language at all. The first time I ever laid eyes on it was in December, and I was doing simple stuff that pleased me in a day or so. Truth be told, I'm pretty much still a nOOb at it myself.
User avatar
KreAch3R
Posts: 608
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Proof of Concept: Scroll a text file in a window.

Post by KreAch3R »

I just saw you answered again. I totally understand, this Sunday update is huge, I am still trying to digest the new options and changes. It's gonna need a lot of example skins to see their potential. So, do your thing. :)

As far as lua in concerned, I will. I am a bit afraid, however, that the already massive possibilities of Rainmeter will be blown to the stars with lua involved, and I will be totally overwhelmed, hehe.:P I should better stop now, to keep the post ontopic. Thanks again for another idea to implement.
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
Timewarptrio
Posts: 1
Joined: April 6th, 2012, 8:19 pm

Re: Proof of Concept: Scroll a text file in a window.

Post by Timewarptrio »

I know you only made this as a proof of concept and it was a while ago, but I'm using it as it is to display a to do list.

I'm wondering how/why the skin isn't getting the changes in the text file, and how I could make it do that. There's no UpdateDivider in the skin (if there was, I removed it), and Update = 1000 is in the Rainmeter section of the skin. How do I get it to read the changes every, say, 5 seconds?