diff options
| author | Kujtim Hoxha <[email protected]> | 2025-04-12 18:45:36 +0200 |
|---|---|---|
| committer | Kujtim Hoxha <[email protected]> | 2025-04-21 13:38:42 +0200 |
| commit | bd2ec29b65e430f83f430db5fdc424c7d631989d (patch) | |
| tree | 0d7ee1a29a7932d54ffa1f247303568d85a3cf11 /internal/assets | |
| parent | 0697dcc1d9c7330d8c9d8a2be0bb94b3d46c9345 (diff) | |
| download | opencode-bd2ec29b65e430f83f430db5fdc424c7d631989d.tar.gz opencode-bd2ec29b65e430f83f430db5fdc424c7d631989d.zip | |
add initial git support
Diffstat (limited to 'internal/assets')
| -rw-r--r-- | internal/assets/diff/themes/dark.json | 73 | ||||
| -rw-r--r-- | internal/assets/embed.go | 6 | ||||
| -rw-r--r-- | internal/assets/write.go | 60 |
3 files changed, 139 insertions, 0 deletions
diff --git a/internal/assets/diff/themes/dark.json b/internal/assets/diff/themes/dark.json new file mode 100644 index 000000000..05c18e08c --- /dev/null +++ b/internal/assets/diff/themes/dark.json @@ -0,0 +1,73 @@ +{ + "SYNTAX_HIGHLIGHTING_THEME": "dark-plus", + "DEFAULT_COLOR": { + "color": "#ffffff", + "backgroundColor": "#212121" + }, + "COMMIT_HEADER_COLOR": { + "color": "#cccccc" + }, + "COMMIT_HEADER_LABEL_COLOR": { + "color": "#00000022" + }, + "COMMIT_SHA_COLOR": { + "color": "#00eeaa" + }, + "COMMIT_AUTHOR_COLOR": { + "color": "#00aaee" + }, + "COMMIT_DATE_COLOR": { + "color": "#cccccc" + }, + "COMMIT_MESSAGE_COLOR": { + "color": "#cccccc" + }, + "COMMIT_TITLE_COLOR": { + "modifiers": [ + "bold" + ] + }, + "FILE_NAME_COLOR": { + "color": "#ffdd99" + }, + "BORDER_COLOR": { + "color": "#ffdd9966", + "modifiers": [ + "dim" + ] + }, + "HUNK_HEADER_COLOR": { + "modifiers": [ + "dim" + ] + }, + "DELETED_WORD_COLOR": { + "color": "#ffcccc", + "backgroundColor": "#ff000033" + }, + "INSERTED_WORD_COLOR": { + "color": "#ccffcc", + "backgroundColor": "#00ff0033" + }, + "DELETED_LINE_NO_COLOR": { + "color": "#00000022", + "backgroundColor": "#00000022" + }, + "INSERTED_LINE_NO_COLOR": { + "color": "#00000022", + "backgroundColor": "#00000022" + }, + "UNMODIFIED_LINE_NO_COLOR": { + "color": "#666666" + }, + "DELETED_LINE_COLOR": { + "color": "#cc6666", + "backgroundColor": "#3a3030" + }, + "INSERTED_LINE_COLOR": { + "color": "#66cc66", + "backgroundColor": "#303a30" + }, + "UNMODIFIED_LINE_COLOR": {}, + "MISSING_LINE_COLOR": {} +} diff --git a/internal/assets/embed.go b/internal/assets/embed.go new file mode 100644 index 000000000..9e1316d08 --- /dev/null +++ b/internal/assets/embed.go @@ -0,0 +1,6 @@ +package assets + +import "embed" + +//go:embed diff +var FS embed.FS diff --git a/internal/assets/write.go b/internal/assets/write.go new file mode 100644 index 000000000..602b589ce --- /dev/null +++ b/internal/assets/write.go @@ -0,0 +1,60 @@ +package assets + +import ( + "os" + "path/filepath" + + "github.com/kujtimiihoxha/termai/internal/config" +) + +func WriteAssets() error { + appCfg := config.Get() + appWd := config.WorkingDirectory() + scriptDir := filepath.Join( + appWd, + appCfg.Data.Directory, + "diff", + ) + scriptPath := filepath.Join(scriptDir, "index.mjs") + // Before, run the script in cmd/diff/main.go to build this file + if _, err := os.Stat(scriptPath); err != nil { + scriptData, err := FS.ReadFile("diff/index.mjs") + if err != nil { + return err + } + + err = os.MkdirAll(scriptDir, 0o755) + if err != nil { + return err + } + err = os.WriteFile(scriptPath, scriptData, 0o755) + if err != nil { + return err + } + } + + themeDir := filepath.Join( + appWd, + appCfg.Data.Directory, + "themes", + ) + + themePath := filepath.Join(themeDir, "dark.json") + + if _, err := os.Stat(themePath); err != nil { + themeData, err := FS.ReadFile("diff/themes/dark.json") + if err != nil { + return err + } + + err = os.MkdirAll(themeDir, 0o755) + if err != nil { + return err + } + err = os.WriteFile(themePath, themeData, 0o755) + if err != nil { + return err + } + } + return nil +} |
