Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 01 2018 17:34
    @greggirwin banned @BIjeuca_twitter
  • Dec 03 2017 05:53
    @PeterWAWood banned @matrixbot
  • Sep 28 2016 12:20
    @PeterWAWood banned @TimeSeriesLord
Vladimir Vasilyev
@9214
@lpvm if we are talking about window menu, then you should extend actor facet with on-menu event handler. For other faces specifying on-menu handler in VID block should be enough.
Luis Vale Mendes
@lpvm
I agree with you that I have to really learn what is said in the documentation. But where is it said on-menu in the documentation of view or VID? Is it implicit?
Specifically p. 11.3
Luis Vale Mendes
@lpvm
Thank you. It's implicit! I'll have to print view and VID on paper to cut, write and make some diagrams! :-)
Vladimir Vasilyev
@9214

It's implicit!

Again, not sure what you mean by that. All info in View/VID documentation is explicit.

Toomas Vooglaid
@toomasv
@lpvm I something like this what you want?:
lay: layout/options [
   on-menu [
      switch event/picked [
         open [probe "opening..."] 
         save [probe "saving..."]
]]][
   menu: ["File" ["Open" open "Save" save]]
]
view lay
Vladimir Vasilyev
@9214
@toomasv you can just go with view/options [on-menu ...][menu: ...].
Toomas Vooglaid
@toomasv
@9214 Yes, of course. But I understood @lpvm asked specifically about layout.
Luis Vale Mendes
@lpvm
@toomasv for now yes, it is! For me it's a lot easier to have some examples and then re-read the documentation. Thanks.
Toomas Vooglaid
@toomasv
@lpvm You are welcome!
Luis Vale Mendes
@lpvm
@9214 Yes, I know about those resources, but the ones I've searched had nothing about placing menus.
Toomas Vooglaid
@toomasv
@lpvm So you can add contextual (right-click) menu to a face:
view [
   area "some words here" 
   with [menu: ["Show" show]] 
   on-menu [switch event/picked [
      show [probe face/text]
   ]]
]
Luis Vale Mendes
@lpvm
Nice!. I read about the popup keyword to create contextual menus, but my attempt was not successful
Vladimir Vasilyev
@9214
view/options [][menu: [popup "a" a "b" b]]
Toomas Vooglaid
@toomasv
@lpvm popup is for creating a right-click menu for window.
Luis Vale Mendes
@lpvm
Understood. These little examples are gold!
Palaing
@Palaing
@9214 FYI - following our discussion: all recent versions of Red windows binary would compile properly on my PC, but the produced gui-console-xxx.exe would not run, though it would run on another machine. I felt more an more frustrated... until today: version red-29nov18-95481b0a.exe compiled and the console showed up! Hallelujah. Don't ask me why.
Vladimir Vasilyev
@9214
Cosmic rays, I presume.
Palaing
@Palaing
@9214 Maybe! Now my old gui-console versions do launch again too. How could I miss that? I thought I had made all possible tests, including with a console-cfg.red file left from an old, working version...
Dave Andersen
@dander
@Palaing did you rule out cranky AV?
Palaing
@Palaing
@dander I think I did - though the AV was messing things up at the beginning. I uninstalled / deactivated AV, emptied quarantine, even cleaned related entries in registry...
Novvorto
@novvorto_twitter
Red []

number: [num-pair]
num-pair: [real-pair | int-pair]
;num-pair: [int-pair | real-pair]
int-pair:[ 0 1 op int]
real-pair:[ 0 1 op real]
op: ["+" | "-"]
int: [some digit]
real: [
    some digit
    "."
    some digit 
]
digit: charset "0123456789"

print parse "12.2-1.2+1-1.2" [some num-pair] print "---"
print parse "12+123-12.34" [some num-pair] print "---"
print parse "-12+123-12.34" [some num-pair] print "---"
With num-pair: [real-pair | int-pair], prints
true
true
true
With num-pair: [int-pair | real-pair], prints
false
false
false
Switching the sequence of checking makes a different. What is the logic behind this?
Vladimir Vasilyev
@9214

@novvorto_twitter Parse rules are left-recursive and greedy. Meaning: the first rules always goes first, and if it can match, then it will match as much as it can.

In your example with [int-pair | real-pair], for instance, 12 is recognized as an integer, and after that parsing fails, as there's nothing that can match .2.

Basically, whenever you reach a real number it will fail, because integer part is consumed my int-pair rule, and decimal part cannot be matched because of leading ..
digit:   charset [#"0" - #"9"]
sign:    charset "+-"

integer: [opt sign some digit]
real:    [integer dot some digit]
number:  [real | integer]

foreach test [
    "12.2-1.2+1-1.2"
    "12+123-12.34"
    "-12+123-12.34"
][
    probe parse test [some number]
]
Novvorto
@novvorto_twitter
I get it. Thanks
LP Olivier
@olivier_lp_twitter
Hi, i m using rebol as a sceipting language on windows, a function I like is Use which is a native function. In red no such function at the moment. Has someone got one, i thought use: func [d b /local f] [f: func append copy [/local] d b f]
Vladimir Vasilyev
@9214
use: func [locals body][
    do bind/copy body context collect [
        forall locals [keep to set-word! locals/1]
        keep none
    ]
]
LP Olivier
@olivier_lp_twitter
@9214 thanx, i m gonna test it, i dont well understand collect/keep
I was a bit upset by the red parse function as it s not working with a string as input, but i saw there is a split function which does the work, pretty well (a char can be the delimiter :-) ) except if the delimiter is a case sensitive string... more and more interesting this language
Vladimir Vasilyev
@9214

I was a bit upset by the red parse function as it s not working with a string as input

Nonsense.

LP Olivier
@olivier_lp_twitter
My bad, a string as rule
Vladimir Vasilyev
@9214
@olivier_lp_twitter use split with bitset! as delimiter for that.

R2:

>> parse "abcdef" "ac"
== ["" "b" "def"]

Red:

>> split "abcdef" charset "ac"
== ["" "b" "def"]
LP Olivier
@olivier_lp_twitter
@9214 yes bitset works fine for multiple char delimiter, but you can use a string as delimiter (in rebol it s less friendly), split "abcdAbcd" "ab" is not case sensitive. With bitset it s case sensitive, my bad is just that there is a use not well done, but not so use
LP Olivier
@olivier_lp_twitter
@9214 do u have a size? Function which work for big files (upper than 232) ? In red as in rebol it s the 232 modulo which is return (integer), i made so long to understand why sometimes i was up to 300 % progressing
Luis Vale Mendes
@lpvm
for doesn't seem to be implemented in Red. Is this a final decision or will we get a similar version to the Rebol's one?
Vladimir Vasilyev
@9214
@lpvm red/REP#6
Luis Vale Mendes
@lpvm
Thanks @9214 . To compare two strings place by place I was thinking on for. I'll use another loop construct then.
Vladimir Vasilyev
@9214
@lpvm just recently I used forall for that.
LP Olivier
@olivier_lp_twitter
@lpvm for in rebol is function, the code is working on red, juste the money! type to be put off
Luis Vale Mendes
@lpvm
In the webpage https://www.red-lang.org/search?q=parse where is said "Creating a simple parser for a subset of HTML", how is the output produced?
Boleslav Březovský
@rebolek
@lpvm with the parse function.
Luis Vale Mendes
@lpvm
Is that example complete?
Boleslav Březovský
@rebolek
@lpvm of course, you can copy/paste it to console and you'll get same result as shown on web.
Luis Vale Mendes
@lpvm
I've copied and pasted, just added the header, but nothing prints.
Boleslav Březovský
@rebolek
@lpvm That's strange, I've tried it right now and works fine:
>>     html: {
{            <html>
{                <head><title>Test</title></head>
{                <body><div><u>Hello</u> <b>World</b></div></body>
{            </html>
{        }
== {^/        <html>^/            <head><title>Test</title></head>^/            <body><div><u>Hello</u> <b>World</b></div></body>^/        </html>^/    }
>> 
>>     ws: charset reduce [space tab cr lf]
== make bitset! #{0064000080}
>> 
>>     parse html tags: [
[            collect [any [
[                ws
[                | "</" thru ">" break
[                | "<" copy name to ">" skip keep (load name) opt tags
[                | keep to "<"
[            ]]
[        ]
== [html [head [title [
    "Test"
]] body [div [u [
    "Hello"
] b [
    "World"
]]]]]