Skip to content

Commit

Permalink
Color scheme for all items in application (#203)
Browse files Browse the repository at this point in the history
* Color scheme for all items in application

* Code cleanup
  • Loading branch information
lamskoy authored Sep 4, 2024
1 parent cc353a5 commit 85e8528
Show file tree
Hide file tree
Showing 24 changed files with 871 additions and 466 deletions.
52 changes: 52 additions & 0 deletions colors/blue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
default:
text: white, navy
editor:
comment: bold yellow
icomment: bold white
origin: bold lcyan
tearline: bold lcyan
tagline: bold lcyan
kludge: bold gray
dialog:
border: bold white
item: white
selection: bold white, dcyan
title: bold red
messageHeader:
title: bold white, dcyan
border: bold white
header: bold white
item: white
highlight: bold white
selection: default, dcyan
window: default, default
messageList:
border: silver
header: bold green
title: bold white, dcyan
prompt: white
item: silver
highlight: bold lcyan
selection: bold white, dcyan
areaList:
border: silver
header: bold green
title: bold white, dcyan
prompt: white
item: silver
highlight: bold lcyan
selection: bold white, dcyan
areaListModal:
border: silver
header: bold green
title: bold white, dcyan
prompt: white
item: silver
highlight: bold lcyan
selection: bold white, dcyan
statusbar:
text: bold white, navy
help:
border: bold white
title: bold yellow, green
text: default
56 changes: 56 additions & 0 deletions colors/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#
# Default Color Scheme
# Use as reference when building your own one
#
default:
text: silver, black
editor:
comment: bold yellow
icomment: bold white
origin: bold white
tearline: bold white
tagline: bold white
kludge: bold gray
dialog:
border: bold red
item: bold silver
selection: bold silver, navy
title: bold yellow
messageHeader:
title: bold yellow
border: bold blue
header: bold silver
item: silver
highlight: bold silver
selection: silver, navy
window: default, default
messageList:
border: red
header: bold yellow
title: bold yellow
prompt: silver
item: silver
highlight: bold default
selection: bold white, navy
areaList:
border: blue
header: bold yellow
title: bold yellow
prompt: silver
item: silver
highlight: bold silver
selection: white, navy
areaListModal:
border: red
header: bold yellow
title: bold yellow
prompt: silver
item: silver
highlight: bold silver
selection: white, navy
statusbar:
text: bold white, navy
help:
border: bold blue
title: bold yellow
text: default
12 changes: 4 additions & 8 deletions gossiped.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ areafile:
log: ./app.log
template: gossiped.tpl
origin: Just Origin
# Uncomment to enable blue colorscheme
#colorscheme: ./colors/blue.yml
tearline: ''
chrs:
default: CP866 2 # <charset> <lvl> http://ftsc.org/docs/fts-5003.001
Expand All @@ -17,13 +19,7 @@ areas:
basetype: msg # msg, squish, jam
- name: utf-8
chrs: UTF-8 4
colors:
editor:
comment: bold yellow
icomment: bold white
origin: bold green
tearline: bold green
tagline: bold green
kludge: bold gray
sorting:
areas: unread # unread, default
statusbar:
clock: true
8 changes: 5 additions & 3 deletions gossiped.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"github.com/askovpen/gossiped/pkg/areasconfig"
"github.com/askovpen/gossiped/pkg/config"
"github.com/askovpen/gossiped/pkg/ui"
Expand Down Expand Up @@ -52,24 +53,25 @@ func main() {
return
}
}

log.Println(fmt.Sprintf("reading configuration from %s", fn))
err := config.Read(fn)
if err != nil {
log.Print(err)
log.Println(err)
return
}
f, _ := os.OpenFile(config.Config.Log, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
defer f.Close()
log.SetOutput(f)
log.SetFlags(log.LstdFlags | log.Lmicroseconds)
log.Print("reading areas")
err = areasconfig.Read()
if err != nil {
log.Print(err)
return
}
// ui.App, err = gocui.NewGui(gocui.OutputNormal)
log.Print("starting ui")
app := ui.NewApp()
log.Print("start")
if err = app.Run(); err != nil {
log.Print("started ui")
log.Print(err)
Expand Down
25 changes: 25 additions & 0 deletions pkg/config/city.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package config

import (
"gopkg.in/yaml.v3"
"io/ioutil"
)

func readCity() {
yamlFile, err := ioutil.ReadFile("city.yaml")
if err != nil {
return
}
err = yaml.Unmarshal(yamlFile, &city)
if err != nil {
return
}
}

// GetCity return city
func GetCity(sa string) string {
if val, ok := city[sa]; ok {
return val
}
return "unknown"
}
41 changes: 41 additions & 0 deletions pkg/config/colorparser.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package config

import (
"log"
"regexp"
"strings"
)

// ParseColorscheme parses the text definition for a colorscheme and returns the corresponding object
// Colorschemes are made up of color-link statements linking a color group to a list of colors
// For example, color-link keyword (blue,red) makes all keywords have a blue foreground and
// red background
// Todo: Implement to read Golded schemes in future
func ParseColorscheme(text string) ColorScheme {
parser := regexp.MustCompile(`color-link\s+(\S*)\s+"(.*)"`)

lines := strings.Split(text, "\n")

c := make(ColorScheme)

for _, line := range lines {
if strings.TrimSpace(line) == "" ||
strings.TrimSpace(line)[0] == '#' {
// Ignore this line
continue
}
matches := parser.FindSubmatch([]byte(line))
if len(matches) == 3 {
link := string(matches[1])
colors := string(matches[2])
style, _ := StringToStyle(colors)
c[link] = style
if link == "default" {
style = StyleDefault
}
} else {
log.Println("Color-link statement is not valid:", line)
}
}
return c
}
Loading

0 comments on commit 85e8528

Please sign in to comment.