View Single Post
Old 02-17-2014, 04:29 PM   #6
arspr
Dead account. Bye
arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.
 
Posts: 587
Karma: 668244
Join Date: Mar 2011
Device: none
Continuing noob brainstorming mode, so expect more nonsense per square inch than in your favourite sitcom...

(But just in case something of the stupid things I'm going to say fires up some of your brain gears by sheer luck).


I start with a question and a needed hypothesis. Whenever any change in the text is made, do you know what modifications are made just as "absolute positions" in the text? I mean, if I type and insert "whatever", are you able to know if "whatever" is inserted in the 98th position of the whole text? Or if I copy/paste "whatever" erasing "whatever other text", are you able to detect that the positions 101st to 120th of the text are being erased and substituted by a new set of just 8 characters?

Because if the answer is "Yes, I (Kovid) can easily know the positions of the modifications that are constantly being made through any of the possible editing actions", then maybe the approach to implement this useful feature could be the next one:
  • Two synchronized copies of the text are needed. One is the "real" HTML text and the other one is the "visibilized" one.
  • The "visibilized" one is constructed just once from a copy of the "real" one where the invisible characters are substituted by any other convenient one (or ones).
  • The Editor only knows about the "visibilized" one, but the important one is the "real" one.
  • Whenever the "visibilized" one, which is managed through the Editor, is changed, as you know the position of those changes, those very same changes are replicated in the "real" one in those exact positions.
  • If any of the changes contains a new invisible character, it is automatically substituted but just in the "visibilized" copy.
  • Any kind of search process is always made on the "real" text, not in the "visibilized" one.
  • Any kind of replacement process is originally done on the "real" text and then replicated in the "visibilized" one through the very same procedure about absolute positions (but in the opposite direction).

In this way you wouldn't need to keep track of the exact substitutions made between "real" and "visibilized" copies. You just have to be careful about replicating exactly the same modifications on both copies of the text.

Please do not be too harsh with your favourite buffoon...
arspr is offline   Reply With Quote