Skip to content

Commit 7bb4e7d

Browse files
committed
Make it possible to define themes as TOML + add 256color support
1 parent d46ebf5 commit 7bb4e7d

File tree

6 files changed

+599
-103
lines changed

6 files changed

+599
-103
lines changed

v2/cmenu.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ func (e *Editor) CommandMenu(c *vt.Canvas, tty *vt.TTY, status *StatusBar, undo
376376
"Amber Mono (O_THEME=ambermono)",
377377
"Green Mono (O_THEME=greenmono)",
378378
"Blue Mono (O_THEME=bluemono)"}
379-
//if vt.Has256Colors() {
380-
//menuChoices = append(menuChoices, "Xoria 256 (O_THEME=xoria)")
381-
//}
379+
if vt.Has256Colors() {
380+
menuChoices = append(menuChoices, "Xoria 256 (O_THEME=xoria)")
381+
}
382382
menuChoices = append(menuChoices, "No colors (NO_COLOR=1)")
383383
useMenuIndex := 0
384384
for i, menuChoiceText := range menuChoices {
@@ -465,10 +465,10 @@ func (e *Editor) CommandMenu(c *vt.Canvas, tty *vt.TTY, status *StatusBar, undo
465465
envNoColor = false
466466
e.setBlueTheme()
467467
e.syntaxHighlight = false
468-
// case "xoria":
469-
//envNoColor = false
470-
//e.SetTheme(NewXoriaTheme())
471-
// e.syntaxHighlight = true
468+
case "xoria":
469+
envNoColor = false
470+
e.SetTheme(NewXoriaTheme())
471+
e.syntaxHighlight = true
472472
case "nocolor":
473473
envNoColor = true
474474
e.setNoColorTheme()

v2/neweditor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,9 @@ func NewEditor(tty *vt.TTY, c *vt.Canvas, fnord FilenameOrData, lineNumber LineN
457457
e.setBlueTheme()
458458
e.syntaxHighlight = false
459459
themeWasSet = true
460+
case "xoria":
461+
e.SetTheme(NewXoriaTheme(), assumeLightBackground)
462+
themeWasSet = true
460463
case "default":
461464
themeWasSet = true
462465
}

v2/themes.go

Lines changed: 4 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package main
22

3-
import "github.com/xyproto/vt"
3+
import (
4+
_ "embed"
45

5-
// TODO: Restructure how themes are stored, so that it's easier to list all themes that
6-
// works with a dark background or all that works with a light background, ref. initialLightBackground
6+
"github.com/xyproto/vt"
7+
)
78

89
var initialLightBackground *bool
910

@@ -382,99 +383,6 @@ func NewPinetreeTheme() Theme {
382383
}
383384
}
384385

385-
// NewZuluTheme creates a unique semantic Theme with nature-inspired colors
386-
func NewZuluTheme() Theme {
387-
return Theme{
388-
Name: "Zulu",
389-
Light: false,
390-
Foreground: vt.Default,
391-
Background: vt.BackgroundDefault,
392-
StatusForeground: vt.White,
393-
StatusBackground: vt.BackgroundBlack,
394-
TopRightForeground: vt.White,
395-
TopRightBackground: vt.BackgroundDefault,
396-
StatusErrorForeground: vt.LightRed,
397-
StatusErrorBackground: vt.BackgroundDefault,
398-
SearchHighlight: vt.Yellow,
399-
MultiLineComment: vt.Gray,
400-
MultiLineString: vt.LightYellow,
401-
HighlightForeground: vt.LightCyan,
402-
HighlightBackground: vt.BackgroundDefault,
403-
Git: vt.LightGreen,
404-
String: "lightyellow",
405-
Keyword: "lightgreen",
406-
Comment: "gray",
407-
Type: "lightcyan",
408-
Literal: "lightmagenta",
409-
Punctuation: "lightgray",
410-
Plaintext: "lightgray",
411-
Tag: "lightcyan",
412-
TextTag: "lightcyan",
413-
TextAttrName: "lightcyan",
414-
TextAttrValue: "lightyellow",
415-
Decimal: "lightmagenta",
416-
AndOr: "lightgreen",
417-
AngleBracket: "lightgreen",
418-
Dollar: "lightmagenta",
419-
Star: "lightyellow",
420-
Static: "lightgreen",
421-
Self: "white",
422-
Class: "lightcyan",
423-
Private: "darkyellow",
424-
Protected: "yellow",
425-
Public: "lightgreen",
426-
Whitespace: "",
427-
AssemblyEnd: "lightcyan",
428-
Mut: "lightgreen",
429-
RainbowParenColors: []vt.AttributeColor{vt.LightYellow, vt.LightGreen, vt.LightCyan, vt.LightMagenta, vt.White},
430-
MarkdownTextColor: vt.LightGray,
431-
HeaderBulletColor: vt.Gray,
432-
HeaderTextColor: vt.LightCyan,
433-
ListBulletColor: vt.LightMagenta,
434-
ListTextColor: vt.LightGray,
435-
ListCodeColor: vt.LightYellow,
436-
CodeColor: vt.LightYellow,
437-
CodeBlockColor: vt.BackgroundDefault,
438-
ImageColor: vt.LightMagenta,
439-
LinkColor: vt.LightCyan,
440-
QuoteColor: vt.Yellow,
441-
QuoteTextColor: vt.LightGray,
442-
HTMLColor: vt.LightCyan,
443-
CommentColor: vt.Gray,
444-
BoldColor: vt.White,
445-
ItalicsColor: vt.LightCyan,
446-
StrikeColor: vt.Gray,
447-
TableColor: vt.LightCyan,
448-
CheckboxColor: vt.LightGray,
449-
XColor: vt.LightMagenta,
450-
TableBackground: vt.BackgroundDefault,
451-
UnmatchedParenColor: vt.LightRed,
452-
MenuTitleColor: vt.LightCyan,
453-
MenuArrowColor: vt.LightGreen,
454-
MenuTextColor: vt.Default,
455-
MenuHighlightColor: vt.LightYellow,
456-
MenuSelectedColor: vt.White,
457-
ManSectionColor: vt.LightMagenta,
458-
ManSynopsisColor: vt.LightCyan,
459-
BoxTextColor: vt.White,
460-
BoxBackground: vt.BackgroundBlack,
461-
ProgressIndicatorBackground: vt.BackgroundGray,
462-
BoxHighlight: vt.LightYellow,
463-
DebugRunningBackground: vt.BackgroundGreen,
464-
DebugStoppedBackground: vt.BackgroundMagenta,
465-
DebugRegistersBackground: vt.BackgroundCyan,
466-
DebugOutputBackground: vt.BackgroundYellow,
467-
DebugLineIndicator: vt.LightCyan,
468-
DebugInstructionsForeground: vt.LightYellow,
469-
DebugInstructionsBackground: vt.BackgroundBlack,
470-
BoxUpperEdge: vt.LightGray,
471-
JumpToLetterColor: vt.LightMagenta,
472-
NanoHelpForeground: vt.Black,
473-
NanoHelpBackground: vt.BackgroundGray,
474-
MultiCursorBackground: vt.BackgroundYellow,
475-
}
476-
}
477-
478386
// NewLitmusTheme creates a new default Theme struct
479387
func NewLitmusTheme() Theme {
480388
return Theme{

0 commit comments

Comments
 (0)