text formatting
Peter Brigham MD
pmbrig at gmail.com
Sun Jul 10 12:16:59 EDT 2011
You can create the htmltext by hand as suggested, or you can do something like the following (not tested):
---------- <script snippet>
local dvdr = "------------" -- or whatever
-- tEntry contains the template for an entry
replace "<timestamp>" with tTime in tEntry
replace "<firstName>" with tFirstName in tEntry
replace "<lastName>" with tLastName in tEntry
replace "<message>" with msgText in tEntry
repeat while cr is char -1 of fld "msgList"
delete char -1 of fld "msgList"
-- make sure no empty lines in fld
end repeat
if line -1 of fld "msgList" <> dvdr then
put cr & dvdr after fld "msgList"
end if
put the number of lines of fld "msgList" into startLineNbr
put cr & tEntry after fld "msgList"
set the textFont of line startLineNbr+1 to -1 of fld "msgList" \
to empty -- start with no formatting
-- on <timestamp>
set the textSize of line startLineNbr+1 of fld "msgList" to 8
set the forecolor of line startLineNbr+1 of fld "msgList" \
to gray
-- <firstName> <lastName: wrote:
set the textStyle of word 1 to -2 of line startLineNbr+2 of \
fld "msgList" to bold
-- <message>
set the textSize of line startLineNbr+3 to -1 of fld "msgList" \
to 16
set the forecolor of line startLineNbr+3 to -1 of fld "msgList" \
to blue
---------- </script snippet>
HTH,
-- Peter
Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig
On Jul 9, 2011, at 12:53 AM, Ian McKnight wrote:
> Hi John
>
> I would look at the HTMLtext property in the Manual/Dictionary.
>
> You would take your text, line by line, and wrap each one with the
> appropriate HTML code
> eg
> put "<font color=grey size=1>"&dateStamp&"</font>&cr into myMsg
> put "<font color=black size=2><b>"&firstName&&surName&"</b></font>"&cr after
> myMsg
> put "<font color=blue>"&theMessage&"</font>"&cr after myMsg
> set the HTMLText of fld "myField" to myMsg
>
> To get the size 16 point text you may have too set the default text size of
> the field to 16 - the HTML should vary it.
> To get the ruled line I think it will be necessary to produce a graphic line
> and use the <img src> tag to reference it.
>
>
> I haven't tried this so you may have to change the colour references to
> numeric values but this hopefully will put you on the correct track
>
>
> On 9 July 2011 08:22, John Allijn <john.allijn at alice.nl> wrote:
>
>> Hi,
>>
>> I have a textfield where I want to present a chunk of text, formatted in a
>> few different styles.
>>
>> This is what the text looks like:
>>
>> ---
>> On <timestamp>
>> <firstname> <Lastname> wrote:
>> <message text>
>> ---
>>
>> and this is how I like to represent it:
>>
>> - the text "on timestamp" should be gray and 8 points
>> - the firstname and lastname should be 10 points, black and bold
>> - the message should be 16 points, blue, regular.
>> - put in a divider-line
>>
>> The problem is that the message-text varies in length and that there may be
>> multiple messages in the field. This means (but maybe I'm wrong) that I have
>> to set the TextColor and TextSize properties while populating the field and
>> that I cannot do this afterwards.
>>
>> So:
>> - How can I set the style of the text, put some text in the field and
>> change the style again?
>> - how can I put in a horizontal line that separates the messages?
>>
>> thank you for your thoughts!
>> John.
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>
>
> --
> Regards
>
>
> Ian McKnight
>
> iangmcknight at gmail.com
> =======================
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list