File: action.go

package info (click to toggle)
golang-github-yosssi-ace 0.0.5-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 484 kB
  • sloc: makefile: 21; sh: 1
file content (45 lines) | stat: -rw-r--r-- 828 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package ace

import (
	"bytes"
	"io"
	"strings"
)

// action represents an action.
type action struct {
	elementBase
}

// WriteTo writes data to w.
func (e *action) WriteTo(w io.Writer) (int64, error) {
	var bf bytes.Buffer

	// Write the action
	bf.WriteString(strings.TrimSpace(e.ln.str))

	// Write the children's HTML.
	if i, err := e.writeChildren(&bf); err != nil {
		return i, err
	}

	// Write the buffer.
	i, err := w.Write(bf.Bytes())

	return int64(i), err

}

func (e *action) IsBlockElement() bool {
	return e.parent.IsBlockElement()
}
func (e *action) IsControlElement() bool {
	return true
}

// newAction creates and returns an action.
func newAction(ln *line, rslt *result, src *source, parent element, opts *Options) *action {
	return &action{
		elementBase: newElementBase(ln, rslt, src, parent, opts),
	}
}