Text Editor Shifting Mechanics

Programming the 6502 microprocessor and its relatives in assembly and other languages.
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Text Editor Shifting Mechanics

Post by GARTHWILSON »

It looks like a really good resource, except that none of the diagrams show up for me, only text.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
User avatar
BigDumbDinosaur
Posts: 9425
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Text Editor Shifting Mechanics

Post by BigDumbDinosaur »

GARTHWILSON wrote:
...none of the diagrams show up for me, only text.
Same here.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Text Editor Shifting Mechanics

Post by BigEd »

rwiker
Posts: 294
Joined: 03 Mar 2011

Re: Text Editor Shifting Mechanics

Post by rwiker »

No True Scotsman wrote:
BigDumbDinosaur wrote:
gfoot wrote:
I don't remember what it is called but it's a method where characters before the cursor are stored at the start of the block and characters after the cursor are at the end of the block, with a big gap in between to allow fast editing.  When the cursor moves (or at least when an edit starts) you move a chunk of data to create this situation before inserting the new text.
That was brought up a number of posts ago...the phrase “sliding window” comes to mind.
Is this what they call a piece table data structure?
https://en.wikipedia.org/wiki/Gap_buffer, perhaps?
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Text Editor Shifting Mechanics

Post by BigEd »

Edit: agree, gfoot is describing a gap buffer.

It looks to me like the piece table is more fine-grained than the gap buffer (so, thanks for the pointer to that!) Also it keeps the original file in one buffer, and additions in a second (growing) buffer. It might be that it's quicker but uses more memory - depending on how big the gap might have been.

Edit to add
Quote:
Undo is just a matter of keeping the right piece descriptors
around. Unlimited undoes can be easily supported.
No True Scotsman
Posts: 127
Joined: 22 Mar 2023

Re: Text Editor Shifting Mechanics

Post by No True Scotsman »

I found an object-oriented implementation of the piece table in JavaScript, if anybody wants to examine it.
PieceTable.js.zip
Source code for a PieceTable written in JavaScript
(2.22 KiB) Downloaded 21 times
The syntax is close enough to Java and C++ to serve as pseudocode for instructional purposes. I haven't delved into this yet myself, but I'll definitely be wanting a rudimentary text editor as a core component of my 6502 system. My preliminary research into writing a text editor herded me in the direction of the piece table. It may have even been the above referenced text that sent me down that road.

It's important to me that the application be completely decoupled from the on-screen visual presentation, as the latter will be farmed out to a serial terminal running on an ESP32 microcontroller board.
Post Reply