mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2024-11-25 16:32:07 +00:00
Added selected style, changed comment style to 2
* handle reversed range specifiers
This commit is contained in:
parent
967ea446fb
commit
76c7028c0a
15
atrcopy.py
15
atrcopy.py
@ -264,26 +264,25 @@ class DefaultSegment(object):
|
|||||||
def tostring(self):
|
def tostring(self):
|
||||||
return self.data.tostring()
|
return self.data.tostring()
|
||||||
|
|
||||||
def get_style_bits(self, match=False, comment=False):
|
def get_style_bits(self, match=False, comment=False, selected=False):
|
||||||
style_bits = 0
|
style_bits = 0
|
||||||
if match:
|
if match:
|
||||||
style_bits |= 1
|
style_bits |= 1
|
||||||
if comment:
|
if comment:
|
||||||
|
style_bits |= 2
|
||||||
|
if selected:
|
||||||
style_bits |= 0x80
|
style_bits |= 0x80
|
||||||
return style_bits
|
return style_bits
|
||||||
|
|
||||||
def get_style_mask(self, match=False, comment=False):
|
def get_style_mask(self, **kwargs):
|
||||||
style_mask = 0xff
|
return 0xff ^ self.get_style_bits(**kwargs)
|
||||||
if match:
|
|
||||||
style_mask &= 0xfe
|
|
||||||
if comment:
|
|
||||||
style_mask &= 0x7f
|
|
||||||
return style_mask
|
|
||||||
|
|
||||||
def set_style_ranges(self, ranges, **kwargs):
|
def set_style_ranges(self, ranges, **kwargs):
|
||||||
style_bits = self.get_style_bits(**kwargs)
|
style_bits = self.get_style_bits(**kwargs)
|
||||||
s = self.style
|
s = self.style
|
||||||
for start, end in ranges:
|
for start, end in ranges:
|
||||||
|
if end < start:
|
||||||
|
start, end = end, start
|
||||||
s[start:end] |= style_bits
|
s[start:end] |= style_bits
|
||||||
|
|
||||||
def clear_style_bits(self, **kwargs):
|
def clear_style_bits(self, **kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user