-
Notifications
You must be signed in to change notification settings - Fork 0
/
organizer_normal.go
133 lines (116 loc) · 2.98 KB
/
organizer_normal.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package main
import (
"strings"
"github.com/charmbracelet/glamour"
"github.com/slzatz/vimango/vim"
)
var n_lookup = map[string]func(){
//"dd": noop,
"dd": del,
"m": mark,
":": exCmd,
string(ctrlKey('l')): switchToEditorMode,
string([]byte{0x17, 0x17}): switchToEditorMode,
string(0x4): del, //ctrl-d
//string(0x2): starEntry, //ctrl-b -probably want this go backwards (unimplemented) and use ctrl-e for this
string(0x1): starEntry, //ctrl-b -probably want this go backwards (unimplemented) and use ctrl-e for this
string(0x18): archive, //ctrl-x
string(ctrlKey('i')): entryInfo, //{{0x9}}
string(ctrlKey('j')): controlJ,
string(ctrlKey('k')): controlK,
string(ctrlKey('z')): controlZ,
string(ctrlKey('n')): drawPreviewWithImages,
" m": drawPreviewWithImages,
}
func exCmd() {
sess.showOrgMessage(":")
org.command_line = ""
org.last_mode = org.mode //at the least picks up NORMAL and NO_ROWS
org.mode = COMMAND_LINE
}
func noop() {
return
}
func _asterisk() {
org.getWordUnderCursor()
org.findNextWord()
}
func mark() {
if org.view != TASK {
sess.showOrgMessage("You can only mark tasks")
return
}
if _, found := org.marked_entries[org.rows[org.fr].id]; found {
delete(org.marked_entries, org.rows[org.fr].id)
} else {
org.marked_entries[org.rows[org.fr].id] = struct{}{}
}
sess.showOrgMessage("Toggle mark for item %d", org.rows[org.fr].id)
}
func _n() {
org.findNextWord()
}
func del() {
toggleDeleted()
}
func starEntry() {
toggleStar()
}
func archive() {
toggleArchived()
}
func entryInfo() {
e := getEntryInfo(getId())
sess.displayEntryInfo(&e)
sess.drawPreviewBox()
}
func switchToEditorMode() {
if len(windows) == 0 {
sess.showOrgMessage("There are no active editors")
return
}
sess.eraseRightScreen()
sess.drawRightScreen()
sess.editorMode = true
vim.BufferSetCurrent(p.vbuf)
}
func controlJ() {
//if len(org.note) > org.altRowoff+org.textLines {
org.altRowoff++
org.drawPreview()
//}
}
func controlK() {
if org.altRowoff > 0 {
org.altRowoff--
org.drawPreview()
}
}
func controlZ() {
id := org.rows[org.fr].id
note := readNoteIntoString(id)
note = generateWWString(note, org.totaleditorcols)
r, _ := glamour.NewTermRenderer(
glamour.WithStylePath("darkslz.json"),
glamour.WithWordWrap(0),
//glamour.WithLinkNumbers(true), //12312023 -- trying to use standard glamour
)
note, _ = r.Render(note)
// glamour seems to add a '\n' at the start
note = strings.TrimSpace(note)
note = strings.ReplaceAll(note, "^^^", "\n") ///////////////04052022
org.note = strings.Split(note, "\n")
sess.eraseRightScreen()
if !sess.imagePreview {
org.drawPreviewWithoutImages()
} else {
org.drawPreviewWithImages()
}
org.mode = LINKS
sess.showOrgMessage("\x1b[1mType a number to choose a link\x1b[0m")
}
func drawPreviewWithImages() {
sess.eraseRightScreen()
org.drawPreviewWithImages()
sess.imagePreview = true
}