2025-01-19 21:08:25 -08:00
|
|
|
local ParamCursorCell = {type = 'param_cursor_cell'}
|
2025-01-19 19:35:37 -08:00
|
|
|
ParamCursorCell.__index = ParamCursorCell
|
|
|
|
|
|
|
|
function ParamCursorCell.new(cursor)
|
|
|
|
local cell = {cursor = cursor}
|
|
|
|
return setmetatable(cell, ParamCursorCell)
|
|
|
|
end
|
|
|
|
|
2025-01-19 21:08:25 -08:00
|
|
|
function ParamCursorCell:write(builder, _)
|
2025-01-19 19:35:37 -08:00
|
|
|
builder:write(self.cursor:get_value())
|
|
|
|
end
|
|
|
|
|
|
|
|
function ParamCursorCell:hit_test(cursor)
|
|
|
|
if self.cursor == cursor then
|
2025-01-19 21:08:25 -08:00
|
|
|
return {{char = self.cursor:get_value(), type = self.type}}
|
2025-01-19 19:35:37 -08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function ParamCursorCell:hit_search(trace, depth)
|
|
|
|
local frame = trace[depth]
|
2025-01-19 21:08:25 -08:00
|
|
|
assert(frame.type == self.type)
|
2025-01-19 19:35:37 -08:00
|
|
|
assert(frame.char == self.cursor:get_value())
|
|
|
|
assert(depth == #trace)
|
|
|
|
|
|
|
|
return self
|
|
|
|
end
|
|
|
|
|
2025-01-19 21:08:25 -08:00
|
|
|
function ParamCursorCell:is_empty()
|
|
|
|
return not self.cursor:get_value():match('%S')
|
|
|
|
end
|
|
|
|
|
2025-01-19 19:35:37 -08:00
|
|
|
function ParamCursorCell:is_before_cursor(cursor)
|
|
|
|
return self.cursor < cursor
|
|
|
|
end
|
|
|
|
|
|
|
|
function ParamCursorCell:is_after_cursor(cursor)
|
|
|
|
return self.cursor > cursor
|
|
|
|
end
|
|
|
|
|
|
|
|
function ParamCursorCell:get_start_cursor()
|
|
|
|
return self.cursor
|
|
|
|
end
|
|
|
|
|
|
|
|
function ParamCursorCell:get_stop_cursor()
|
|
|
|
return self.cursor
|
|
|
|
end
|
|
|
|
|
|
|
|
return ParamCursorCell
|