Difference between revisions of "RichMemo/Samples"
From Lazarus wiki
Jump to navigationJump to searchm (→Tabs) |
m (→Tab Offsets) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
In order for tabs to work the text should be split tab character (#9) | In order for tabs to work the text should be split tab character (#9) | ||
+ | This is how the text would look like if no tab separation is used: | ||
+ | |||
+ | [[Image:richmemo_basic1.png]] | ||
+ | |||
+ | <source lang="delphi"> | ||
+ | RichMemo1.Lines.Add('hello world'); | ||
+ | RichMemo1.Lines.Add('this sample'); | ||
+ | </source> | ||
+ | |||
+ | |||
+ | If the words are split by Tabs, then the control tries to find the next proper tab offset in order: | ||
+ | |||
+ | [[Image:richmemo_basic2.png]] | ||
+ | |||
+ | <source lang="delphi"> | ||
+ | RichMemo1.Lines.Add('hello'#9'world'); | ||
+ | RichMemo1.Lines.Add('this'+#9+'sample'); | ||
+ | </source> | ||
+ | ===Tab Offsets=== | ||
+ | The length of tab offsets can be controlled using [[RichMemo#GetParaTabs|GetParaTabs]] and [[RichMemo#GetParaTabs|SetParaTabs]] methods. | ||
+ | |||
+ | <source lang="delphi"> | ||
+ | var | ||
+ | st : TTabStopList; | ||
+ | i : integer; | ||
+ | begin | ||
+ | |||
+ | RichMemo1.GetParaTabs(0, st); // getting the current tabs | ||
+ | st.Count:=8; | ||
+ | SetLength(st.Tabs, st.Count); | ||
+ | for i:=0 to length(st.Tabs)-1 do | ||
+ | st.Tabs[i].Offset:=i*72; | ||
+ | RichMemo1.SetParaTabs(-1,-1,st); // assigning tabs stops | ||
+ | |||
+ | // assigning text with tabs (#9) | ||
+ | RichMemo1.Lines.Add('hello'#9'world'#9'to'#9'columns'); | ||
+ | RichMemo1.Lines.Add('does'#9'it'#9'look'#9'good'#9'?'); | ||
+ | RichMemo1.Lines.Add('tab'+#9+'is'+#9+'character'+#9+'9'); | ||
+ | end; | ||
+ | </sourcE> | ||
+ | [[Image:richmemo_tabs.png]] | ||
+ | |||
+ | ==See Also== | ||
+ | *[[RichMemo]] | ||
[[Category:RichMemo]] | [[Category:RichMemo]] |
Latest revision as of 20:22, 28 June 2021
Tabs
Tabs are used to organize the text in table-like layout. This would not be a real layout table, but will make the text (if it's short enough) to look table alike.
Basics
In order for tabs to work the text should be split tab character (#9)
This is how the text would look like if no tab separation is used:
RichMemo1.Lines.Add('hello world');
RichMemo1.Lines.Add('this sample');
If the words are split by Tabs, then the control tries to find the next proper tab offset in order:
RichMemo1.Lines.Add('hello'#9'world');
RichMemo1.Lines.Add('this'+#9+'sample');
Tab Offsets
The length of tab offsets can be controlled using GetParaTabs and SetParaTabs methods.
var
st : TTabStopList;
i : integer;
begin
RichMemo1.GetParaTabs(0, st); // getting the current tabs
st.Count:=8;
SetLength(st.Tabs, st.Count);
for i:=0 to length(st.Tabs)-1 do
st.Tabs[i].Offset:=i*72;
RichMemo1.SetParaTabs(-1,-1,st); // assigning tabs stops
// assigning text with tabs (#9)
RichMemo1.Lines.Add('hello'#9'world'#9'to'#9'columns');
RichMemo1.Lines.Add('does'#9'it'#9'look'#9'good'#9'?');
RichMemo1.Lines.Add('tab'+#9+'is'+#9+'character'+#9+'9');
end;