Well that didn't work...
Cubist at aol.com
Cubist at aol.com
Tue Jun 21 06:22:06 EDT 2005
sez todd at geistinteractive.com:
>I have been trying to figure out how to create a little simple text
>editor. Basically I want to add two features to a regular scrolling
>field.
>
>Feature 1
>
> Pressing tab while the insertion point is on a line of text
>needs to INDENT the line
> pressing shift_tab needs to OUTDENT it.
Rev is perfectly capable of indenting text in a field, and even indenting
the first line of a paragraph differently from the 2nd and later lines. The
properties you wand are called "margins" (for the whole thing) and "firstMargin"
(for the first line). The "margins" property lets you adjust the top, bottom,
right, and left margins separately, in a 4-item list; if the margins property
is only one number, all sides of the text field get that number for heir
margin-value.
Unfortunately, Rev text fields can only have 1 (one) value for
margins/first/Margin, and that one value applies to *all* the paragraphs in the field --
so if you want different amounts of indentation for different paragraphs, you
have to use more than one text field. But if you don't mind indenting *all*
the text in a field simultaneously, something like this might work:
local DeltaTab = 8 # adjust this value up or down, as you please
on tabKey
put the margins of me into Fred
# if the margins *weren't* a 4-item list, let's make it so now
if the number of items in Fred = 1 then put "," & Fred & "," & Fred & "," &
Fred after Fred
if the shiftKey is up then put DeltaTab into DT else put (-1 * DeltaTab)
into DT
add DT to item 2 of Fred
add DT to item 4 of Fred
set the margins of me to Fred
end tabKey
That handler assumes you want to adjust the right and left margin values.
If you only want to worry about the first line's indent-value, try this
instead:
local DeltaTab = 8 # adjust this value up or down, as you please
on tabKey
put the firstMargin of me into Fred
if the shiftKey is up then put DeltaTab into DT else put (-1 * DeltaTab)
into DT
add DT to item 2 of Fred
add DT to item 4 of Fred
set the firstMargin of me to Fred
end tabKey
>Feature 2
>
> A new Line created by pressing "return" needs to line up with
>the previous line
> Like this...
Again, Rev makes all the paragraphs in a single field indent the same
amount. Therefore, this behavior is not just available, it's downright mandatory!
More information about the use-livecode
mailing list