Skip to content

Instantly share code, notes, and snippets.

@nedzadarek
Created September 3, 2018 12:10
Show Gist options
  • Save nedzadarek/2893d446f1086a29fc226c611e4522db to your computer and use it in GitHub Desktop.
Save nedzadarek/2893d446f1086a29fc226c611e4522db to your computer and use it in GitHub Desktop.
Help system for vid (tested with Red for Windows version 0.6.3 built 26-Mar-2018)
Red [
author: "Nędza Darek"
license: "Just point to this repository/gist"
content-used: [
examples: http://www.red-by-example.org
docs: https://doc.red-lang.org/en/vid.html
]
bugs-new_features: [
printing: {Print in nice form and divide by words}
]
version: alpha
]
vid-help: [
tab-panel: [
syntax: {
group-box <divider> <options> [<body>]
<divider> : optional number of row or columns (integer!).
<options> : optional list of settings for the panel.
<body> : panel's VID content description (block!).
}
description: {
Constructs a child group-box panel inside the current container, where the content is another VID block. A divider argument can be provided, setting a grid-mode layout:
- if the direction is across, divider represents number of columns.
- if the direction is below, divider represents number of rows.
Note:
Providing a string! value as option will set the group-box title text.
}
examples: [
[
tab-panel 250x120 [
"tab a" [base red]
"tab b" [base blue]
]
]
[
tab-panel 250x120 [
"tab A" [f: field "0"]
"randomize A" [button "randomize field"[f/text: to-string random 42]]
]
]
]
]
]
; FIX ME
print-pad: function [
str [string!]
n [integer!]
][
position: str
loop n [prin " "]
print copy/part str (position: system/console/size/x - n)
position: at str (position + 1)
unless tail? position [print-pad position n]
exit
]
; str: make string! 300
; insert/dup str " " 12
; repeat n 300 [i: i + 1 if i > 9 [i: 0] append str i]
; print-pad str 5
?vid: function [
'word
/example n
/examples
/next-examples
/description
/syntax
][
case [
description [
print-pad vid-help/:word/description 5
]
syntax [
print-pad vid-help/:word/syntax 5
]
examples [
i: 0
foreach example vid-help/:word/examples [
i: i + 1
print "############"
print ["#" i ": "]
print-pad mold/only example 5
view example
]
]
example [
print ["#" n ": "]
print-pad mold/only vid-help/:word/examples/:n 5
view vid-help/:word/examples/:n
]
true [
print "Description: "
print-pad vid-help/:word/description 5
print "Syntax: "
print-pad vid-help/:word/syntax 5
print "Examples: "
i: 0
foreach example vid-help/:word/examples [
print "#######"
i: i + 1
print ["#" i ": "]
print-pad mold example 5
]
]
]
]
?vid tab-panel
?vid/description tab-panel
?vid/syntax tab-panel
; examples' codes are printed in the console!
?vid/examples tab-panel
?vid/example tab-panel 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment