Documentation ¶
Overview ¶
Text printing and output control. The default Tapestry runtime will process printed text according to its [markup rules](https://pkg.go.dev/git.sr.ht/~ionous/tapestry/web/markup).
Index ¶
- Variables
- func Register(reg func(any))
- type BufferText
- type BufferText_Slice
- type Counter
- type Counter_Slot
- type Counter_Slots
- type CycleText
- type CycleText_Slice
- type LineBreak
- type LineBreak_Slice
- type MenuData
- type MenuOptions
- type MenuOptions_Slice
- type ParagraphBreak
- type ParagraphBreak_Slice
- type PrintBrackets
- type PrintBrackets_Slice
- type PrintCommas
- type PrintCommas_Slice
- type PrintCount
- type PrintCount_Slice
- type PrintMenu
- type PrintMenuChoice
- type PrintMenuChoice_Slice
- type PrintMenu_Slice
- type PrintNum
- type PrintNum_Slice
- type PrintRow
- type PrintRow_Slice
- type PrintRows
- type PrintRows_Slice
- type PrintText
- type PrintText_Slice
- type PrintWords
- type PrintWords_Slice
- type SayActor
- type SayActor_Slice
- type ShuffleText
- type ShuffleText_Slice
- type Shuffler
- type SoftBreak
- type SoftBreak_Slice
- type StoppingText
- type StoppingText_Slice
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var Z_Types = typeinfo.TypeSet{ Name: "format", Comment: []string{ "Text printing and output control.", "The default Tapestry runtime will process printed text according to its [markup rules](https://pkg.go.dev/git.sr.ht/~ionous/tapestry/web/markup).", }, Slot: z_slot_list, Flow: z_flow_list, Signatures: z_signatures, }
package listing of type data
var Zt_BufferText typeinfo.Flow
buffer_text, a type of flow.
var Zt_Counter = typeinfo.Slot{ Name: "counter", Markup: map[string]any{ "--": "A slot used internally for generating unique names during weave.", }, }
counter, a type of slot.
var Zt_CycleText typeinfo.Flow
cycle_text, a type of flow.
var Zt_LineBreak typeinfo.Flow
line_break, a type of flow.
var Zt_MenuOptions typeinfo.Flow
menu_options, a type of flow.
var Zt_ParagraphBreak typeinfo.Flow
paragraph_break, a type of flow.
var Zt_PrintBrackets typeinfo.Flow
print_brackets, a type of flow.
var Zt_PrintCommas typeinfo.Flow
print_commas, a type of flow.
var Zt_PrintCount typeinfo.Flow
print_count, a type of flow.
var Zt_PrintMenu typeinfo.Flow
print_menu, a type of flow.
var Zt_PrintMenuChoice typeinfo.Flow
print_menu_choice, a type of flow.
var Zt_PrintNum typeinfo.Flow
print_num, a type of flow.
var Zt_PrintRow typeinfo.Flow
print_row, a type of flow.
var Zt_PrintRows typeinfo.Flow
print_rows, a type of flow.
var Zt_PrintText typeinfo.Flow
print_text, a type of flow.
var Zt_PrintWords typeinfo.Flow
print_words, a type of flow.
var Zt_SayActor typeinfo.Flow
say_actor, a type of flow.
var Zt_ShuffleText typeinfo.Flow
shuffle_text, a type of flow.
var Zt_SoftBreak typeinfo.Flow
soft_break, a type of flow.
var Zt_StoppingText typeinfo.Flow
stopping_text, a type of flow.
Functions ¶
Types ¶
type BufferText ¶
Capture any and all text printed by the game, and return it as a single string of continuous text. New lines are stored as line feeds ('\n').
func (*BufferText) GetMarkup ¶
func (op *BufferText) GetMarkup(ensure bool) map[string]any
Implements typeinfo.Markup
type BufferText_Slice ¶
type BufferText_Slice []BufferText
Holds a slice of type BufferText.
func (*BufferText_Slice) Repeats ¶
func (op *BufferText_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of BufferText.
func (*BufferText_Slice) TypeInfo ¶
func (*BufferText_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of BufferText.
type Counter ¶
type Counter interface {
GetInternalCounter() *string
}
A slot used internally for generating unique names during weave.
type Counter_Slot ¶
type Counter_Slot struct{ Value Counter }
Holds a single slot.
func (*Counter_Slot) TypeInfo ¶
func (*Counter_Slot) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a single slot.
type Counter_Slots ¶
type Counter_Slots []Counter
Holds a slice of slots.
func (*Counter_Slots) Repeats ¶
func (op *Counter_Slots) Repeats() bool
Implements typeinfo.Repeats for a slice of slots.
func (*Counter_Slots) TypeInfo ¶
func (*Counter_Slots) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of slots.
type CycleText ¶
type CycleText struct { Name string Parts []rtti.TextEval Markup map[string]any `json:",omitempty"` }
Returns some text selected from a set of predefined values. When called multiple times, this returns each one of the values in their specified order, then it loops back to the first value again.
func (*CycleText) GetInternalCounter ¶
func (*CycleText) GetMarkup ¶
Implements typeinfo.Markup
type CycleText_Slice ¶
type CycleText_Slice []CycleText
Holds a slice of type CycleText.
func (*CycleText_Slice) Repeats ¶
func (op *CycleText_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of CycleText.
func (*CycleText_Slice) TypeInfo ¶
func (*CycleText_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of CycleText.
type LineBreak ¶
Start a new line. See also the <br> markup.
func (*LineBreak) GetMarkup ¶
Implements typeinfo.Markup
type LineBreak_Slice ¶
type LineBreak_Slice []LineBreak
Holds a slice of type LineBreak.
func (*LineBreak_Slice) Repeats ¶
func (op *LineBreak_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of LineBreak.
func (*LineBreak_Slice) TypeInfo ¶
func (*LineBreak_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of LineBreak.
type MenuData ¶ added in v0.24.8
var CurrentMenu MenuData
alt: could collect into a private member of print menu choices alt: the parser could examine the text output and capture the choices. ( examining the ol / ul for numbers i suppose )
func GetMenuData ¶ added in v0.24.8
type MenuOptions ¶ added in v0.24.8
type MenuOptions struct { ShowList rtti.BoolEval ShowNumbers rtti.BoolEval Markup map[string]any `json:",omitempty"` }
Settings to control menu presentation.
func (*MenuOptions) GetMarkup ¶ added in v0.24.8
func (op *MenuOptions) GetMarkup(ensure bool) map[string]any
Implements typeinfo.Markup
func (*MenuOptions) TypeInfo ¶ added in v0.24.8
func (*MenuOptions) TypeInfo() typeinfo.T
Implements typeinfo.Instance
type MenuOptions_Slice ¶ added in v0.24.8
type MenuOptions_Slice []MenuOptions
Holds a slice of type MenuOptions.
func (*MenuOptions_Slice) Repeats ¶ added in v0.24.8
func (op *MenuOptions_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of MenuOptions.
func (*MenuOptions_Slice) TypeInfo ¶ added in v0.24.8
func (*MenuOptions_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of MenuOptions.
type ParagraphBreak ¶
Add a single blank line ( unless a blank line was just written ). See also the <p> markup.
func (*ParagraphBreak) GetMarkup ¶
func (op *ParagraphBreak) GetMarkup(ensure bool) map[string]any
Implements typeinfo.Markup
func (*ParagraphBreak) TypeInfo ¶
func (*ParagraphBreak) TypeInfo() typeinfo.T
Implements typeinfo.Instance
type ParagraphBreak_Slice ¶
type ParagraphBreak_Slice []ParagraphBreak
Holds a slice of type ParagraphBreak.
func (*ParagraphBreak_Slice) Repeats ¶
func (op *ParagraphBreak_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of ParagraphBreak.
func (*ParagraphBreak_Slice) TypeInfo ¶
func (*ParagraphBreak_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of ParagraphBreak.
type PrintBrackets ¶
Collect printed text and surround the output with parenthesis '()'. If no text is printed, no parentheses are printed.
Example ¶
package main import ( "os" "git.sr.ht/~ionous/tapestry/dl/format" "git.sr.ht/~ionous/tapestry/dl/literal" "git.sr.ht/~ionous/tapestry/rt" "git.sr.ht/~ionous/tapestry/rt/safe" "git.sr.ht/~ionous/tapestry/rt/writer" "git.sr.ht/~ionous/tapestry/test/testutil" ) var helloThereWorld = []rt.Execute{ &format.PrintText{Text: literal.T("hello")}, &format.PrintText{Text: literal.T("there")}, &format.PrintText{Text: literal.T("world")}, } func main() { var run sayTester run.SetWriter(os.Stdout) if e := safe.WriteText(&run, &format.PrintBrackets{Exe: helloThereWorld}); e != nil { panic(e) } } type baseRuntime struct { testutil.PanicRuntime } type sayTester struct { baseRuntime writer.Sink }
Output: (hello there world)
func (*PrintBrackets) GetMarkup ¶
func (op *PrintBrackets) GetMarkup(ensure bool) map[string]any
Implements typeinfo.Markup
func (*PrintBrackets) TypeInfo ¶
func (*PrintBrackets) TypeInfo() typeinfo.T
Implements typeinfo.Instance
type PrintBrackets_Slice ¶
type PrintBrackets_Slice []PrintBrackets
Holds a slice of type PrintBrackets.
func (*PrintBrackets_Slice) Repeats ¶
func (op *PrintBrackets_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of PrintBrackets.
func (*PrintBrackets_Slice) TypeInfo ¶
func (*PrintBrackets_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of PrintBrackets.
type PrintCommas ¶
Separates words with commas, and 'and'.
Example ¶
package main import ( "os" "git.sr.ht/~ionous/tapestry/dl/format" "git.sr.ht/~ionous/tapestry/dl/literal" "git.sr.ht/~ionous/tapestry/rt" "git.sr.ht/~ionous/tapestry/rt/safe" "git.sr.ht/~ionous/tapestry/rt/writer" "git.sr.ht/~ionous/tapestry/test/testutil" ) var helloThereWorld = []rt.Execute{ &format.PrintText{Text: literal.T("hello")}, &format.PrintText{Text: literal.T("there")}, &format.PrintText{Text: literal.T("world")}, } func main() { var run sayTester run.SetWriter(os.Stdout) if e := safe.WriteText(&run, &format.PrintCommas{Exe: helloThereWorld}); e != nil { panic(e) } } type baseRuntime struct { testutil.PanicRuntime } type sayTester struct { baseRuntime writer.Sink }
Output: hello, there, and world
func (*PrintCommas) GetMarkup ¶
func (op *PrintCommas) GetMarkup(ensure bool) map[string]any
Implements typeinfo.Markup
func (*PrintCommas) TypeInfo ¶
func (*PrintCommas) TypeInfo() typeinfo.T
Implements typeinfo.Instance
type PrintCommas_Slice ¶
type PrintCommas_Slice []PrintCommas
Holds a slice of type PrintCommas.
func (*PrintCommas_Slice) Repeats ¶
func (op *PrintCommas_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of PrintCommas.
func (*PrintCommas_Slice) TypeInfo ¶
func (*PrintCommas_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of PrintCommas.
type PrintCount ¶
Express an integer in plain english ( aka a cardinal number ). For example, given the number `12` return the text "tweleve". It converts floating point numbers to integer by truncating: given `1.6`, it returns "one".
The [story.Execute] version prints the text for the player.
Example ¶
var run sayTester run.SetWriter(os.Stdout) if e := safe.WriteText(&run, &PrintCount{Num: literal.F(213)}); e != nil { panic(e) }
Output: two hundred thirteen
func (*PrintCount) GetMarkup ¶
func (op *PrintCount) GetMarkup(ensure bool) map[string]any
Implements typeinfo.Markup
type PrintCount_Slice ¶
type PrintCount_Slice []PrintCount
Holds a slice of type PrintCount.
func (*PrintCount_Slice) Repeats ¶
func (op *PrintCount_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of PrintCount.
func (*PrintCount_Slice) TypeInfo ¶
func (*PrintCount_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of PrintCount.
type PrintMenu ¶ added in v0.24.8
type PrintMenu struct { ActionName rtti.TextEval MenuOptions *MenuOptions Exe []rtti.Execute Markup map[string]any `json:",omitempty"` }
Starts a menu. Individual menu options are printed with `Print choice:`. It's considered an error to try to print multiple menus in single turn. Menus
func (*PrintMenu) GetMarkup ¶ added in v0.24.8
Implements typeinfo.Markup
type PrintMenuChoice ¶ added in v0.24.8
type PrintMenuChoice struct { Label rtti.TextEval Content rtti.TextEval Markup map[string]any `json:",omitempty"` }
Prints an individual menu choice. It's considered an error to try to print a menu choice other than during `Print menu:choices:`.
func (*PrintMenuChoice) Execute ¶ added in v0.24.8
func (op *PrintMenuChoice) Execute(run rt.Runtime) (err error)
func (*PrintMenuChoice) GetMarkup ¶ added in v0.24.8
func (op *PrintMenuChoice) GetMarkup(ensure bool) map[string]any
Implements typeinfo.Markup
func (*PrintMenuChoice) TypeInfo ¶ added in v0.24.8
func (*PrintMenuChoice) TypeInfo() typeinfo.T
Implements typeinfo.Instance
type PrintMenuChoice_Slice ¶ added in v0.24.8
type PrintMenuChoice_Slice []PrintMenuChoice
Holds a slice of type PrintMenuChoice.
func (*PrintMenuChoice_Slice) Repeats ¶ added in v0.24.8
func (op *PrintMenuChoice_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of PrintMenuChoice.
func (*PrintMenuChoice_Slice) TypeInfo ¶ added in v0.24.8
func (*PrintMenuChoice_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of PrintMenuChoice.
type PrintMenu_Slice ¶ added in v0.24.8
type PrintMenu_Slice []PrintMenu
Holds a slice of type PrintMenu.
func (*PrintMenu_Slice) Repeats ¶ added in v0.24.8
func (op *PrintMenu_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of PrintMenu.
func (*PrintMenu_Slice) TypeInfo ¶ added in v0.24.8
func (*PrintMenu_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of PrintMenu.
type PrintNum ¶
Express a number using digits. For example, given the number `12` return the text "12".
The [story.Execute] version prints the text for the player.
Example ¶
var run sayTester run.SetWriter(os.Stdout) if e := safe.WriteText(&run, &PrintNum{Num: literal.F(213)}); e != nil { panic(e) }
Output: 213
func (*PrintNum) GetMarkup ¶
Implements typeinfo.Markup
type PrintNum_Slice ¶
type PrintNum_Slice []PrintNum
Holds a slice of type PrintNum.
func (*PrintNum_Slice) Repeats ¶
func (op *PrintNum_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of PrintNum.
func (*PrintNum_Slice) TypeInfo ¶
func (*PrintNum_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of PrintNum.
type PrintRow ¶
Group text into a single line <li> as part of a list of lines. See also: `Print rows:`.
func (*PrintRow) GetMarkup ¶
Implements typeinfo.Markup
type PrintRow_Slice ¶
type PrintRow_Slice []PrintRow
Holds a slice of type PrintRow.
func (*PrintRow_Slice) Repeats ¶
func (op *PrintRow_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of PrintRow.
func (*PrintRow_Slice) TypeInfo ¶
func (*PrintRow_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of PrintRow.
type PrintRows ¶
Group text into an unordered list <ul>.
func (*PrintRows) GetMarkup ¶
Implements typeinfo.Markup
type PrintRows_Slice ¶
type PrintRows_Slice []PrintRows
Holds a slice of type PrintRows.
func (*PrintRows_Slice) Repeats ¶
func (op *PrintRows_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of PrintRows.
func (*PrintRows_Slice) TypeInfo ¶
func (*PrintRows_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of PrintRows.
type PrintText ¶
Display some text to the player. The default runtime will format the text according to the rules specified by the Tapestry markup package: https://pkg.go.dev/git.sr.ht/~ionous/tapestry/web/markup
func (*PrintText) GetMarkup ¶
Implements typeinfo.Markup
type PrintText_Slice ¶
type PrintText_Slice []PrintText
Holds a slice of type PrintText.
func (*PrintText_Slice) Repeats ¶
func (op *PrintText_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of PrintText.
func (*PrintText_Slice) TypeInfo ¶
func (*PrintText_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of PrintText.
type PrintWords ¶
type PrintWords struct { Separator rtti.TextEval Exe []rtti.Execute Markup map[string]any `json:",omitempty"` }
Collect printed text and separate that text by single spaces.
Example ¶
package main import ( "os" "git.sr.ht/~ionous/tapestry/dl/format" "git.sr.ht/~ionous/tapestry/dl/literal" "git.sr.ht/~ionous/tapestry/rt" "git.sr.ht/~ionous/tapestry/rt/safe" "git.sr.ht/~ionous/tapestry/rt/writer" "git.sr.ht/~ionous/tapestry/test/testutil" ) var helloThereWorld = []rt.Execute{ &format.PrintText{Text: literal.T("hello")}, &format.PrintText{Text: literal.T("there")}, &format.PrintText{Text: literal.T("world")}, } func main() { var run sayTester run.SetWriter(os.Stdout) if e := safe.WriteText(&run, &format.PrintWords{Exe: helloThereWorld}); e != nil { panic(e) } } type baseRuntime struct { testutil.PanicRuntime } type sayTester struct { baseRuntime writer.Sink }
Output: hello there world
func (*PrintWords) GetMarkup ¶
func (op *PrintWords) GetMarkup(ensure bool) map[string]any
Implements typeinfo.Markup
type PrintWords_Slice ¶
type PrintWords_Slice []PrintWords
Holds a slice of type PrintWords.
func (*PrintWords_Slice) Repeats ¶
func (op *PrintWords_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of PrintWords.
func (*PrintWords_Slice) TypeInfo ¶
func (*PrintWords_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of PrintWords.
type SayActor ¶ added in v0.24.8
type SayActor struct { Actor rtti.TextEval Text rtti.TextEval Markup map[string]any `json:",omitempty"` }
Have a particular actor say some text to the player. The text can contain a "template" which holds commands executed at runtime. See the Tapestry guide for more information.
func (*SayActor) GetMarkup ¶ added in v0.24.8
Implements typeinfo.Markup
type SayActor_Slice ¶ added in v0.24.8
type SayActor_Slice []SayActor
Holds a slice of type SayActor.
func (*SayActor_Slice) Repeats ¶ added in v0.24.8
func (op *SayActor_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of SayActor.
func (*SayActor_Slice) TypeInfo ¶ added in v0.24.8
func (*SayActor_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of SayActor.
type ShuffleText ¶
type ShuffleText struct { Name string Parts []rtti.TextEval Markup map[string]any `json:",omitempty"` // contains filtered or unexported fields }
Returns some text selected from a set of predefined values. When called multiple times, this returns each one of the values in a randomized order. After returning all of the available options, it begins again with a new ordering.
func (*ShuffleText) GetInternalCounter ¶
func (op *ShuffleText) GetInternalCounter() *string
func (*ShuffleText) GetMarkup ¶
func (op *ShuffleText) GetMarkup(ensure bool) map[string]any
Implements typeinfo.Markup
func (*ShuffleText) TypeInfo ¶
func (*ShuffleText) TypeInfo() typeinfo.T
Implements typeinfo.Instance
type ShuffleText_Slice ¶
type ShuffleText_Slice []ShuffleText
Holds a slice of type ShuffleText.
func (*ShuffleText_Slice) Repeats ¶
func (op *ShuffleText_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of ShuffleText.
func (*ShuffleText_Slice) TypeInfo ¶
func (*ShuffleText_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of ShuffleText.
type SoftBreak ¶
Start a new line ( if not already at a new line ). See also the <wbr> markup.
func (*SoftBreak) GetMarkup ¶
Implements typeinfo.Markup
type SoftBreak_Slice ¶
type SoftBreak_Slice []SoftBreak
Holds a slice of type SoftBreak.
func (*SoftBreak_Slice) Repeats ¶
func (op *SoftBreak_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of SoftBreak.
func (*SoftBreak_Slice) TypeInfo ¶
func (*SoftBreak_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of SoftBreak.
type StoppingText ¶
type StoppingText struct { Name string Parts []rtti.TextEval Markup map[string]any `json:",omitempty"` }
Returns some text selected from a set of predefined values. When called multiple times, this returns each of its inputs in turn. After returning all of the available options, it sticks to using the last option.
As a special case, if there was only ever one option: it returns that option followed by nothing ( the empty string ) forever after.
func (*StoppingText) GetInternalCounter ¶
func (op *StoppingText) GetInternalCounter() *string
func (*StoppingText) GetMarkup ¶
func (op *StoppingText) GetMarkup(ensure bool) map[string]any
Implements typeinfo.Markup
func (*StoppingText) TypeInfo ¶
func (*StoppingText) TypeInfo() typeinfo.T
Implements typeinfo.Instance
type StoppingText_Slice ¶
type StoppingText_Slice []StoppingText
Holds a slice of type StoppingText.
func (*StoppingText_Slice) Repeats ¶
func (op *StoppingText_Slice) Repeats() bool
Implements typeinfo.Repeats for a slice of StoppingText.
func (*StoppingText_Slice) TypeInfo ¶
func (*StoppingText_Slice) TypeInfo() typeinfo.T
Implements typeinfo.Instance for a slice of StoppingText.