X-Git-Url: http://git.annexia.org/?p=virt-top.git;a=blobdiff_plain;f=src%2Fscreen.ml;fp=src%2Fscreen.ml;h=0d847a274d4318a89eee14ebf2a378f83861250f;hp=0000000000000000000000000000000000000000;hb=90d14bc151e488972d33eefaac2242d9a6e07578;hpb=3e9ed9c0fe49c3d4e4a8e467d521f676769c485a;ds=sidebyside diff --git a/src/screen.ml b/src/screen.ml new file mode 100644 index 0000000..0d847a2 --- /dev/null +++ b/src/screen.ml @@ -0,0 +1,52 @@ +(* 'top'-like tool for libvirt domains. + (C) Copyright 2007-2017 Richard W.M. Jones, Red Hat Inc. + http://libvirt.org/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*) + +(* The virt-top screen layout. *) + +open Curses + +module D = Libvirt.Domain + +(* Line numbers. *) +let top_lineno = 0 +let summary_lineno = 1 (* this takes 2 lines *) +let message_lineno = 3 +let header_lineno = 4 +let domains_lineno = 5 + +(* Easier to use versions of curses functions addstr, mvaddstr, etc. *) +let move y x = ignore (move y x) +let refresh () = ignore (refresh ()) +let addch c = ignore (addch (int_of_char c)) +let addstr s = ignore (addstr s) +let mvaddstr y x s = ignore (mvaddstr y x s) + +(* Print in the "message area". *) +let clear_msg () = move message_lineno 0; clrtoeol () +let print_msg str = clear_msg (); mvaddstr message_lineno 0 str + +(* Show a libvirt domain state (the 'S' column). *) +let show_state = function + | D.InfoNoState -> '?' + | D.InfoRunning -> 'R' + | D.InfoBlocked -> 'S' + | D.InfoPaused -> 'P' + | D.InfoShutdown -> 'D' + | D.InfoShutoff -> 'O' + | D.InfoCrashed -> 'X'