-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added plugin support and documentation
- Loading branch information
Showing
9 changed files
with
111 additions
and
47 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
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,5 +1,9 @@ | ||
package main | ||
|
||
import ( | ||
// Default command plugins | ||
_ "github.com/driusan/de/actions/defaults" | ||
|
||
// Go syntax highlighting plugin | ||
_ "github.com/driusan/de/renderer/gorenderer" | ||
) |
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,9 @@ | ||
package renderer | ||
|
||
import ( | ||
"github.com/driusan/de/renderer" | ||
) | ||
|
||
func init() { | ||
renderer.RegisterRenderer(&GoSyntax{}) | ||
} |
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,32 @@ | ||
package renderer | ||
|
||
import ( | ||
"github.com/driusan/de/demodel" | ||
"image" | ||
) | ||
|
||
type Renderer interface { | ||
CanRender(demodel.CharBuffer) bool | ||
Render(demodel.CharBuffer) (image.Image, ImageMap, error) | ||
} | ||
|
||
var renderers []Renderer | ||
|
||
func init() { | ||
// Make sure renderers is initialized with at least 1 renderer | ||
// that can render anything. | ||
renderers = []Renderer{NoSyntaxRenderer{}} | ||
|
||
} | ||
func RegisterRenderer(r Renderer) { | ||
renderers = append(renderers, r) | ||
} | ||
|
||
func GetRenderer(buff demodel.CharBuffer) Renderer { | ||
for i := len(renderers) - 1; i >= 0; i-- { | ||
if renderers[i].CanRender(buff) { | ||
return renderers[i] | ||
} | ||
} | ||
return renderers[0] | ||
} |