[Lazarus] Custom file filters in "File Open Dialog" of IDE

Graeme Geldenhuys graemeg.lists at gmail.com
Wed Nov 4 07:56:09 CET 2009


Graeme Geldenhuys wrote:
> On 03/11/2009, Martin <lazarus at mfriebe.de> wrote:
>   
>>  The unit can set the "width" (amount of spaces covered by) each tab
>> individually.
>>     
>
> Is "width" in characters or in pixels? Currently elastic tabstops work
> like a word processor where tabstop width is set in pixels.
>   
 From what I read, setting it in pixel is not a pre-condition. You could 
same as good set it to "char pos" (like 1 pixel = 1 char-width)

The point it that you extend the behaviour of having "defined/fixed 
tabstops".
And for that it does not even matter if your "defined/fixed tabstop" 
happens every 4 chars, or at a list of given positions "4, 10, 16, 22, ..."

Elastic tabstop simply mean:
- if the is no line (in the paragraph (above or below)) with equal or 
more tabstops than the current line, then a normal tab stop is used 
(next from fixed list)
- if there is another such line, then all tabstop that share the same 
position will be vertiacal aligned

Or in even other words:
if in any line in a paragraph, the n-th tabstop is pushed behind it's 
fixed position (due to text in front not fitting otherwise) => then in 
every other line in the given paragraph the n-th tabstop is pushed to 
the same vertical location

So it can work basen on char positions. No pixel position needed.


Pixel position could be introduced, by extending 
SynEditTextDoubleWidthChars. which defines the width of a char, based as 
a multiply of the base-char. The base char currently is the width of 
latin chars => but if you set it to one pixel .... It would have side 
efects, such as the x positon in the status bar getting too large...

> Just to be clear of how Elastic Tabstops work, here follows a simple
> explanation.
>
> eg: Using the elastic tabstops plugin for Gnome's gEdit editor, I can
> set some custom user defined parameters values.
>
> gconftool-2 --type int --set
> /apps/gedit-2/plugins/elastictabstops/minimumwidth 10
> gconftool-2 --type int --set
> /apps/gedit-2/plugins/elastictabstops/paddingwidth 16
>
> This sets the miminum stabstop width to 10 pixels. And paddingwidth to
> 16 pixels. The later is used for tabs after text, not the first tab on
> a line. So if I was at the left edge of my editor window and I press
> the Tab key, I would jump 10 pixels right. That 10 pixel width is only
> constant for the first tabstop in a line. After that, pressing the Tab
> key, it will align to the tab cell/block above it.
>
> eg:  <t> = Tab key pressed and Char(09) is inserted
>
> begin
> <t>i := 0;<t>// line one comment
> <t><t>// line 2 comment
> end;
>
> Using a minimumwidth and paddingwidth of above. With elastic tabstops
> the first tab will be 10 pixels from the left. The second tab on that
> same line with be 10 + 16 pixels (minimumwidth + paddingwidth) away
> from the text before the "// line one comment" is located.
>
> On line 2, the first Tabstop is again 10 pixels. The second Tabstop
> will jump a large about so it lines up with the second tabstop of the
> previous line.
>
> So even though the second line only has two physical Tab characters
> ($09), the comment will start wherever the previous lines second
> tabstop is set. This is the "elastic" part of elastic tabstops.
>   
Any tab in the first line will have a width given as n-spaces => so any 
char following a tab, will be within synedits char grid
The tabs in the 2nd line therefore can also be converted into n spaces.

If of course text is inserted in the first line, pushing the tab out, 
then the 2nd line must adapt too. => possible

The amount of spaces for any tab, can be specified in unit 
SynEditTextTabExpander
function TSynEditStringTabExpander.GetPhysicalCharWidths(const Line: String;

an array, that specifies for every BYTE in the lines text, how many 
cells it occupies on the screen
multybyte utf8 chars, have there width assigned to their first (or last) 
byte. and all other bytes set to 0


So all you need to implement is the algorithm that scans the paragraph 
and finds the widths

2nd thing you have to implement is, that if one line in the paragraph 
changes, you have to find all other lines n the same paragraph and 
trigger the notifications to synedit, so they get redrawn too -> if the 
get redrawnd a call for each line will be made asking for the width of 
the tabs.


>
> So the current SynEdit used in Lazarus should be able to support this?
> Sorry if I sound repetitive, but I don't want to start a possible
> complex implementation, just to find out later that SynEdit doesn't
> actually support what "elastic tabstops" required from a editor
> component. :-)
>
>
>   
>>  If you subclass it, and then do the calculation inside (and add callbacks
>> to tell synedit, that lines must be repainted), then it should work out of
>> the box
>>     
>
> I'll take a closer look at the synedit code in a week or two, when
> time permits. But from what I remember in my last synedit adventure,
> the synedit code was quite complex and riddled with IFDEF statements.
>
>   





More information about the Lazarus mailing list