Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Multiline text in face?

 [1/14] from: robert:muench:robertmuench at: 18-Sep-2002 9:20


Hi, how can I set the text of a face to a multiline text? I would like to do something like: text: "this is a^/multiline^/text" This text should appear as three lines. BTW: I can't (better: I'm not sure) use an area or something like this, because I'm working directly with a face. Robert -- Binary/unsupported file stripped by Listar -- -- Type: application/ms-tnef -- File: winmail.dat

 [2/14] from: petr:krenzelok:trz:cz at: 18-Sep-2002 9:30


Robert M. Muench wrote:
>Hi, how can I set the text of a face to a multiline text? I would like to do >something like: > > text: "this is a^/multiline^/text" >
view layout [text as-is "this is a^/multiline^/text"] HTH, -pekr-

 [3/14] from: robert:muench:robertmuench at: 18-Sep-2002 15:05


> -----Original Message----- > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]
<<quoted lines omitted: 3>>
> Subject: [REBOL] Re: Multiline text in face? > view layout [text as-is "this is a^/multiline^/text"]
Hi, well OK. How do I specify this for my face: test-face: make face [ size: 200x20 ] mytext: "Hi^/Rebol" make test-face compose [ text: as-is (mytext) ] ** Script Error: as-is has no value Robert

 [4/14] from: petr:krenzelok:trz:cz at: 18-Sep-2002 15:24


Robert M. Muench wrote:
>>-----Original Message----- >>From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]
<<quoted lines omitted: 16>>
>] >** Script Error: as-is has no value
compose works - just try it separately .... it will not scream. What fails though seems to be your VID code ;-) text: as-is .....??? what as-is? You have to specify text, h1, etc ... so just modify your example: view layout compose [t: text as-is (mytext)] Is that what you wanted? -pekr-

 [5/14] from: rebolek:seznam:cz at: 18-Sep-2002 15:44


'as-is is VID-keyword, not REBOL function so use it like: view layout compose [text as-is (mytext)] bye, bolek

 [6/14] from: gscottjones:mchsi at: 18-Sep-2002 9:30


> > On Behalf Of Petr Krenzelok > > view layout [text as-is "this is a^/multiline^/text"]
From: "Robert M. Muench"
> Hi, well OK. How do I specify this for my face: > test-face: make face [
<<quoted lines omitted: 4>>
> text: as-is (mytext) > ]
Hi, Robert, As was mentioned after this post of yours, 'as-is is a VID word. Although it does not really make a difference in what you are trying to achieve, there were two other errors in your code. The first is that the code is putting mytext as the title line for the main window, not as a text face *within* the window. The second was more than likely a typo in your final make in that text was used as a set-word instead of a VID word. My guess is that you are looking to make custom faces, instead of just VID, and are trying to figure out how to get the 'as-is effect of multi-line printing. I suspect that there is a way to do this purely in View (without VID), but I suspect that you will be re-inventing the wheel to some extent. A quick way to get the effect and still use largely custom faces can be done as follows: ;give a little more room in main window test-face: make face [ size: 200x200 ] mytext: "Hi^/Rebol" ;do a throw away 'layout inorder to get a ;default text face using 'as-is layout [ t: text as-is mytext ] ;paste only the default text face to the main window pane test-face/pane: copy to-block t ;check the result view/offset test-face 100x100 Assuming I have correctly guessed your intention, I hope that this helps. --Scott Jones

 [7/14] from: gscottjones:mchsi at: 18-Sep-2002 9:59


Responding to self: Hi, Self, From: "G. Scott Jones" ...
> ;give a little more room in main window > test-face: make face [
<<quoted lines omitted: 8>>
> ;paste only the default text face to the main window pane > test-face/pane: copy to-block t
The line above could be written more simply as: test-face/pane: :t
> ;check the result > view/offset test-face 100x100
--Scott Jones

 [8/14] from: g:santilli:tiscalinet:it at: 18-Sep-2002 19:36


Hi Robert, On Wednesday, September 18, 2002, 9:20:18 AM, you wrote: RMM> Hi, how can I set the text of a face to a multiline text? I would like to do RMM> something like: RMM> text: "this is a^/multiline^/text" view layout [text as-is "this is a^/multiline^/text"] Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [9/14] from: g:santilli:tiscalinet:it at: 18-Sep-2002 19:47


Hi Robert, On Wednesday, September 18, 2002, 3:05:09 PM, you wrote: RMM> make test-face compose [ RMM> text: as-is (mytext) RMM> ] make test-face [ text: "Text^/with^/newlines" ] Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [10/14] from: robert:muench:robertmuench at: 19-Sep-2002 9:18


> -----Original Message----- > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]
<<quoted lines omitted: 3>>
> Subject: [REBOL] Re: Multiline text in face? > As was mentioned after this post of yours, 'as-is is a VID word.
Hi, yes I know but...
> My guess is that you are looking to make custom faces, > instead of just VID, and are trying to figure out how to get > the 'as-is effect of multi-line printing.
... That's exactly what I try to do :-)). Well, I thought my posting that I use a face was clear about this.
> I suspect that > there is a way to do this purely in View (without VID), but I > suspect that you will be re-inventing the wheel to some > extent.
That could be. What I do is I'm playing around with Christian Langenreiters code of touchgraph. And there the nodes are implemented as faces because these are just appended to a layout block. The faces carry around all that's needed. So, IIRC the 'text value of a face is the text you will see on screen, right? It's not the VID text word. And I don't think that I can assign a layout block that uses VID words to this text property, right?
> ;do a throw away 'layout inorder to get a > ;default text face using 'as-is > layout [ > t: text as-is mytext > ]
:-) That's smart! I'm going to try it, thanks! Robert

 [11/14] from: jftheys:skynet:be at: 19-Sep-2002 10:14


Hi, Why not like this? mytext: "Hi^/Rebol^/ok" fa: make test-face [ pane: make face[ text: mytext edge: none ] ] view/offset fa 25x25

 [12/14] from: g:santilli:tiscalinet:it at: 19-Sep-2002 11:07


Hi Robert, On Thursday, September 19, 2002, 9:18:08 AM, you wrote:
>> ;do a throw away 'layout inorder to get a >> ;default text face using 'as-is >> layout [ >> t: text as-is mytext >> ]
RMM> :-) That's smart! I'm going to try it, thanks! Robert Actually, you don't need to do that, unless you want to take benefit from what LAYOUT does without having to do it by yourself. Since you are asking to avoid what the TEXT style does (i.e. TRIM/LINES on your text), and you already have your faces built, using layout is just overkill. As I said earlier, you just need to set the TEXT facet to your text, as in: face/text: "Multiline^/text" View does *not* remove that newline by default. Is the TEXT style that does when used in VID without using AS-IS.
>> t: get-style 'text >> print mold t/init
[ if all [not flag-face? self as-is string? text] [trim/lines text] if none? text [text: copy ""] change font/colors font/color if :action [feel: svvf/hot saved-area: true] data: size if any [none? size size/x < 0 size/y < 0] [ state: max 1x1 pane-size * 9 / 10 - offset - para/margin if none? size [size: state] if size/x < 0 [size/x: state/x] if size/y < 0 [size/y: state/y] size: size-text self all [ para para/origin size: size + para/origin para/margin size: size + para/margin ] ] if all [data data/y < 0] [size/x: data/x] data: none ] Notice the first line: if all [not flag-face? self as-is string? text] [trim/lines text] HTH, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [13/14] from: gscottjones:mchsi at: 19-Sep-2002 7:21


Hi, Robert and all other respondents, I guess life is a lot like Lewis Carroll's "Alice in Wonderland," do we say what we mean or mean what we say? Language is a fragile medium, and I am hardly the most articulate person on this list. Earlier respondents were demonstrating how to use the VID word 'as-is and layout to achieve the goal. I suspected that Robert was trying to get the behavior of 'as-is while using custom faces in View. Except for a typo, Robert was trying to do what Gabrielle was saying, but he was inadvertently doing it on the incorrect face (using the text path of the parent window, and not a child window; the text path of the main window is the title bar). Given that VID supplies reasonable default values (one of the better parts of object oriented programming paradigm), I tried to show how he could quickly and easily inherit all the fundamental aspects of a VID laid-out text element in a *child* window. It was not very elegant, and I wasn't happy with it. Jean-François showed that basic functionality could be achieved "more easily" than what I was thinking possible (thanks!), and I suspect that Gabrielle is trying to figure out why there is any confusion at all!!, but only suffered the "oversite" of not giving a full working example that helps those of us (namely, me!!!) see exactly how to do it. :-) As almost a side note, I am going to submit one more example that demonstrates what I initially wanted to do yesterday, and that is to inherit the bulk of the text style *without* using layout (it was easier than I thought). Some defaults still need to be adjusted, as is true whenever one avoids VID and layout. This example draws on the most essential aspects of what Jean-François and Gabrielle have said and shown. svv: system/view/vid mytext: "Hi^/Rebol^/OK" test-face: make face [ offset: 100x100 size: 200x200 pane: make select svv/vid-styles 'text [ text: mytext color: 142.128.110 size: 100x100 ] ] test-face/pane/size: size-text test-face/pane test-face/pane/size: test-face/pane/size + 4x4 test-face/size: test-face/pane/size + 4x4 view test-face --Scott Jones

 [14/14] from: robert:muench:robertmuench at: 20-Sep-2002 16:34


> -----Original Message----- > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]
<<quoted lines omitted: 5>>
> your text, as in: > face/text: "Multiline^/text"
Ok, than I need to know the correct size to use to see the whole text, right? I can use size-text and provide the face to it and later set the correct size. Well, I'm going to try it. Thanks. Robert (no longer confused)

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted