mod: rewrite highlight feature

This commit is contained in:
Qingping Hou
2012-03-20 16:42:22 +08:00
parent f4ea1cdb62
commit a185f238eb
4 changed files with 305 additions and 164 deletions

View File

@@ -48,16 +48,20 @@ function Cursor:new(o)
o = o or {}
o.x_pos = o.x_pos or self.x_pos
o.y_pos = o.y_pos or self.y_pos
o.h = o.h or self.h
o.w = o.h / 3
o.line_w = math.floor(o.h / 10)
setmetatable(o, self)
self.__index = self
o:setHeight(o.h or self.h)
return o
end
function Cursor:setHeight(h)
self.h = h
self.w = self.h / 3
self.line_w = math.floor(self.h / 10)
end
function Cursor:_draw(x, y)
local body_h = self.h - self.line_w
-- paint upper horizontal line
@@ -96,6 +100,18 @@ function Cursor:moveAndDraw(x_off, y_off)
self:draw()
end
function Cursor:moveTo(x_pos, y_pos)
self.x_pos = x_pos
self.y_pos = y_pos
end
function Cursor:moveToAndDraw(x_pos, y_pos)
self:clear()
self.x_pos = x_pos
self.y_pos = y_pos
self:draw()
end
function Cursor:moveHorizontalAndDraw(x_off)
self:clear()
self:move(x_off, 0)