Skip to content

Instantly share code, notes, and snippets.

View AlexanderBaggett's full-sized avatar

Alexander Baggett AlexanderBaggett

View GitHub Profile
@AlexanderBaggett
AlexanderBaggett / gist:04fb6fde4c1bbc4da9042ad28db99f63
Created February 1, 2019 19:55
Gregg Irwin explaining How set works in Red
o: object [a: 1 b: 2 c: 3]
== make object! [
a: 1
b: 2
c: 3
]
>> set o object [a: 11 b: 12]
== make object! [
a: 11
b: 12
@AlexanderBaggett
AlexanderBaggett / EmbeddedScroller.red
Created January 31, 2019 16:22
Toomas Vooglaid's Embedded Scroller
view [
size 390x220
across space 0x0
base 367x200 with [
flags: 'scrollable
pane: layout/only [
origin 0x0 space 0x0
p: panel 350x800 [
origin 0x0 space 0x0
below
@AlexanderBaggett
AlexanderBaggett / ScrollerTest.red
Created January 19, 2019 16:28
Toomasv's Scroller Test
view [panel [origin 0x0 text 40 "Data:" t0: text 40 "" return
sc: scroller 200x300 on-change [t0/text: to-string face/data]]
below text "Selected:" t1: text ""
slider 25x260 [t1/text: to-string round/to sc/selected: face/data .01]
return text "Steps:" t2: text ""
slider 25x260 [t2/text: to-string round/to sc/steps: to-float face/data .01]
]
@AlexanderBaggett
AlexanderBaggett / RefreshLists.red
Created January 19, 2019 16:26
Refresh Red Keyword Lists
foreach line split help-string action! newline [append actions: [] first split trim/lines line " "]
write/lines %actions.txt sort actions
foreach line split help-string datatype! newline [append datatypes: [] first split trim/lines line " "]
write/lines %datatypes.txt sort datatypes
foreach line split help-string event! newline [append events: [] first split trim/lines line " "]
write/lines %events.txt sort events
foreach line split help-string native! newline [append natives: [] first split trim/lines line " "]
@AlexanderBaggett
AlexanderBaggett / scroller.red
Created January 19, 2019 16:23
Toomasv's Scroller
view [
sc: scroller 15x150 [tl/selected: to-integer round/ceiling face/data / face/steps]
on-created [
face/steps: 1.0 / length? tl/data
face/selected: 1.0 / (length? tl/data) * 100%]
tl: text-list 100x150 data [
"one" "two" "three" "four" "five" "six" "seven"
]
]
@AlexanderBaggett
AlexanderBaggett / RTDScroller.red
Last active January 19, 2019 16:23
Toomasv's Rich Text Scroller
context [
rt: scr: i2: none
select-line: function [line][
pos: rt/text
loop line - 1 [pos: find/tail pos newline]
i1: index? pos
if not i2: find next pos lf [i2: tail rt/text]
i2: index? i2
rt/data/1: as-pair i1 i2 - i1
]
public static void Retry(
Action action,
int coolDownSeconds,
int maxAttempt)
{
var exceptions = new List<Exception>();
for (int attempted = 0; attempted < maxAttempt; attempted++)
{
try
{
@AlexanderBaggett
AlexanderBaggett / gist:d1504da93727a1778e8b5b3453946fc1
Last active March 11, 2024 23:25
Full win32 window from C# with Pinvoke
In this post, .net platform has this pinvoke mechanism where it is allowed that you call into the Native windows .
this is extremely useful when you have some 3rd party libraries or if you try to program against with the low-level windows APIS.
One of the typic application htat utilize the Lowe-level windows apis are those Native win32 applications. Where you creat a message pump with the necessary WNDCLASSEX to represent/register the window message pump and message handler process. What you will deal with the win32 applications include the following.
RegisterClassEx, CreateWindowEx, GetMessage(), TranslateMesage(), and DispatchMessage(...).
to be able to use the Window API, you have to declare tons of Structure and PInvoke Method, while you can find help from the Pinvoke.Net.
First, we will introduce some of the win32/user32 functions and their relative structure definitions.
Red []
get-api-data: function [][
collect/into [
foreach w sort words-of system/words [
if all [word? w any-function? get/any :w][
a: ""
append a "-------------"
append a newline
append a w
@AlexanderBaggett
AlexanderBaggett / RedIDE.red
Last active October 16, 2019 14:07
Red IDE
Red [needs 'view]
;;keywords: to-block read %keywords.txt this puts the words on different lines
;;keywords: to-block form read/lines %keywords.txt
functions: read %functions.txt
natives: read %natives.txt
types: read %datatypes.txt
events: read %events.txt
;; could also do read/lines %keywords.txt and put each word on it's own line in the file itself.