On Mon, Sep 19, 2016 at 04:18:14AM -0700, elextr wrote:<br>
> > Should be easy, and should also be how the program is implemented.<br>
> <br>
> and how do you keep all this updated and in sync with changes to the<br>
> buffer as its edited?<br>
<br>
The layered model - the bottom layer is the text/ raw utf8 stream.<br>
<br>
The next layers are the indexing layers for various purposes as and when<br>
needed.<br>
<br>
An index is not just an array of "locations" of course since when the<br>
underlying text stream is inserted into or deleted from (in terms of<br>
bytes, not graphemes), then of course the corresponding index in the<br>
upper layer also needs to be updated.<br>
<br>
Now because when an index point gets updated it is that all subsequent<br>
index points also need to be updated, a tree structure for the indexes<br>
is required.<br>
<br>
And because the underlying layer can change, even it needs to be<br>
represented by a tree structure (various blocks of text are the leaves<br>
of the tree).<br>
<br>
This is basic Comp Sci - thus the "easy" bit. The text editor data<br>
structure is really the simplest useful program, and the data structures<br>
needed to handle "large" (anything other than trivial sized) text files,<br>
are well understood, well studied, and highly optimized.<br>
<br>
<br>
> > At least, that's how a superior programmer would implement it ;)<br>
> <br>
> Most of the features you describe are handled by the Scintilla editing<br>
> component which is a separate project at www.scintilla.org and I am<br>
> sure they would be delighted to hear how a "superior" programmer would<br>
> re-implement their library. :)<br>
<br>
Ah ok. An external dependency.<br>
<br>
Well :)<br>
<br>
Guess who needs to advise them their data structures are inferior then<br>
hey? :D<br>
<br>
Enjoy the ride, and to ease your communications with your upstream<br>
dependency, I suggest being exceptionally blunt with your "inferior<br>
structures" communications, and to top it off, don't stop at the code<br>
but go on to point large accusatory fingers at the personal life choices<br>
of the programmers involved.<br>
<br>
That should speed up the re-implementation.<br>


<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/issues/1238#issuecomment-247974921">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ1Ape95h5__WNVCXNTsWMwLs1xFzks5qrnoHgaJpZM4KAGgV">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJ3y440jtKxbPU1hHgKIS69ZzfaB2ks5qrnoHgaJpZM4KAGgV.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/geany/geany/issues/1238#issuecomment-247974921"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany","title":"geany/geany","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany"}},"updates":{"snippets":[{"icon":"PERSON","message":"@zenaan in #1238: On Mon, Sep 19, 2016 at 04:18:14AM -0700, elextr wrote:\n\u003e \u003e Should be easy, and should also be how the program is implemented.\n\u003e \n\u003e and how do you keep all this updated and in sync with changes to the\n\u003e buffer as its edited?\n\nThe layered model - the bottom layer is the text/ raw utf8 stream.\n\nThe next layers are the indexing layers for various purposes as and when\nneeded.\n\nAn index is not just an array of \"locations\" of course since when the\nunderlying text stream is inserted into or deleted from (in terms of\nbytes, not graphemes), then of course the corresponding index in the\nupper layer also needs to be updated.\n\nNow because when an index point gets updated it is that all subsequent\nindex points also need to be updated, a tree structure for the indexes\nis required.\n\nAnd because the underlying layer can change, even it needs to be\nrepresented by a tree structure (various blocks of text are the leaves\nof the tree).\n\nThis is basic Comp Sci - thus the \"easy\" bit. The text editor data\nstructure is really the simplest useful program, and the data structures\nneeded to handle \"large\" (anything other than trivial sized) text files,\nare well understood, well studied, and highly optimized.\n\n\n\u003e \u003e At least, that's how a superior programmer would implement it ;)\n\u003e \n\u003e Most of the features you describe are handled by the Scintilla editing\n\u003e component which is a separate project at www.scintilla.org and I am\n\u003e sure they would be delighted to hear how a \"superior\" programmer would\n\u003e re-implement their library. :)\n\nAh ok. An external dependency.\n\nWell :)\n\nGuess who needs to advise them their data structures are inferior then\nhey? :D\n\nEnjoy the ride, and to ease your communications with your upstream\ndependency, I suggest being exceptionally blunt with your \"inferior\nstructures\" communications, and to top it off, don't stop at the code\nbut go on to point large accusatory fingers at the personal life choices\nof the programmers involved.\n\nThat should speed up the re-implementation.\n"}],"action":{"name":"View Issue","url":"https://github.com/geany/geany/issues/1238#issuecomment-247974921"}}}</script>