X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=state%2Fstate.go;h=124b88425ccfb012db032c08a14d751323986787;hb=65c9ae05af2882d60512d5beefa99dae232d9f16;hp=e0056baab29c0e2679c6bf6711767ae4c0b256dd;hpb=52d3c00ce729f908f342e10f48818b112dec0130;p=pstop.git diff --git a/state/state.go b/state/state.go index e0056ba..124b884 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() } @@ -242,7 +261,7 @@ func (state State) displayDescription() { } func (state *State) displayOpsOrLatency() { - state.screen.PrintAt(0, 2, state.tiwsbt.Headings()) + state.screen.BoldPrintAt(0, 2, state.tiwsbt.Headings()) max_rows := state.screen.Height() - 3 row_content := state.tiwsbt.RowContent(max_rows) @@ -261,12 +280,12 @@ func (state *State) displayOpsOrLatency() { } // print out the totals at the bottom - state.screen.PrintAt(0, state.screen.Height()-1, state.tiwsbt.TotalRowContent()) + state.screen.BoldPrintAt(0, state.screen.Height()-1, state.tiwsbt.TotalRowContent()) } // show actual I/O latency values func (state State) displayIO() { - state.screen.PrintAt(0, 2, state.fsbi.Headings()) + state.screen.BoldPrintAt(0, 2, state.fsbi.Headings()) // print out the data max_rows := state.screen.Height() - 3 @@ -286,11 +305,11 @@ func (state State) displayIO() { } // print out the totals at the bottom - state.screen.PrintAt(0, state.screen.Height()-1, state.fsbi.TotalRowContent()) + state.screen.BoldPrintAt(0, state.screen.Height()-1, state.fsbi.TotalRowContent()) } func (state *State) displayLocks() { - state.screen.PrintAt(0, 2, state.tlwsbt.Headings()) + state.screen.BoldPrintAt(0, 2, state.tlwsbt.Headings()) // print out the data max_rows := state.screen.Height() - 3 @@ -310,11 +329,11 @@ func (state *State) displayLocks() { } // print out the totals at the bottom - state.screen.PrintAt(0, state.screen.Height()-1, state.tlwsbt.TotalRowContent()) + state.screen.BoldPrintAt(0, state.screen.Height()-1, state.tlwsbt.TotalRowContent()) } func (state *State) displayUsers() { - state.screen.PrintAt(0, 2, state.users.Headings()) + state.screen.BoldPrintAt(0, 2, state.users.Headings()) // print out the data max_rows := state.screen.Height() - 3 @@ -334,7 +353,7 @@ func (state *State) displayUsers() { } // print out the totals at the bottom - state.screen.PrintAt(0, state.screen.Height()-1, state.users.TotalRowContent()) + state.screen.BoldPrintAt(0, state.screen.Height()-1, state.users.TotalRowContent()) } // do we want to show all p_s data?