parent
c1fc94a124
commit
b46f7c491e
@ -43,10 +43,12 @@ Usage
|
|||||||
-----
|
-----
|
||||||
|
|
||||||
| mode | key | action |
|
| mode | key | action |
|
||||||
|--------|-----------|--------------------------|
|
|--------|-----------|----------------------------|
|
||||||
| normal | `i` | insert mode |
|
| normal | `i` | insert mode |
|
||||||
| normal | `k` | move channel cursor up |
|
| normal | `k` | move channel cursor up |
|
||||||
| normal | `j` | move channel cursor down |
|
| normal | `j` | move channel cursor down |
|
||||||
|
| normal | `gg` | move channel cursor top |
|
||||||
|
| normal | `G` | move channel cursor bottom |
|
||||||
| normal | `pg-up` | scroll chat pane up |
|
| normal | `pg-up` | scroll chat pane up |
|
||||||
| normal | `ctrl-b` | scroll chat pane up |
|
| normal | `ctrl-b` | scroll chat pane up |
|
||||||
| normal | `ctrl-u` | scroll chat pane up |
|
| normal | `ctrl-u` | scroll chat pane up |
|
||||||
|
@ -12,9 +12,9 @@ import (
|
|||||||
// Channels is the definition of a Channels component
|
// Channels is the definition of a Channels component
|
||||||
type Channels struct {
|
type Channels struct {
|
||||||
List *termui.List
|
List *termui.List
|
||||||
SelectedChannel int
|
SelectedChannel int // index of which channel is selected from the List
|
||||||
Offset int
|
Offset int // from what offset are channels rendered
|
||||||
CursorPosition int
|
CursorPosition int // the y position of the 'cursor'
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateChannels is the constructor for the Channels component
|
// CreateChannels is the constructor for the Channels component
|
||||||
@ -142,6 +142,28 @@ func (c *Channels) MoveCursorDown() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MoveCursorTop will move the cursor to the top of the channels
|
||||||
|
func (c *Channels) MoveCursorTop() {
|
||||||
|
c.SetSelectedChannel(0)
|
||||||
|
c.CursorPosition = c.List.InnerBounds().Min.Y
|
||||||
|
c.Offset = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// MoveCursorBottom will move the cursor to the bottom of the channels
|
||||||
|
func (c *Channels) MoveCursorBottom() {
|
||||||
|
c.SetSelectedChannel(len(c.List.Items) - 1)
|
||||||
|
|
||||||
|
offset := len(c.List.Items) - (c.List.InnerBounds().Max.Y - 1)
|
||||||
|
|
||||||
|
if offset < 0 {
|
||||||
|
c.Offset = 0
|
||||||
|
c.CursorPosition = c.SelectedChannel + 1
|
||||||
|
} else {
|
||||||
|
c.Offset = offset
|
||||||
|
c.CursorPosition = c.List.InnerBounds().Max.Y - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ScrollUp enables us to scroll through the channel list when it overflows
|
// ScrollUp enables us to scroll through the channel list when it overflows
|
||||||
func (c *Channels) ScrollUp() {
|
func (c *Channels) ScrollUp() {
|
||||||
if c.CursorPosition == c.List.InnerBounds().Min.Y {
|
if c.CursorPosition == c.List.InnerBounds().Min.Y {
|
||||||
|
@ -43,6 +43,10 @@ func anyKeyHandler(ctx *context.AppContext) {
|
|||||||
actionMoveCursorDownChannels(ctx)
|
actionMoveCursorDownChannels(ctx)
|
||||||
case 'k':
|
case 'k':
|
||||||
actionMoveCursorUpChannels(ctx)
|
actionMoveCursorUpChannels(ctx)
|
||||||
|
case 'g':
|
||||||
|
actionMoveCursorTopChannels(ctx)
|
||||||
|
case 'G':
|
||||||
|
actionMoveCursorBottomChannels(ctx)
|
||||||
case 'i':
|
case 'i':
|
||||||
actionInsertMode(ctx)
|
actionInsertMode(ctx)
|
||||||
}
|
}
|
||||||
@ -208,6 +212,16 @@ func actionMoveCursorDownChannels(ctx *context.AppContext) {
|
|||||||
actionChangeChannel(ctx)
|
actionChangeChannel(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func actionMoveCursorTopChannels(ctx *context.AppContext) {
|
||||||
|
ctx.View.Channels.MoveCursorTop()
|
||||||
|
actionChangeChannel(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func actionMoveCursorBottomChannels(ctx *context.AppContext) {
|
||||||
|
ctx.View.Channels.MoveCursorBottom()
|
||||||
|
actionChangeChannel(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
func actionChangeChannel(ctx *context.AppContext) {
|
func actionChangeChannel(ctx *context.AppContext) {
|
||||||
// Clear messages from Chat pane
|
// Clear messages from Chat pane
|
||||||
ctx.View.Chat.ClearMessages()
|
ctx.View.Chat.ClearMessages()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user