Skip to content

Instantly share code, notes, and snippets.

@GiuseppeChillemi
GiuseppeChillemi / func-ctx.red
Last active December 31, 2024 01:24
Func-ctx Function creator
Red [
Title: "Func-ctx Function creator"
Description: "100% compatible Function creator for functions that could accept a context to set its one to"
Usage: {
func-ctx body specs
To pass a context, simply
myfunc/ctx arg1 arg2... context [arg1: value arg2: value....]
@GiuseppeChillemi
GiuseppeChillemi / replica.red
Created November 30, 2024 01:23
Replicates a function adding custom code handling
Red [
title: "Replica"
Description: "Creates another function that calls the original, with context manipulation capabilities"
Author: "Giuseppe Chillemi"
Copyright: "MIT license"
Version: 1.00
Needs: [
func-spec-words
quotes
get-all
@GiuseppeChillemi
GiuseppeChillemi / Propagate.red
Last active November 29, 2024 02:51
Field propagation between objects with transformations
Red [
title: "Propagate"
Description: "Propagates fields values accross objects with transformations"
Author: "Giuseppe Chillemi"
Copyright: "MIT license"
Version: 2.00
Needs: {
`Mirror` function
https://gist.github.com/GiuseppeChillemi/99e77fa72f8a417b82d3e7502068c1a8
}
@GiuseppeChillemi
GiuseppeChillemi / mirror.red
Last active November 29, 2024 02:42
Mirrors a field value to another object using a map. It could use a block for modification
Red [
Title: "Mirror fields"
Description: "Mirrors a field from a context to another. A modification code can be used"
Usage: mirror [obj1 obj2] [src-word | :src-word dest-word | 'dst-word [code]....]
Version: 2.0
]
mirror: func [
"Mirrors the value of a word in a context to a word in another"
objects [block!] "The objects to link"
@GiuseppeChillemi
GiuseppeChillemi / composable-vid
Created October 29, 2024 20:55
Composable library
Red [
Title: "VID Composablel library test"
]
library: [
p1 [
code-segment [
panel 600x40 [
b: button "Hit me!" [
@GiuseppeChillemi
GiuseppeChillemi / Compose-where.red
Created October 24, 2024 22:07
compose-where 1.0
Red [
title: "Compose-where"
Description: "A dialected compose with filtering and auto composition"
]
compose-where: func [
"Compose where groups match using CMP/GROUP/(code). Use CMPO for ONLY"
series [block!] "The block to compose"
/group "Specify a group to compose"
grp [word! block!] "The group(s) to compose"
@GiuseppeChillemi
GiuseppeChillemi / Include-Function.red
Last active October 8, 2024 02:42
Include-Function.red
Red [
Title: "Include a Function from a file"
Description: "Extracts and load one or more functions from a file"
]
copy-function: func [
"Search for a function definition and copy it from a block"
file [block!] "A block containing the functions"
@GiuseppeChillemi
GiuseppeChillemi / Collect-Function
Last active January 30, 2024 02:42
Collect-Functions
Red [
title: "collect-functions"
description: "collects all the function names found inside a block (statically and not at runtime)"
]
add-function: func [
"Append the function name to the target container"
container [block!] "The container of functions"
name [word! set-word! lit-word! paren!] "The function to add or the paren that will be reduced to the name"
/index "Adds the path to reach the function from the top"
@GiuseppeChillemi
GiuseppeChillemi / for-record.red
Last active January 22, 2024 02:54
For-Skip attemp
Red [
title: "For-Record"
description: "A For-skip alternative"
notes: {
Use BREAK-HERE let the function return the series at current position
Use RETURN-VALUE to let the function return anything you want
If the cycle will end naturally, the series will be at head position
}
]
@GiuseppeChillemi
GiuseppeChillemi / set-caret-test.red
Created October 18, 2023 22:38
Set-Caret does not work
Red [
title: "NoteManager Evolution"
needs: 'View
]
#system [
#import [
"user32.dll" stdcall [
SendMessage: "SendMessageW" [