type Direction … const LeftToRight … const RightToLeft … const Mixed … const Neutral … type options … type Option … // DefaultDirection sets the default direction for a Paragraph. The direction is // overridden if the text contains directional characters. func DefaultDirection(d Direction) Option { … } type Paragraph … // Initialize the p.pairTypes, p.pairValues and p.types from the input previously // set by p.SetBytes() or p.SetString(). Also limit the input up to (and including) a paragraph // separator (bidi class B). // // The function p.Order() needs these values to be set, so this preparation could be postponed. // But since the SetBytes and SetStrings functions return the length of the input up to the paragraph // separator, the whole input needs to be processed anyway and should not be done twice. // // The function has the same return values as SetBytes() / SetString() func (p *Paragraph) prepareInput() (n int, err error) { … } // SetBytes configures p for the given paragraph text. It replaces text // previously set by SetBytes or SetString. If b contains a paragraph separator // it will only process the first paragraph and report the number of bytes // consumed from b including this separator. Error may be non-nil if options are // given. func (p *Paragraph) SetBytes(b []byte, opts ...Option) (n int, err error) { … } // SetString configures s for the given paragraph text. It replaces text // previously set by SetBytes or SetString. If s contains a paragraph separator // it will only process the first paragraph and report the number of bytes // consumed from s including this separator. Error may be non-nil if options are // given. func (p *Paragraph) SetString(s string, opts ...Option) (n int, err error) { … } // IsLeftToRight reports whether the principle direction of rendering for this // paragraphs is left-to-right. If this returns false, the principle direction // of rendering is right-to-left. func (p *Paragraph) IsLeftToRight() bool { … } // Direction returns the direction of the text of this paragraph. // // The direction may be LeftToRight, RightToLeft, Mixed, or Neutral. func (p *Paragraph) Direction() Direction { … } // RunAt reports the Run at the given position of the input text. // // This method can be used for computing line breaks on paragraphs. func (p *Paragraph) RunAt(pos int) Run { … } func calculateOrdering(levels []level, runes []rune) Ordering { … } // Order computes the visual ordering of all the runs in a Paragraph. func (p *Paragraph) Order() (Ordering, error) { … } // Line computes the visual ordering of runs for a single line starting and // ending at the given positions in the original text. func (p *Paragraph) Line(start, end int) (Ordering, error) { … } type Ordering … // Direction reports the directionality of the runs. // // The direction may be LeftToRight, RightToLeft, Mixed, or Neutral. func (o *Ordering) Direction() Direction { … } // NumRuns returns the number of runs. func (o *Ordering) NumRuns() int { … } // Run returns the ith run within the ordering. func (o *Ordering) Run(i int) Run { … } type Run … // String returns the text of the run in its original order. func (r *Run) String() string { … } // Bytes returns the text of the run in its original order. func (r *Run) Bytes() []byte { … } // Direction reports the direction of the run. func (r *Run) Direction() Direction { … } // Pos returns the position of the Run within the text passed to SetBytes or SetString of the // originating Paragraph value. func (r *Run) Pos() (start, end int) { … } // AppendReverse reverses the order of characters of in, appends them to out, // and returns the result. Modifiers will still follow the runes they modify. // Brackets are replaced with their counterparts. func AppendReverse(out, in []byte) []byte { … } // ReverseString reverses the order of characters in s and returns a new string. // Modifiers will still follow the runes they modify. Brackets are replaced with // their counterparts. func ReverseString(s string) string { … }