World: r3wp
[Rebol School] Rebol School
older newer | first last |
Brock 5-Feb-2009 [1450x3] | If I can blend these two functionalities into one, I'd have the best of both worlds. Essentially I'm looking to build a Vector-like draw program, but as simple and small as possible. This would allow drag points onto any selected object in order to allow for resizing or fine-tuning of object placement. As I said previously, I believe Anton has done some work with drag-points on lines etc, but don't remember the script name that did this. Warp-image.r also does something similar with an image. |
I think this would be a very interesting project to undertake. It would be nice to have both the smallest paint program, and vector drawing program in Rebol. | |
I'm sure you will let me know if there are any issues accessing the file. | |
Graham 5-Feb-2009 [1453] | Needs sqlite.r |
Brock 5-Feb-2009 [1454] | you can remove that line from the code, it's only used to save the draw data if you press the save button. I should have removed any reference to the sqlite and the associated queries. |
Graham 5-Feb-2009 [1455] | those text objects can be dragged over the drawing area ... |
Brock 5-Feb-2009 [1456x2] | yes they can, but they don't get included in the draw block that is being represented. Whereas the objects that are selectable by the radio buttons are actually included in the draw block. |
I used the method to drag-and-drop as used in Nick's Guitar Chords app. It worked great for that type of drag and drop. | |
kib2 6-Feb-2009 [1458] | Hi, I'm starting with Rebol and I'm asking myself how to split a given string according to a pattern delimiter : "2 linebreaks or more" ? |
Izkata 6-Feb-2009 [1459] | Simplest way I can think of: parse "One^/Two^/^/Three^/^/^/Four" "^/" The ^/ is an escape character meaning newline |
kib2 6-Feb-2009 [1460] | Izkata: thanks for answering me. In fact that's what I'm currently using, but that's not satisfying because I'm splitting with one linebreak, to two. I'm looking for something that outputs : ["One^/Two" "Three" "Four"] |
Geomol 6-Feb-2009 [1461] | >> out: [] >> parse "one^/two^/^/three^/^/^/four" [any [copy arg to "^/^/" (append out arg) any newline] copy arg to end (append out arg)] == true >> out == ["one^/two" "three" "four"] |
Henrik 6-Feb-2009 [1462] | Geomol, you are faster than me, but that's almost the same as I was coming up with :-) |
Geomol 6-Feb-2009 [1463] | :-) Now, is there any shorter/smarter way to do it? |
Henrik 6-Feb-2009 [1464] | it is probably easier in R3. |
kib2 6-Feb-2009 [1465x2] | Thanks a lot Geomol (can you explain to me a bit your snippet? I'm currently studying the parse dialect) |
Henrik: why would it be easier in R3 : does parse gained some additional tricks ? | |
Geomol 6-Feb-2009 [1467] | The second argument to parse can be a string, and then parse split up the first argument, or the second argument can be a block of parsing rules. out is just my output block. So the parsing rules go: 1) first any of a sub-block of sub-rules 2) sub-block copy the input string to a point, where two newlines are found, the result in the variable: arg 3) the paranthesis is evaluated (as normal REBOL code), and it append arg (the part of the string, we just copied) to the variable out 4) the parser then skip any number of newlines (2, 3 or more) 5) when the sub-rules are not valid any longer, the input string is copied till the end (and appended to out as before) |
Henrik 6-Feb-2009 [1468x2] | kib2: not yet, but there are some more logical string splitting functions in R3. |
particularly string parsing needs to be improved. the above code should be simpler to do. | |
kib2 6-Feb-2009 [1470] | Geomol: thanks for the explanations. If I understand it well, that means that we can add actions during the parsing phase? That seems really powerful! |
Henrik 6-Feb-2009 [1471] | parse is ridiculously powerful (and equally hard to learn/use) :-) |
Geomol 6-Feb-2009 [1472] | yes, paranthesis can hold any normal REBOL code (or actions as you call it). |
kib2 6-Feb-2009 [1473] | Henrik: you mean things like python's "...".split(delimiter) ? |
Henrik 6-Feb-2009 [1474] | yes |
Geomol 6-Feb-2009 [1475] | kib2, if you're going to use parse, go read this: http://www.rebol.com/docs/core23/rebolcore-15.html |
kib2 6-Feb-2009 [1476x2] | Geomol: nice, I've made a print version of a nice doc I've found here http://www.codeconscious.com/rebol/parse-tutorial.html, but I don't know if it's up to date. |
Henrik: from what I've seen so far, such things are quiet easy with parse. | |
Geomol 6-Feb-2009 [1478] | That should be up to date too. |
kib2 6-Feb-2009 [1479] | Geomol: ok, thanks. From what I'm reading, that's how Rebol builds all those dialects too. |
Geomol 6-Feb-2009 [1480] | I think, parsing in REBOL is really strong. It makes us read about any kind of input without too much hazzle (once you've taken the time to get a feel for parse). |
Henrik 6-Feb-2009 [1481x2] | yes, dialects can be processed with parse, however it's not the only method. |
what makes parse truly powerful is multiple levels of dialects. | |
kib2 6-Feb-2009 [1483] | So Rebol does not really need regexps, that's it ? |
Geomol 6-Feb-2009 [1484] | What was the definition of a dialect? Something that LOAD can handle? |
Henrik 6-Feb-2009 [1485] | Geomol. yes I think so. |
kib2 6-Feb-2009 [1486] | Parse seems to me like packrat parsers (pegs) |
Henrik 6-Feb-2009 [1487] | I can read parse dialects. I can't read regexp. :-) |
kib2 6-Feb-2009 [1488] | Henrik: well, I think that's their purpose : your code becomes very readable. But what about the perfs ? |
Geomol 6-Feb-2009 [1489] | hehe :-) |
kib2 6-Feb-2009 [1490] | Geomol: what do you mean ?! Poor or better than regexps ? |
Geomol 6-Feb-2009 [1491] | kib, I think, you'll find performance of parse to be really good, and I think, the reason is, that parse is native. |
kib2 6-Feb-2009 [1492] | Geomol: you mean parse is C implemented ? |
Geomol 6-Feb-2009 [1493] | kib, I would say REBOL parse is a lot better than regexps. Yes, native words in REBOL is implemented in C. |
Henrik 6-Feb-2009 [1494] | parse is surprisingly fast, yes. |
kib2 6-Feb-2009 [1495] | Geomol: cool. And does parse uses Unicode with R3 now ? |
Geomol 6-Feb-2009 [1496x2] | I think, Henrik is better to answer that. |
R3 parse project: http://www.rebol.net/wiki/Parse_Project It mention unicode. | |
Henrik 6-Feb-2009 [1498] | I think it will support unicode, yes. |
kib2 6-Feb-2009 [1499] | That's very nice. Is parse inspired from something (another langage maybe ?). |
older newer | first last |