[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua and text-representation
- From: Gavin Wraith <gavin@...>
- Date: Mon, 01 Mar 2010 15:07:21 GMT
I have been thinking about Lua and text. By text, I do not mean
simply a string, but a data-structure with an allied notion of list of
markers-to-a-position (for representing a cursor, for selections
of text, ... ). Primitive operations on a text would be (M)
movement-of-cursor, (I) insertion of a character and (D) deletion
of a character.
What is the most efficient way of implementing this
1) in Lua,
2) in C, but under the constraint that the operations also include
converting a selection of the text to a Lua string, and insertion of
a Lua string at a marker?
In case 1 taking text to be a string, and marker to be an index,
M is cheap, I and D expensive.
Having separate lists for the characters before the cursor and for
those after the cursor might be better. In that case I and D are
cheap, while M becomes expensive.
In case 2 I am looking for datastructures that would use Lua's
garbage collection. Are there any tricks or modifications to Lua's
memory-allocation strategy for tables that could ensure that the
cursor-movement transformation did not trigger a table-reallocation?
I know that there are text editors out there, like Scite and textadept,
which are closely related to Lua, so I guess that various people have
given this abstract question a fair amount of thought. I would be grateful
if anybody could point me at online documentation or previous Lualist
entries that consider these questions.
Thanks
--
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/