Skip to content

Commit

Permalink
updating color scheme to give better visual cues
Browse files Browse the repository at this point in the history
  • Loading branch information
7onetella committed Feb 27, 2020
1 parent 12c6156 commit 744dd32
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 48 deletions.
30 changes: 15 additions & 15 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (s *Search) HandleCommand(command string) {
}
tokens := strings.Split(str, ".")
if len(tokens) == 1 {
s.App.StatusBar.SetText("[red]please specify file extension[white]")
s.App.StatusBar.SetText("[red:white]please specify file extension[white]")
return
}

Expand Down Expand Up @@ -79,30 +79,30 @@ func (s *Search) HandleCommand(command string) {

err = OpenFileIfNoneExist(markdownFilePath, markdown)
if err != nil {
s.App.StatusBar.SetText("[red]generating content: " + err.Error() + "[white]")
s.App.StatusBar.SetText("[red:white]generating content: " + err.Error() + "[white]")
return
}
OpenVim(s.App, markdownFilePath)
s.App.StatusBar.SetText("[yellow]content generated[white]")
s.App.StatusBar.SetText("[white:darkcyan]content generated[white]")

// convert content to pdf if the extension is pdf
if extension == "pdf" {
// does pandoc exist in path?
if !DoesBinaryExists("pandoc") {
s.App.StatusBar.SetText("[red]please install pandoc to generate pdf[white]")
s.App.StatusBar.SetText("[red:white]please install pandoc to generate pdf[white]")
return
}
pdfFiePath := generatedDocPath + filename + ".pdf"
err := Exec([]string{"pandoc", "-s", markdownFilePath, "-o", pdfFiePath})
if err != nil {
s.App.StatusBar.SetText("[red]generating pdf: " + err.Error() + "[white]")
s.App.StatusBar.SetText("[red:white]generating pdf: " + err.Error() + "[white]")
return
}
s.App.StatusBar.SetText("[yellow]pdf generated[white]")
s.App.StatusBar.SetText("[white:darkcyan]pdf generated[white]")

err = Exec([]string{"open", pdfFiePath})
if err != nil {
s.App.StatusBar.SetText("[red]opening pdf: " + err.Error() + "[white]")
s.App.StatusBar.SetText("[red:white]opening pdf: " + err.Error() + "[white]")
return
}

Expand All @@ -113,7 +113,7 @@ func (s *Search) HandleCommand(command string) {

err = Exec([]string{"open", markdownFilePath})
if err != nil {
s.App.StatusBar.SetText("[red]opening content: " + err.Error() + "[white]")
s.App.StatusBar.SetText("[red:white]opening content: " + err.Error() + "[white]")
return
}

Expand All @@ -135,7 +135,7 @@ func (s *Search) HandleCommand(command string) {
s.SelectRow(0)
s.App.SetFocus(s.SearchBar)

s.App.StatusBar.SetText("[white]listing docs by type " + doctype)
s.App.StatusBar.SetText("[white:darkcyan]listing docs by type '" + doctype + "'")
case "tag":
tags := terms[1:]
for i := 0; i < s.ResultList.GetRowCount(); i++ {
Expand Down Expand Up @@ -206,7 +206,7 @@ func (s *Search) HandleCommand(command string) {
}
tokens := strings.Split(str, ".")
if len(tokens) == 1 {
s.App.StatusBar.SetText("[red]please specify file extension[white]")
s.App.StatusBar.SetText("[red:white]please specify file extension[white]")
return
}

Expand Down Expand Up @@ -244,14 +244,14 @@ func (s *Search) HandleCommand(command string) {

err = OpenFileIfNoneExist(backupFilePath, content)
if err != nil {
s.App.StatusBar.SetText("[red]exporting content: " + err.Error() + "[white]")
s.App.StatusBar.SetText("[red:white]exporting content: " + err.Error() + "[white]")
return
}
s.App.StatusBar.SetText("[yellow]exporting done[white]")
s.App.StatusBar.SetText("[white:darkcyan]exporting done[white]")

err = Exec([]string{"open", backupFilePath})
if err != nil {
s.App.StatusBar.SetText("[red]opening exported: " + err.Error() + "[white]")
s.App.StatusBar.SetText("[red:white]opening exported: " + err.Error() + "[white]")
return
}
case "import":
Expand All @@ -265,7 +265,7 @@ func (s *Search) HandleCommand(command string) {
generatedDocPath := home + config.Config().GetString("generated_doc_path")
tokens := strings.Split(str, ".")
if len(tokens) == 1 {
s.App.StatusBar.SetText("[red]please specify file extension[white]")
s.App.StatusBar.SetText("[red:white]please specify file extension[white]")
return
}

Expand Down Expand Up @@ -304,7 +304,7 @@ func (s *Search) HandleCommand(command string) {
doc.SetID(0)
s.App.DataHandler.Write(doc)
}
s.App.StatusBar.SetText("[yellow]importing done[white]")
s.App.StatusBar.SetText("[white:darkcyan]importing done[white]")
}
}

Expand Down
46 changes: 26 additions & 20 deletions help.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,45 @@ func (h *Help) SetApp(app *SimpleApp) {

func (h *Help) Page() (title string, content tview.Primitive) {
fmt.Fprintf(h.Content, `
[white:darkcyan][List of shortcut keys for the following scope[][white]
[yellow]List of shortcut keys for the following scope[white]
[black:darkcyan][Entire App[][white]
[darkcyan]Entire App[white]
Ctrl-C <- Exit
Ctrl-N <- New note
Ctrl-H <- Navigate to left menu item
Ctrl-L <- Navigate to right menu item
Ctrl-O <- Show debug view
Ctrl-D <- Go to debug view and back
Ctrl-E <- Clear debug view
Ctrl-c <- Exit
Ctrl-n <- New note
Ctrl-h <- Navigate to left menu item
Ctrl-l <- Navigate to right menu item
Ctrl-o <- Show debug view
Ctrl-d <- Go to debug view and back
Ctrl-e <- Clear debug view
Tab <- Switch between various views
[darkcyan]Search Bar[white]
[black:darkcyan][Search Bar[][white]
Ctrl-U <- Delete the entire line.
Ctrl-A <- Move to the beginning of the line.
Ctrl-E <- Move to the end of the line.
Ctrl-n <- New note
Ctrl-Space <- Delete the entire line.
Ctrl-u <- Delete the entire line.
Ctrl-a <- Move to the beginning of the line.
Ctrl-e <- Move to the end of the line.
Alt-left, Alt-b <- Move left by one word.
Alt-right, Alt-f <- Move right by one word.
Ctrl-K <- Delete from the cursor to the end of the line.
Ctrl-W <- Delete the last word before the cursor.
Ctrl-k <- Delete from the cursor to the end of the line.
Ctrl-w <- Delete the last word before the cursor.
[darkcyan]Search Result Rows[white]
[black:darkcyan][Search Result Rows[][white]
Tab <- Go back to search bar
j <- Move down
k <- Move up
i <- Load currently selected row in the edit view
e <- Edit vim editable fields, e.g. note
t <- Toggle toggle-able field
spacebar <- Select row
Ctrl-D <- Batch delete selected rows
Tab <- Go back to search bar
Ctrl-j <- Move row down
Ctrl-k <- Move row up
Ctrl-d <- Batch delete selected rows
Ctrl-a <- Select all / Deselect all
Ctrl-t <- Toggle all / Detoggle all
`)
return "Help", h.Content
}
15 changes: 10 additions & 5 deletions indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (ih *IndexHandler) Search(queryString string) ([]MiniDoc, string) {
log.Errorf("index search error: %v", err)
return nil, ""
}
stat := fmt.Sprintf("%d matches, showing %d through %d, took %s\n", sr.Total, sr.Request.From+1, sr.Request.From+len(sr.Hits), sr.Took)
stat := fmt.Sprintf(" %d matches, showing %d through %d, took %s\n", sr.Total, sr.Request.From+1, sr.Request.From+len(sr.Hits), sr.Took)

docs := make([]MiniDoc, sr.Hits.Len())
for ri, hit := range sr.Hits {
Expand All @@ -135,8 +135,8 @@ func (ih *IndexHandler) Search(queryString string) ([]MiniDoc, string) {
}

log.Debug("# of fragments: " + strconv.Itoa(len(hit.Fragments)))
for _, fragments := range hit.Fragments {
rv := ""
for fieldName, fragments := range hit.Fragments {
rv := "[" + fieldName + "[] "
for _, fragment := range fragments {
// [43m [0m
fragment = strings.ReplaceAll(fragment, "[43m", "[yellow]")
Expand Down Expand Up @@ -167,7 +167,7 @@ func IndexMapping() (*mapping.IndexMappingImpl, error) {

indexMapping := bleve.NewIndexMapping()
for _, doctype := range doctypes {
documentMapping := DocumentMapping(indexedFields[doctype])
documentMapping := DocumentMapping(indexedFields[doctype], excludedFields[doctype])
indexMapping.AddDocumentMapping(doctype, documentMapping)
}
indexMapping.TypeField = "type"
Expand All @@ -176,7 +176,7 @@ func IndexMapping() (*mapping.IndexMappingImpl, error) {
return indexMapping, nil
}

func DocumentMapping(indexedFields []string) *mapping.DocumentMapping {
func DocumentMapping(indexedFields []string, excludedFields []string) *mapping.DocumentMapping {
englishTextFieldMapping := bleve.NewTextFieldMapping()
englishTextFieldMapping.Analyzer = en.AnalyzerName

Expand All @@ -185,5 +185,10 @@ func DocumentMapping(indexedFields []string) *mapping.DocumentMapping {
documentMapping.AddFieldMappingsAt(f, englishTextFieldMapping)
}

disabledFieldMapping := bleve.NewDocumentDisabledMapping()
for _, f := range excludedFields {
documentMapping.AddSubDocumentMapping(f, disabledFieldMapping)
}

return documentMapping
}
2 changes: 1 addition & 1 deletion model_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (m *BaseDoc) GetMarkdown() string {
}

func (M *BaseDoc) GetAvailableActions() string {
return "😊"
return "*"
}

func (m *BaseDoc) GetDisplayFields() []string {
Expand Down
14 changes: 10 additions & 4 deletions model_custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ import (
"strings"
)

var doctypes = []string{"url", "note", "todo"}
var doctypes = []string{"url", "note", "todo", "shortcut"}

var indexedFields = map[string][]string{
"url": {"title", "description", "tags"},
"note": {"title", "note", "tags"},
"todo": {"task", "done", "tags"},
}

var excludedFields = map[string][]string{
"url": {"url"},
"note": {},
"todo": {},
}

// --------------------------------------------------------------------------------
// URL Doc
// --------------------------------------------------------------------------------
Expand Down Expand Up @@ -45,7 +51,7 @@ func (d *URLDoc) HandleEvent(event *tcell.EventKey) {
}

func (d *URLDoc) GetAvailableActions() string {
return "[yellow]o[white]pen url in browser | [yellow]t[white]oggle watch later"
return "o <- open url in browser | t <- toggle watch later"
}

func (d *URLDoc) GetMarkdown() string {
Expand Down Expand Up @@ -114,7 +120,7 @@ func (d *NoteDoc) GetDisplayFields() []string {
}

func (d *NoteDoc) GetAvailableActions() string {
return ""
return "*"
}

func (d *NoteDoc) GetEditFields() []string {
Expand Down Expand Up @@ -181,7 +187,7 @@ func (d *ToDoDoc) HandleEvent(event *tcell.EventKey) {
}

func (d *ToDoDoc) GetAvailableActions() string {
return "[yellow]t[white] <= toggle done"
return "t <- toggle done"
}

func (d *ToDoDoc) GetMarkdown() string {
Expand Down
5 changes: 3 additions & 2 deletions search.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (s *Search) Search(searchby string) bool {
s.debug("result is empty")
return false
}
s.App.StatusBar.SetText(stat)
s.App.StatusBar.SetText("[white:darkcyan]" + stat + "[white]")

s.UpdateResult(result)
return false
Expand Down Expand Up @@ -295,6 +295,7 @@ func (s *Search) GoToSearchBar(clear bool) {
s.SearchBar.Clear(true)
s.InitSearchBar()
}
s.App.StatusBar.SetText("[white:darkcyan] Ctrl-h <- navigate left | Ctrl-l <- navigate right[white]")
s.App.Draw()
s.App.SetFocus(s.SearchBar)
}
Expand Down Expand Up @@ -342,7 +343,7 @@ func (s *Search) Preview(direction int) {

// move keys like j and k controls the selection
// result list select only makes sense for shifting the focus over and selecting
s.App.StatusBar.SetText(fmt.Sprintf("%d | %s", s.CurrentRowIndex, doc.GetAvailableActions()))
s.App.StatusBar.SetText(fmt.Sprintf("[white:darkcyan] t <- toogle | spacebar <- select | %s | row %d", doc.GetAvailableActions(), s.CurrentRowIndex))

json := JsonMapFrom(doc)
jh := NewJsonMapWrapper(json)
Expand Down
2 changes: 1 addition & 1 deletion simpleapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func NewSimpleApp(opts ...SimpleAppOption) *SimpleApp {
false,
}

status.SetText("Ctrl-L for help")
status.SetText("[white:darkcyan] Ctrl-h <- navigate left | Ctrl-l <- navigate right[white]")
app.DebugView = NewDebugView(app)

app.Rows = tview.NewFlex().SetDirection(tview.FlexRow).
Expand Down

0 comments on commit 744dd32

Please sign in to comment.