text editor component (seeking design advice)

From: petr krebs (krebsik_at_seznam.cz)
Date: 01/22/04

  • Next message: Bruce Roberts: "Re: text editor component (seeking design advice)"
    Date: Thu, 22 Jan 2004 18:21:27 +0100
    
    

    hello,

    i'm about to write a text editor component with some advanced features i
    need for a future project, but when it comes down to some of it design
    aspects, i keep hesitating.
    the features i want to implement are:

    unicode
    syntax highlighting
    line wrapping
    TEXT FOLDING
        (i mean folding of arbitrary parts of text, not just lines, into an
    expandable and
         contractible icon/symbol - can be also nested)
    right-to-left reading (not sure about this, do you think it could be of any
    real use?)
    and other common things (undo, redo, configurable keystrokes etc.)

    i encounter several design problems. i seek every imaginable form of
    advice - agreements, disagreements, links etc, in other words - whatever
    help - to the discussion below:
    * first of all, i do not know how to store the character data. one approach
    could be plain text, but then i would need to recolor each visible line on
    every scroll, which i think would be a serious performance flaw. on the
    other hand, if i store all the necessary character data (only color and
    style, not font face or size), how to keep track of those parts of text
    which need recoloring and which don't??
    this all gets a bit knotty by that text folding, which speaks in favour of
    the second approach from the two i've given above - let's imagine lots of
    text is folded, all folds visible on one screen. if i obey the first
    approach, i'll have to parse even the folded text - for syntax highlighting
    purposes. this would dramatically affect performance which is something i
    definitely don't want, and the second approach (storing styled character
    data) seems more natural for this purpose. on the other side, its drawback
    lies in excessive use of memory (2 bytes for the unicode character itself, 4
    bytes holding the color, and at least one byte for additional styling -
    underline, italic etc: that's 7 bytes per character at minimal). or do you
    think i shouldn't worry about memory/performance?? (why microsoft word comes
    to my mind every time i think about these two things? :-)))
    * last note to the folding - my idea is to implement it by means of some
    control characters (character codes for start of a folding level/end of a
    folding level, with the second byte indicating whether its currently folded
    or unfolded). any other ideas?
    * syntax highlighting - i don't know whether to opt for event-driven style
    or separate class for it. what do you think?
    * then, how to observe which parts of text need recoloring/reparsing? my
    idea is to hold a "syntax integer" for each line (for example a number for
    keyword, for expression - this will be up to the highlighter which will
    change syntax number as the parsing progresses - is this a good approach?).
    then the highlighter starts at the line on which some changes (writing,
    clipboard pasting etc.) take place, and goes through the following lines
    until a line's syntax number is identical to that number currently
    reported - this would imply that no further syntax processing is necessary
    as it would involve no changes to the following lines, am i right?. this is
    just my first idea, what do you think about it?
    * last thing is the line wrapping. i need the scrolling to be aware with the
    already wrapped lines, in order to avoid "screen jumps", and i don't have
    any ideas how to address this.

    lot's of questions, eh? :-)) i desperately need some clues, advices,
    suggestions, whatever. i am sure that such a control might be useful for
    everyone, not just me.
    so please, share your ideas. moreover, i would be happy if someone was
    interested in any form of cooperation or teamwork.

    thanks in advance
    petr krebs


  • Next message: Bruce Roberts: "Re: text editor component (seeking design advice)"

    Relevant Pages

    • Re: The fallacy of strengthened liars paradox.
      ... have the same syntax. ... However, in English, the same expression, character ... no real difference. ... What does it mean to me to have contradictory ...
      (sci.logic)
    • Re: Again: Please hear my plea: print without softspace
      ... >> character instead of a ',' to alter the behavior of print. ... Changing the behavior of print when a syntax ... print statement is a sort of magic syntax as it is; ... it could be some other character. ...
      (comp.lang.python)
    • Re: Triggers, truncate field, how to
      ... The lenfunction is the correct function to find the length of a character ... But I am wondering why you would want to truncate the column to only ... know where to find the wright syntax code for it. ... trigger to do logically. ...
      (microsoft.public.sqlserver.server)
    • Nochmal utf8
      ... zu wenig Zeichen besitzt. ... `utf` LONGTEXT CHARACTER SET utf8 NOT NULL, ... Was ist an zweiter Syntax falsch? ...
      (de.comp.datenbanken.mysql)
    • Re: Arbeit mit externen Programmen
      ... Ich glaub ich werd nen gaaaanz grosser Fan von Delphi. ... Die Syntax der Sprache ist ja extrem uebersichtlich und verstaendlich. ... mit dem man das Folding etwas mehr in die tiefe bringen kann? ...
      (de.comp.lang.delphi.misc)