Skip to content

Commit

Permalink
Fix small bugs, better var names.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-sk committed Feb 11, 2012
1 parent 3e5cc3f commit ad8078e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
13 changes: 3 additions & 10 deletions livecss/colorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@
:license: BSD, see LICENSE for more details.
"""
# stdlib

# from plistlib import readPlist as read_plist
# from plistlib import writePlist as write_plist
from color import Color
from fast_theme_generation import generate_theme_file


# local imports
from theme import *
from state import State
# from config import Config
from helpers import *
from color import Color
from state import State
from theme import *
from utils import *
# from debug import profile

Expand Down
19 changes: 11 additions & 8 deletions livecss/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ def __init__(self, view, colors=False, regions=False):

@property
def is_dirty(self):
# if we don't have previously saved state
if not self.regions:
is_dirty = True

old_regions = get_highlighted_regions(self._view, self.count)
new_regions = self._regions

if str(old_regions) == str(new_regions):
if old_regions == new_regions:
is_dirty = False
else:
is_dirty = True
Expand All @@ -30,21 +31,23 @@ def is_dirty(self):
@property
def need_generate_theme_file(self):
if set(self._colors) - set(self.colors or []):
generate = True
need_generate = True
else:
generate = False
need_generate = False
self.colors = [str(x) for x in self._colors]
return generate
return need_generate

def erase(self):
self._s[self._id] = {}


def get_highlighted_regions(view, last_count):
if not last_count:
return []
def get_highlighted_regions(view, last_highlighted_region):
""" Returns currently highlighted regions
"""
if not last_highlighted_region:
return
regions = []
for i in range(int(last_count)):
for i in range(int(last_highlighted_region)):
region = view.get_regions('css_color_%d' % i)
if region:
regions.append(region[0])
Expand Down

0 comments on commit ad8078e

Please sign in to comment.