7
7
)
8
8
9
9
// globally defined selected line starts at 1 to account for header width.
10
+ // sl is the line within the view, it does not represent the line in the currentSplit
10
11
var sl = 1
11
12
12
13
// loop ... main execution loop. Figure out wtf is happening here.
@@ -22,16 +23,17 @@ func loop(s tcell.Screen) {
22
23
close (quit )
23
24
return
24
25
case tcell .KeyDown :
25
- moveSelectedLine (1 , sl , 1 , 1 )
26
+ moveSelectedLine (1 , sl , len ( currentSplit ), 1 , 1 )
26
27
27
28
case tcell .KeyUp :
28
- moveSelectedLine (- 1 , sl , 1 , 1 )
29
+ moveSelectedLine (- 1 , sl , len ( currentSplit ), 1 , 1 )
29
30
30
31
case tcell .KeyLeft :
31
32
32
- s .Sync ()
33
33
case tcell .KeyRight :
34
- s .Sync ()
34
+ //determine index into selectedSlice that selectedline is pointed at.
35
+ //pass selectedline to windowstring to messageretrieve
36
+ //messageRetrieve()
35
37
}
36
38
case * tcell.EventResize :
37
39
s .Sync ()
56
58
// moveSelectedLine ... Return the currently selected line with deviation specified by amount value.
57
59
// Amount should only ever be 1 or -1. The logic in moveSelectedLine is not robust enough
58
60
// to safely handle other values.
59
- func moveSelectedLine (amount int , selectedline int , headerheight int , footerheight int ) {
61
+ func moveSelectedLine (amount int , selectedline int , lenlines int , headerheight int , footerheight int ) {
60
62
// if amount is a negative value and the currently selected line is the top (ie, headerwidth), keep it at the
61
63
// at the index that's the same thickness as the header.
62
64
if (amount < 0 ) && (selectedline == headerheight ) {
@@ -65,6 +67,8 @@ func moveSelectedLine(amount int, selectedline int, headerheight int, footerheig
65
67
// then return the max value.
66
68
} else if (amount > 0 ) && (selectedline == windowHeight - footerheight - 1 ) {
67
69
sl = windowHeight - footerheight - 1
70
+ } else if (amount > 0 ) && (selectedline == lenlines - 1 ) {
71
+ sl = lenlines - 1
68
72
} else {
69
73
sl = selectedline + amount
70
74
}
@@ -73,19 +77,19 @@ func moveSelectedLine(amount int, selectedline int, headerheight int, footerheig
73
77
74
78
// windowString ... takes a chunk of text delimited by newlines and returns a specified portion of it
75
79
// that fits within the current size of the terminal window. A number of lines to offset
76
- // into the original message must be provided by the selected integer.
77
- // windowheight will usually be an integer that starts at 1 whereas selected is likely
80
+ // into the original message must be provided by the offset integer.
81
+ // windowheight will usually be an integer that starts at 1 whereas offset is likely
78
82
// starting from 0. When passing variables to this function, it is recommended to increment
79
- // selected by 1.
83
+ // offset by 1.
80
84
// The function does not return a reduced portion of the input message if it has less lines
81
85
// than windowheight.
82
- /*func windowString(lines []string, selectedline int, headerheight int, footerheight int) []string {
83
- if windowHeight-headerheight-footerheight >= len(lines) {
86
+ func currentWindow (lines []string , offset int , headerheight int , footerheight int ) []string {
87
+ limit := windowHeight - headerheight - footerheight
88
+ if limit >= len (lines ) {
84
89
return lines
85
90
}
86
- if selected > windowheight {
87
- return strings.Join( lines[selected-windowheight:selected], "\n")
91
+ if offset > limit {
92
+ return lines [offset - limit : offset ]
88
93
}
89
- return strings.Join( lines[0:windowheight], "\n")
94
+ return lines [0 :limit ]
90
95
}
91
- */
0 commit comments