add on-demand window refresh

    Introduce support for on-demand window refresh (tab).
    Extended tab_window class now defines virtual window_refresh() function,
    which should be implemented in derived classes according to refresh
    logic.

    Add support for window refresh to tuninig tab. For example, this
    allows to update list with plugged-in/unplagged USB devices, etc., w/o
    the need of powertop restart.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
refactor w_display_cpu_pstates() and w_display_cpu_cstates()

    Currently, w_display_cpu_pstates() and w_display_cpu_cstates()
    are 90% similar functions with the only difference in abstract_cpu
    calls: pstate vs. cstate.

    This patch introduces helper functions:
    - has_state_level() -- call has_pstate_level() or has_cstate_level()
    - fill_state_name() -- call fill_pstate_name() or fill_cstate_name()
    - fill_state_line() -- call fill_pstate_line() or fill_pstate_line()

    actions are performed according to passed param: PSTATE or CSTATE.

    This allows to merge implementations of w_display_cpu_pstates() and
    w_display_cpu_cstates() into one function -- impl_w_display_cpu_states()
    (which performs helpers calls with appropriate PSTATE or CSTATE flag).

    w_display_cpu_pstates() and w_display_cpu_cstates() are still there,
    but the only thing they do is
    	impl_w_display_cpu_states(PSTATE) or impl_w_display_cpu_states(CSTATE)
    accordingly.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
avoid werase() call on every cursor move

     No need to call werase() each time cursor changes its position. In fact the only
     time we should call it - is when list of tunables changed.
     Introduce static bool flag to mark the need of werase() call.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
introduce get_user_input() function

    Introduce library routine get_user_input(char *buf, unsigned sz),
    which is used to obtain user input.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
give user ability to set refresh time

    Introduce ability to set powertop refresh timeout via `-s` switch.
    Currently, measurement timeout is allowed to be within [1,32] secs
    range.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
tuning: suppress compilation warning

    Suppress `warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wparentheses]'
    compilation warning.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
tuning: suppress compilation warning (2)

    Suppress `warning: comparison between signed and unsigned integer expressions [-Wsign-compare]'
    compilation warning.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
add tab_window class virtual destructor

    Add virtual .dtor to tab_window class.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
rewrite timer::is_deferred()

     Rewrite is_deferred().
     No need to check for !handler, since it's allocated member array.
     "total events" substrig search is redundant -- EOF should do the
     same. Also replace strchr() with "D," substring search.
     Patch also removes get_timerstats() -- looks useless.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
introduce timer::deferred member variable

     Timer creation makes powertop stuck with high CPU usage for a noticeable
     amount of time, due to /proc/timer_stats file parsing.

     Move member is_deferred() to static timer_is_deferred(const char*) function,
     which gets called during timer() construction.

     is_deferred() function returns member bool deferred variable instead,
     preventing CPU consuming file lookup.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>