-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
add Follow and ExploreOption (#3)
* work on placement options * tryout explore opts * work on Follow * work on follow * working follow * add option to follow * add SameRow, SameColumn * add tests, fix zero mapkey check * add int tests * see what disable cache means * add comments
Showing
15 changed files
with
338 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
examples/dump/structexplorer.html | ||
structexplorer.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
}, | ||
} | ||
} | ||
|
||
// OnColumn places the next object in the same column on a new free row. | ||
func OnColumn(column int) ExploreOption { | ||
return ExploreOption{ | ||
placement: func(e *explorer) (newRow, newColumn int) { | ||
return e.nextFreeRow(column) + 1, column | ||
}, | ||
} | ||
} | ||
|
||
// OnRow places the next object in the same row on a new free column. | ||
func OnRow(row int) ExploreOption { | ||
return ExploreOption{ | ||
placement: func(e *explorer) (newRow, newColumn int) { | ||
return row, e.nextFreeColumn(row) + 1 | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package structexplorer | ||
|
||
import ( | ||
"net/http" | ||
"path" | ||
) | ||
|
||
// Options can be used to configure a Service on startup. | ||
type Options struct { | ||
// Uses 5656 as the default | ||
HTTPPort int | ||
// Uses http.DefaultServeMux as default | ||
ServeMux *http.ServeMux | ||
// Uses "/" as default | ||
HTTPBasePath string | ||
} | ||
|
||
func (o *Options) rootPath() string { | ||
if o.HTTPBasePath == "" { | ||
return "/" | ||
} | ||
return path.Join("/", o.HTTPBasePath) | ||
} | ||
|
||
func (o *Options) httpPort() int { | ||
if o.HTTPPort == 0 { | ||
return 5656 | ||
} | ||
return o.HTTPPort | ||
} | ||
|
||
func (o *Options) serveMux() *http.ServeMux { | ||
if o.ServeMux == nil { | ||
return http.DefaultServeMux | ||
} | ||
return o.ServeMux | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters