Skip to content

Commit bc53dfe

Browse files
committed
feat: highlight prefix in compact mode
Turns out spacing=0 doesn't work even in full screen mode. Switching back to spacing=1 for compact mode regardless of whether context pane is visible or not.
1 parent ef9543c commit bc53dfe

14 files changed

+112
-80
lines changed

cmd/assets/guide/actions-adding-tasks.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ You can add a task below the cursor by pressing `a`. Once you get acquainted
55
with omm, you'll want to have more control on the position of the newly added
66
task. omm offers the following keymaps for that.
77

8+
```text
89
o/a add task below cursor
910
O add task above cursor
1011
I add task at the top
1112
A add task at the end
13+
```
1214

1315
Go ahead, create a task, then move to the next guided item.

cmd/assets/guide/actions-filtering-tasks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ prompt, which will match your query with task prefixes.
44
Try it out now. You get out of the filtered state by pressing `q/esc/<ctrl+c>`.
55

66
Note: You cannot add tasks or move them around in a filtered state. But, you can
7-
move a task to the top of the list (by pressing ``). Doing this will also get
8-
you out of the filtered state.
7+
move a task to the top or the bottom of the list (by pressing ``/`E`). Doing
8+
this will also get you out of the filtered state.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Context can (optionally) be written in markdown, which will get rendered
2+
accordingly.
3+
4+
For example:
5+
6+
# This is an H1 heading
7+
8+
## This is an H2 heading
9+
10+
```go
11+
// a comment
12+
fmt.Print("This is a code block")
13+
```

cmd/assets/guide/config-flags-env-vars-and-config-file.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ variable counterpart, as well as a TOML config counterpart.
44
For example:
55

66
```text
7-
--show-context -> OMM_SHOW_CONTEXT -> show_context
8-
--editor -> OMM_EDITOR -> editor
7+
--show-context -> OMM_SHOW_CONTEXT -> show_context
8+
--editor -> OMM_EDITOR -> editor
99
```

cmd/assets/guide/domain-task-priorities.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ And, as we all know, priorities often change. You're probably juggling multiple
55
tasks on any given day. As such, omm allows you to move tasks around in the
66
priority order. It has the following keymaps to achieve this:
77

8+
```text
89
⏎ move task to the top
910
E move task to the end
1011
J move task one position down
1112
K move task one position up
13+
```
1214

1315
It's recommended that you move the task that you're currently focussing on to
1416
the top.

cmd/assets/guide/visuals-toggling-context-pane.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The context pane can be toggled on/off by pressing `C`.
1+
The context pane can be toggled on/off by pressing `C` (capital c).
22

33
You can choose to display it or not based on your preference. For convenience,
44
the lists will always highlight tasks that have a context associated with them

cmd/guide.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ var (
3434
{summary: "cli: adding a task via the CLI"},
3535
{summary: "cli: importing several tasks via the CLI"},
3636
{summary: "actions: adding context"},
37+
{summary: "actions: markdown in context"},
3738
{summary: "actions: filtering tasks"},
3839
{summary: "actions: quick filtering via a list"},
3940
{summary: "domain: task bookmarks"},

cmd/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ Error: %s`, author, repoIssuesUrl, guideErr)
317317
}
318318
config := ui.Config{
319319
DBPath: dbPathFull,
320-
ListDensity: ui.Spacious,
320+
ListDensity: ui.Compact,
321321
TaskListColor: taskListColor,
322322
ArchivedTaskListColor: archivedTaskListColor,
323323
TaskListTitle: taskListTitle,
@@ -374,7 +374,7 @@ Error: %s`, author, repoIssuesUrl, err)
374374
rootCmd.Flags().StringVar(&taskListColor, "tl-color", ui.TaskListColor, "hex color used for the task list")
375375
rootCmd.Flags().StringVar(&archivedTaskListColor, "atl-color", ui.ArchivedTLColor, "hex color used for the archived tasks list")
376376
rootCmd.Flags().StringVar(&taskListTitle, "title", ui.TaskListDefaultTitle, fmt.Sprintf("title of the task list, will trim till %d chars", taskListTitleMaxLen))
377-
rootCmd.Flags().StringVar(&listDensityFlagInp, "list-density", ui.SpaciousDensityVal, fmt.Sprintf("type of density for the list; possible values: [%s, %s]", ui.CompactDensityVal, ui.SpaciousDensityVal))
377+
rootCmd.Flags().StringVar(&listDensityFlagInp, "list-density", ui.CompactDensityVal, fmt.Sprintf("type of density for the list; possible values: [%s, %s]", ui.CompactDensityVal, ui.SpaciousDensityVal))
378378
rootCmd.Flags().StringVar(&editorFlagInp, "editor", "vi", "editor command to run when adding/editing context to a task")
379379
rootCmd.Flags().BoolVar(&showContextFlagInp, "show-context", false, "whether to start omm with a visible task context pane or not; this can later be toggled on/off in the TUI")
380380

internal/types/types.go

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -99,36 +99,19 @@ func CheckIfTaskSummaryValid(summary string) (bool, error) {
9999
return true, nil
100100
}
101101

102-
func (t *Task) SetTitle(compact bool) {
102+
func (t Task) GetPrefixAndSummaryContent() (string, string, bool) {
103103
summEls := strings.Split(t.Summary, PrefixDelimiter)
104104

105-
if compact {
106-
var summ string
107-
if len(summEls) > 1 {
108-
prefix := utils.RightPadTrim(summEls[0], compactPrefixPadding, true)
109-
summ = prefix + strings.Join(summEls[1:], PrefixDelimiter)
110-
} else {
111-
summ = t.Summary
112-
}
113-
114-
var hasContext string
115-
if t.Context != nil {
116-
hasContext = "(c)"
117-
}
118-
t.ItemTitle = fmt.Sprintf("%s%s", utils.RightPadTrim(summ, taskSummaryWidth, true), hasContext)
119-
return
120-
}
121-
122105
if len(summEls) == 1 {
123-
t.ItemTitle = t.Summary
124-
return
106+
return "", t.Summary, false
125107
}
126108

127-
t.ItemTitle = utils.Trim(strings.TrimSpace(strings.Join(summEls[1:], PrefixDelimiter)), taskSummaryWidth)
109+
return strings.TrimSpace(summEls[0]), strings.TrimSpace(strings.Join(summEls[1:], PrefixDelimiter)), true
128110
}
129111

130112
func (t Task) Title() string {
131-
return t.ItemTitle
113+
_, sc, _ := t.GetPrefixAndSummaryContent()
114+
return sc
132115
}
133116

134117
func (t Task) Description() string {
@@ -138,7 +121,7 @@ func (t Task) Description() string {
138121

139122
summEls := strings.Split(t.Summary, PrefixDelimiter)
140123
if len(summEls) > 1 {
141-
prefix = getDynamicStyle(summEls[0]).Render(utils.RightPadTrim(summEls[0], spaciousPrefixPadding, true))
124+
prefix = GetDynamicStyle(summEls[0]).Render(utils.RightPadTrim(summEls[0], spaciousPrefixPadding, true))
142125
} else {
143126
prefix = strings.Repeat(" ", spaciousPrefixPadding)
144127
}
@@ -167,7 +150,7 @@ func (t Task) FilterValue() string {
167150
return ""
168151
}
169152

170-
func getDynamicStyle(str string) lipgloss.Style {
153+
func GetDynamicStyle(str string) lipgloss.Style {
171154
h := fnv.New32()
172155
h.Write([]byte(str))
173156
hash := h.Sum32()

internal/ui/assets/gruvbox.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"underline": true
7777
},
7878
"link_text": {
79-
"color": "#458588",
79+
"color": "#fabd2f",
8080
"bold": true
8181
},
8282
"image": {
@@ -95,10 +95,9 @@
9595
},
9696
"code_block": {
9797
"color": "244",
98-
"margin": 2,
9998
"chroma": {
10099
"text": {
101-
"color": "#bdae93"
100+
"color": "#fbf1c7"
102101
},
103102
"error": {
104103
"color": "#282828",

0 commit comments

Comments
 (0)