X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=state%2Fstate.go;h=682fb1cd20cccce6b5e1c5d33678d7e13230d09e;hb=193ae41f5473832680f1969a1e0bc19bc27909b8;hp=e0056baab29c0e2679c6bf6711767ae4c0b256dd;hpb=52d3c00ce729f908f342e10f48818b112dec0130;p=pstop.git diff --git a/state/state.go b/state/state.go index e0056ba..682fb1c 100644 --- a/state/state.go +++ b/state/state.go @@ -152,6 +152,8 @@ func (state State) Help() bool { return state.help } +// states go: showLatency -> showOps -> showIO -> showLocks -> showUsers + // display the output according to the mode we are in func (state *State) Display() { if state.help { @@ -171,6 +173,29 @@ func (state *State) Display() { } } +// fix_latency_setting() ensures the SetWantsLatency() value is +// correct. This needs to be done more cleanly. +func (state *State) fix_latency_setting() { + if state.show == showLatency { + state.tiwsbt.SetWantsLatency(true) + } + if state.show == showOps { + state.tiwsbt.SetWantsLatency(false) + } +} + +// change to the previous display mode +func (state *State) DisplayPrevious() { + if state.show == showLatency { + state.show = showUsers + } else { + state.show-- + } + state.fix_latency_setting() + state.screen.Clear() + state.screen.Flush() +} + // change to the next display mode func (state *State) DisplayNext() { if state.show == showUsers { @@ -178,13 +203,7 @@ func (state *State) DisplayNext() { } else { state.show++ } - // this needs to be done more cleanly - if state.show == showLatency { - state.tiwsbt.SetWantsLatency(true) - } - if state.show == showOps { - state.tiwsbt.SetWantsLatency(false) - } + state.fix_latency_setting() state.screen.Clear() state.screen.Flush() }