On 26.04.2013, at 17:23, Georg Potthast <
dos...@googlemail.com> wrote:
> Hi Matthias,
>
> thank you for your message. I had hoped eventually there would be a Fl_Text_Buffer_A class which would be compatible to the old one. ;-)
>
> I just tried to compile the code with 1.3.0 and do not understand it yet. So I can just post the parts that do not compile and thus make a "Request for Comment"
>
> 1.)
> ch = buf->character( p ); // I assume this can be replaced with ch = buf->char_at(p);
Yes, but char_at() must be at a UTF8 boundary (it usually is), and it returns a unicode character (32 bit instead of 8).
> 2.)
> indent += Fl_Text_Buffer::character_width( ch, indent, buf->tab_distance(), buf->null_substitution_character() );
> Here we have character_width() and null_substition_character() both are no longer available.
The NUL character is the end of the text, so there is no logical replacement for it. 1.1 allowed a NUL character, but I did not see the use, and it seemed to confuse users.
* in Unicode, there are no fixed width fonts! Even if the ASCII characters may
happen to be all the same width in pixels, chinese charcaters surely are not.
There are plenty of exceptions, like ligatures, that make special handling of
"fixed" character widths a nightmare. I decided to remove all references to
fixed fonts and see "columns" as a multiple of the average width of a
character in the main font.
Use double Fl_Text_Display::string_width( const char *string, int length, int style ) const instead.
> 3.)
> charLen = Fl_Text_Buffer::expand_character( lineStr[ charIndex ], outIndex, expandedChar,
> mBuffer->tab_distance(), mBuffer->null_substitution_character() );
> Here expand_character() is used which is no more available..
Yes, and it is no longer needed. In 1.1, BEL for example would be replaced by the string "BEL". In UTF-8, a little bell may appear (or not, depending on your character set).
> 4.)
> return buf->primary_selection()->includes(pos, buf->line_start( pos ), column);
> Here gpp complains that "->includes()" would have only one argument now.
Yes. includes() with three arguments was only useful in column selection. With proportional (non monospaced) fonts, column selection does not make much sense and the feature was dropped. In Unicode, all characters a proportional (even in a seemingly monospaced font, Chinese character just *must* be wider for example)
> 5.)
> int My_Text_Display::range_touches_selection(Fl_Text_Selection *sel,
> int rangeStart, int rangeEnd) {
> return sel->selected() && sel->rectangular() && sel->end() >= rangeStart &&
> sel->start() <= rangeEnd;
> }
> The compiler says here:
> error: 'class Fl_Text_Selection' has no member named 'rectangular'
See 4.)
> Any suggestions how to rewrite this?
If you really REALLY need column selection, you'd have to either import the 1.1 classes and name them Fl_ASCII_Text_Buffer, etc., or you'd have to write something that looks like column selection from scratch.
Hope that helps.
- Matthias