issue-#163 Adding 'Decimal' Tabs to Rulers

Merged to the master branch
User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: issue-#163 Adding 'Decimal' Tabs to Rulers

Post by Robert »

Actually I now think that

Code: Select all

... OR rd.r.eot;
would also work.
Two solutions for the price of one!
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#146 TextRulers docu improvements

Post by Josef Templ »

Robert wrote:
Josef Templ wrote:And finally a question: in which case is the ":" required as the radix character?
I have no idea why I put it in; I can't ever remenber using it. But maybe it is useful for times?
For me this is an indication that the OpenOffice approach would be the right one.
There may be situations where you want to align on something different from
a decimal point or comma. This also allows to choose between dot and comma.
The TextSetters implementation is the same for any radix char
and so it may also be a freely chosen character.
It only requires a little GUI but that would be welcome anyway, for example for setting
the tab stop position as a number. This is also offered in Word and OpenOffice.

The heuristics to treat dot, comma, and colon the same can lead to surprises, for example in the column header.
If it happens to contain a colon, it would be aligned to the colon even if dot or comma is used in the data below.
You may say that this is unlikely, OK, but it is simply ugly to have such an effect at all.
It also causes troubles when converting to a different text format because there is no one that
uses this rule.
Helmut, sorry, but for me this heuristics is not an option.

The implementation of a choosable radix character may seem like a complicated task but I think
it is a pretty straightforward extension. The complicated part is in TextSetters and this is the same anyway.

- Josef
Zinn
Posts: 476
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main
Contact:

Re: issue-#163 Adding 'Decimal' Tabs to Rulers

Post by Zinn »

Josef, your arguments are all OK. Robert, how far are your changes about my succession to right align instead of centre?
Helmut
luowy
Posts: 234
Joined: Mon Oct 20, 2014 12:52 pm

Re: issue-#163 Adding 'Decimal' Tabs to Rulers

Post by luowy »

Zinn wrote:Josef, your arguments are all OK. Robert, how far are your changes about my succession to right align instead of centre?
Helmut
TextSetters.StdSetter.GetLine

Code: Select all

		.........
		IF (chr = '.') OR (chr = ':') THEN
					j := 0; tail[j] := chr;
					REPEAT INC(j); INC(k); chr := rd.zone[k]; tail[j] := chr UNTIL chr = 0X;
					 RETURN  w -  rd.attr.font.StringWidth(tail) + rd.attr.font.SStringWidth('.') DIV 2
				ELSE
					RETURN w (*>>*)+ rd.attr.font.SStringWidth('.') DIV 2(*<<*) 
				END
			END
		END LeftOfTab;
Last edited by luowy on Thu Jun 15, 2017 1:17 pm, edited 1 time in total.
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#163 Adding 'Decimal' Tabs to Rulers

Post by Josef Templ »

I also observed another problem with TextRulers.
On my machine the rendering of the leftmost box (fixed or open line width) is not
showing the intended triangle properly.

The fix would be simple. I already have done it locally.
It would actually simplify the coding.

- Josef
Attachments
Ruler_rendering_problem.jpg
Ruler_rendering_problem.jpg (2.8 KiB) Viewed 28957 times
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#163 Adding 'Decimal' Tabs to Rulers

Post by Josef Templ »

A version of decimal tabs in rulers is available now.
For the diffs see https://redmine.blackboxframework.org/p ... b9c530e25c.

The changes include:
1. decimal tabs for rulers. The default is in TextRulers.defaultRadixChar, which is "." initially. A non-default char can be set with a dialog (right click on the tab mark).
2. improved rendering of the top-left icon for the fixed line-width triangle.
3. using L and T shapes for tab marks as in Word and OpenOffice.
4. a dialog for setting tab properties (type, radix char, position). Opened with a right click on the tab mark.
5. Only if a non-default (default = ".") radix char is used for a decimal tab there is a new store version for TextRuler.Attributes.
Otherwise it uses the same format as Robert's version, i.e. existing texts with Robert's extension should work as before.

It was harder than I expected.

TextSetters work a bit different than Robert's version, which was not always working correctly
and fixing it would have added more code replication for finding the alignment position.
I tried to avoid any code replication at all and adapted GatherString such that it stops at the
decimal point and returns the decimal point as a separate single character string (in the case of processing a decimal tab).
The box's size (right) is saved at the end of a string and when a decimal point occurs, the alignment position
can be adjusted by subtraction.

A controversial point may be the new rendering of the tab marks.
The rationale behind that is: Using L and T shapes
(1) simplifies the coding and, more importantly,
(2) makes the differences of the tab types better visible. It is also
(3) in line with Word and OpenOffice.

The docu is not yet updated.

- Josef
User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: issue-#163 Adding 'Decimal' Tabs to Rulers

Post by Robert »

All sounds good.
Can you post the changed files in .pac format, and I will look at them when I return home in 4 or 5 days.
Josef Templ wrote:It was harder than I expected.
Ha, ha; warned you!
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#163 Adding 'Decimal' Tabs to Rulers

Post by Josef Templ »

A test version can be downloaded from http://blackboxframework.org/unstable/i ... a1.885.zip.

- Josef
Zinn
Posts: 476
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main
Contact:

Re: issue-#163 Adding 'Decimal' Tabs to Rulers

Post by Zinn »

Josef,

thank you for the perfect solution.
The first impression is it works well.
I need more time for testing.

In all headers there should be change the number from #150 to #163.
- 20170620, center #163, adding decimal tabs to TextRulers

Further I would like to add in the Tab form two command buttons [<] & [>] for navigation between the tabs.

- Helmut
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#163 Adding 'Decimal' Tabs to Rulers

Post by Josef Templ »

Change list issue numbers have been fixed now. Thanks for the hint.
Some minor code cleanups have been added as well.

Prev, Next buttons would be welcome indeed.
In addition it would be good to have a chance to identify the tabulator being edited.
A simple identification would be to display the tabIndex (+1) because this is exactly what is
used internally for identifying the tab in OK/Apply.

I will look into this.

- Josef
Post Reply