An efficient datatype to store lines

This commit is contained in:
Kovid Goyal 2016-10-15 13:41:29 +05:30
parent 3069faff5c
commit 59f92f9db8

24
kitty/data_types.py Normal file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env python
# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
from numpy import zeros, dtype
color_type = dtype([('type', 'u1'), ('r', 'u1'), ('g', 'u1'), ('b', 'u1')])
class Line:
__slots__ = 'char fg bg bold italic reverse strikethrough decoration decoration_fg'.split()
continued = False
def __init__(self, sz: int):
self.char = zeros(sz, 'U1')
self.fg = zeros(sz, color_type)
self.bg = zeros(sz, color_type)
self.bold = zeros(sz, bool)
self.italic = zeros(sz, bool)
self.reverse = zeros(sz, bool)
self.strikethrough = zeros(sz, bool)
self.decoration = zeros(sz, 'u1')
self.decoration_fg = zeros(sz, color_type)