@ -33,8 +33,8 @@ NO WARRANTIES OF ANY KIND WHATSOEVER. SEE THE LICENSE FILE FOR DETAILS.
g Group stocks by advancing / declining issues .
g Group stocks by advancing / declining issues .
o Change column sort order .
o Change column sort order .
p Pause market data and stock updates .
p Pause market data and stock updates .
PgDn Scroll Down , down arrow key also works .
Scroll Scroll up / down .
PgUp Scroll up , up arrow key also works .
PgUp / PgDn ; Up / Down arrow ; j / k ; J / K also all scroll up / down
q Quit mop .
q Quit mop .
esc Ditto .
esc Ditto .
@ -48,13 +48,18 @@ func mainLoop(screen *mop.Screen, profile *mop.Profile) {
var lineEditor * mop . LineEditor
var lineEditor * mop . LineEditor
var columnEditor * mop . ColumnEditor
var columnEditor * mop . ColumnEditor
keyboardQueue := make ( chan termbox . Event )
termbox . SetInputMode ( termbox . InputMouse )
// use buffered channel for keyboard event queue
keyboardQueue := make ( chan termbox . Event , 16 )
timestampQueue := time . NewTicker ( 1 * time . Second )
timestampQueue := time . NewTicker ( 1 * time . Second )
quotesQueue := time . NewTicker ( 5 * time . Second )
quotesQueue := time . NewTicker ( 5 * time . Second )
marketQueue := time . NewTicker ( 12 * time . Second )
marketQueue := time . NewTicker ( 12 * time . Second )
showingHelp := false
showingHelp := false
paused := false
paused := false
pgUpDownLines := 10
upDownJump := profile . UpDownJump
redrawQuotesFlag := false
go func ( ) {
go func ( ) {
for {
for {
@ -96,13 +101,19 @@ loop:
showingHelp = true
showingHelp = true
screen . Clear ( ) . Draw ( help )
screen . Clear ( ) . Draw ( help )
} else if event . Key == termbox . KeyPgdn ||
} else if event . Key == termbox . KeyPgdn ||
event . Key == termbox . KeyArrowDown {
event . Ch == 'J' {
screen . IncreaseOffset ( pgUpDownLines , len ( profile . Tickers ) )
screen . IncreaseOffset ( upDownJump , len ( profile . Tickers ) )
screen . Clear ( ) . Draw ( market , quotes )
redrawQuotesFlag = true
} else if event . Key == termbox . KeyPgup ||
} else if event . Key == termbox . KeyPgup ||
event . Key == termbox . KeyArrowUp {
event . Ch == 'K' {
screen . DecreaseOffset ( pgUpDownLines )
screen . DecreaseOffset ( upDownJump )
screen . Clear ( ) . Draw ( market , quotes )
redrawQuotesFlag = true
} else if event . Key == termbox . KeyArrowUp || event . Ch == 'k' {
screen . DecreaseOffset ( 1 )
redrawQuotesFlag = true
} else if event . Key == termbox . KeyArrowDown || event . Ch == 'j' {
screen . IncreaseOffset ( 1 , len ( profile . Tickers ) )
redrawQuotesFlag = true
}
}
} else if lineEditor != nil {
} else if lineEditor != nil {
if done := lineEditor . Handle ( event ) ; done {
if done := lineEditor . Handle ( event ) ; done {
@ -123,6 +134,17 @@ loop:
} else {
} else {
screen . Draw ( help )
screen . Draw ( help )
}
}
case termbox . EventMouse :
if lineEditor == nil && columnEditor == nil && ! showingHelp {
switch event . Key {
case termbox . MouseWheelUp :
screen . DecreaseOffset ( 1 )
redrawQuotesFlag = true
case termbox . MouseWheelDown :
screen . IncreaseOffset ( 1 , len ( profile . Tickers ) )
redrawQuotesFlag = true
}
}
}
}
case <- timestampQueue . C :
case <- timestampQueue . C :
@ -140,6 +162,10 @@ loop:
screen . Draw ( market )
screen . Draw ( market )
}
}
}
}
if redrawQuotesFlag && len ( keyboardQueue ) == 0 {
screen . Draw ( quotes )
}
}
}
}
}