-
Notifications
You must be signed in to change notification settings - Fork 3
/
explore_options.go
35 lines (30 loc) · 948 Bytes
/
explore_options.go
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
package structexplorer
type placementFunc func(e *explorer) (newRow, newColumn int)
// ExploreOption is a type for the options that can be passed to the Explore or Follow function.
type ExploreOption struct {
placement placementFunc
}
// RowColumn places the next object in the specified row and column.
func RowColumn(row, column int) ExploreOption {
return ExploreOption{
placement: func(e *explorer) (newRow, newColumn int) {
return row, column
},
}
}
// Column places the next object in the same column on a new free row.
func Column(column int) ExploreOption {
return ExploreOption{
placement: func(e *explorer) (newRow, newColumn int) {
return e.nextFreeRow(column) + 1, column
},
}
}
// Row places the next object in the same row on a new free column.
func Row(row int) ExploreOption {
return ExploreOption{
placement: func(e *explorer) (newRow, newColumn int) {
return row, e.nextFreeColumn(row) + 1
},
}
}