mirror of
https://github.com/nicolargo/glances.git
synced 2024-09-11 12:47:14 +03:00
Add line separators in the terminal output #1996
This commit is contained in:
parent
a648b488d0
commit
13ba034e92
@ -123,10 +123,16 @@ Examples of use:
|
||||
help='display modules (plugins & exports) list and exit',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--disable-plugin', '--disable-plugins', dest='disable_plugin', help='disable plugin (comma separed list)'
|
||||
'--disable-plugin',
|
||||
'--disable-plugins',
|
||||
dest='disable_plugin',
|
||||
help='disable plugin (comma separed list)'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--enable-plugin', '--enable-plugins', dest='enable_plugin', help='enable plugin (comma separed list)'
|
||||
'--enable-plugin',
|
||||
'--enable-plugins',
|
||||
dest='enable_plugin',
|
||||
help='enable plugin (comma separed list)'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--disable-process',
|
||||
@ -219,7 +225,11 @@ Examples of use:
|
||||
help='disable background colors in the terminal',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--enable-irq', action='store_true', default=False, dest='enable_irq', help='enable IRQ module'
|
||||
'--enable-irq',
|
||||
action='store_true',
|
||||
default=False,
|
||||
dest='enable_irq',
|
||||
help='enable IRQ module'
|
||||
),
|
||||
parser.add_argument(
|
||||
'--enable-process-extended',
|
||||
@ -228,6 +238,14 @@ Examples of use:
|
||||
dest='enable_process_extended',
|
||||
help='enable extended stats on top process',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--separator',
|
||||
'--enable-separator',
|
||||
action='store_true',
|
||||
default=False,
|
||||
dest='enable_separator',
|
||||
help='enable separator in the UI'
|
||||
),
|
||||
# Sort processes list
|
||||
parser.add_argument(
|
||||
'--sort-processes',
|
||||
|
@ -27,6 +27,7 @@ from glances.globals import MACOS, WINDOWS
|
||||
from glances.logger import logger
|
||||
from glances.events import glances_events
|
||||
from glances.processes import glances_processes, sort_processes_key_list
|
||||
from glances.outputs.glances_unicode import unicode_message
|
||||
from glances.timer import Timer
|
||||
|
||||
# Import curses library for "normal" operating system
|
||||
@ -525,7 +526,7 @@ class _GlancesCurses(object):
|
||||
self.column = 0
|
||||
self.next_column = 0
|
||||
|
||||
def new_line(self):
|
||||
def new_line(self, separator=False):
|
||||
"""New line in the curses interface."""
|
||||
self.line = self.next_line
|
||||
|
||||
@ -533,6 +534,18 @@ class _GlancesCurses(object):
|
||||
"""New column in the curses interface."""
|
||||
self.column = self.next_column
|
||||
|
||||
def separator_line(self, color='TITLE'):
|
||||
"""New separator line in the curses interface."""
|
||||
if not self.args.enable_separator:
|
||||
return
|
||||
self.new_line()
|
||||
self.line -= 1
|
||||
line_width = self.term_window.getmaxyx()[1] - self.column
|
||||
self.term_window.addnstr(self.line, self.column,
|
||||
unicode_message('MEDIUM_LINE', self.args) * line_width,
|
||||
line_width,
|
||||
self.colors_list[color])
|
||||
|
||||
def __get_stat_display(self, stats, layer):
|
||||
"""Return a dict of dict with all the stats display.
|
||||
# TODO: Drop extra parameter
|
||||
@ -632,11 +645,14 @@ class _GlancesCurses(object):
|
||||
# Optionally: Cloud on second line
|
||||
# =====================================
|
||||
self.__display_header(__stat_display)
|
||||
self.separator_line()
|
||||
|
||||
# ==============================================================
|
||||
# Display second line (<SUMMARY>+CPU|PERCPU+<GPU>+LOAD+MEM+SWAP)
|
||||
# ==============================================================
|
||||
self.__display_top(__stat_display, stats)
|
||||
self.init_column()
|
||||
self.separator_line()
|
||||
|
||||
# ==================================================================
|
||||
# Display left sidebar (NETWORK+PORTS+DISKIO+FS+SENSORS+Current time)
|
||||
@ -725,12 +741,14 @@ class _GlancesCurses(object):
|
||||
self.display_plugin(stat_display["ip"])
|
||||
self.new_column()
|
||||
self.display_plugin(
|
||||
stat_display["uptime"], add_space=-(self.get_stats_display_width(stat_display["cloud"]) != 0)
|
||||
stat_display["uptime"],
|
||||
add_space=-(self.get_stats_display_width(stat_display["cloud"]) != 0)
|
||||
)
|
||||
# Second line (optional)
|
||||
self.init_column()
|
||||
self.new_line()
|
||||
self.display_plugin(stat_display["cloud"])
|
||||
if self.get_stats_display_width(stat_display["cloud"]) != 0:
|
||||
# Second line (optional)
|
||||
self.new_line()
|
||||
self.display_plugin(stat_display["cloud"])
|
||||
|
||||
def __display_top(self, stat_display, stats):
|
||||
"""Display the second line in the Curses interface.
|
||||
|
@ -26,9 +26,10 @@ _unicode_message = {
|
||||
'ARROW_DOWN': [u'\u2193', u'v'],
|
||||
'CHECK': [u'\u2713', u''],
|
||||
'PROCESS_SELECTOR': [u'>', u'>'],
|
||||
'MEDIUM_LINE': [u'\u23AF', u'-'],
|
||||
'LOW_LINE': [u'\u2581', u'_'],
|
||||
}
|
||||
|
||||
|
||||
def unicode_message(key, args=None):
|
||||
"""Return the unicode message for the given key."""
|
||||
if args and hasattr(args, 'disable_unicode') and args.disable_unicode:
|
||||
|
Loading…
Reference in New Issue
Block a user