smhg / sublime-suncycle

Sublime Text layout switch based on sunrise and sunset at your location.
MIT License
12 stars 6 forks source link

only set theme on startup, day -> night, night -> day #6

Open stijnster opened 10 years ago

stijnster commented 10 years ago

Hi,

when developing the ip2loc lookup functionality, I noticed the plugin checks the day/night setting about every 20sec. Therefor it also sets the theme every 20sec.

Wouldn't it be nicer to set the theme only;

That way, we don't force the theme all day long (suppose I'm in an Espresso Libre mood today). I think it would also improve system performance a bit as it doesn't need to apply the theme when it's already set.

We could extract it into a setting of course.

What do you think. I would be happy to take a look at it and create a patch.

Stijn

smhg commented 10 years ago

Currently the 20 second loop roughly does this:

So, a lot of overhead.

This loop should indeed only detect day part change (day -> night, night -> day). But that means more caching (in memory). You will need to cache the sunset/sunrise calculations. But they are subject to changes in:

If you can accomplish that, you can indeed leave the current color scheme/theme untouched until the next day part change (as you won't use the current color scheme/theme to derive the current day part).

smhg commented 10 years ago

Could we do this in a new file/class structure? See #7. I have no idea how unit testing works in Python, but with the differences between ST2 and ST3 that sounds more useful than ever. Travis CI can then run tests on both Python versions.

stijnster commented 10 years ago

Yes, I was looking for unit tests when I started to develop but couldn't find any. It would be awesome to have that into the project. Saves a lot of headaches :-)