Introduce CLAMP macro. Unify all MIN(MAX(a,b),c) uses.

With the CLAMP macro replacing the combination of MIN and MAX, we will
have at least two advantages:
1. It's more obvious semantically.
2. There are no more mixes of confusing uses like MIN(MAX(a,b),c) and
   MAX(MIN(a,b),c) and MIN(a,MAX(b,c)) appearing everywhere. We unify
   the 'clamping' with a single macro.
Note that the behavior of this CLAMP macro is different from
the combination `MAX(low,MIN(x,high))`.
* This CLAMP macro expands to two comparisons instead of three from
  MAX and MIN combination. In theory, this makes the code slightly
  smaller, in case that (low) or (high) or both are computed at
  runtime, so that compilers cannot optimize them. (The third
  comparison will matter if (low)>(high); see below.)
* CLAMP has a side effect, that if (low)>(high) it will produce weird
  results. Unlike MIN & MAX which will force either (low) or (high) to
  win. No assertion of ((low)<=(high)) is done in this macro, for now.

This CLAMP macro is implemented like described in glib
<http://developer.gnome.org/glib/stable/glib-Standard-Macros.html>
and does not handle weird uses like CLAMP(a++, low++, high--) .
14 files changed
tree: 7cb08e282337b483de387b68cf7e225eb359853f
  1. .editorconfig
  2. .gitignore
  3. .travis.yml
  4. AUTHORS
  5. Action.c
  6. Action.h
  7. Affinity.c
  8. Affinity.h
  9. AffinityPanel.c
  10. AffinityPanel.h
  11. AvailableColumnsPanel.c
  12. AvailableColumnsPanel.h
  13. AvailableMetersPanel.c
  14. AvailableMetersPanel.h
  15. BatteryMeter.c
  16. BatteryMeter.h
  17. COPYING
  18. CPUMeter.c
  19. CPUMeter.h
  20. CRT.c
  21. CRT.h
  22. CategoriesPanel.c
  23. CategoriesPanel.h
  24. ChangeLog
  25. CheckItem.c
  26. CheckItem.h
  27. ClockMeter.c
  28. ClockMeter.h
  29. ColorsPanel.c
  30. ColorsPanel.h
  31. ColumnsPanel.c
  32. ColumnsPanel.h
  33. DisplayOptionsPanel.c
  34. DisplayOptionsPanel.h
  35. EnvScreen.c
  36. EnvScreen.h
  37. FunctionBar.c
  38. FunctionBar.h
  39. Hashtable.c
  40. Hashtable.h
  41. Header.c
  42. Header.h
  43. HostnameMeter.c
  44. HostnameMeter.h
  45. INSTALL
  46. IncSet.c
  47. IncSet.h
  48. InfoScreen.c
  49. InfoScreen.h
  50. ListItem.c
  51. ListItem.h
  52. LoadAverageMeter.c
  53. LoadAverageMeter.h
  54. MainPanel.c
  55. MainPanel.h
  56. Makefile.am
  57. MemoryMeter.c
  58. MemoryMeter.h
  59. Meter.c
  60. Meter.h
  61. MetersPanel.c
  62. MetersPanel.h
  63. NEWS
  64. Object.c
  65. Object.h
  66. OpenFilesScreen.c
  67. OpenFilesScreen.h
  68. Panel.c
  69. Panel.h
  70. Process.c
  71. Process.h
  72. ProcessList.c
  73. ProcessList.h
  74. README
  75. RichString.c
  76. RichString.h
  77. ScreenManager.c
  78. ScreenManager.h
  79. Settings.c
  80. Settings.h
  81. SignalsPanel.c
  82. SignalsPanel.h
  83. StringUtils.c
  84. StringUtils.h
  85. SwapMeter.c
  86. SwapMeter.h
  87. TESTPLAN
  88. TasksMeter.c
  89. TasksMeter.h
  90. TraceScreen.c
  91. TraceScreen.h
  92. UptimeMeter.c
  93. UptimeMeter.h
  94. UsersTable.c
  95. UsersTable.h
  96. Vector.c
  97. Vector.h
  98. autogen.sh
  99. configure.ac
  100. darwin/
  101. freebsd/
  102. htop.1.in
  103. htop.c
  104. htop.desktop
  105. htop.h
  106. htop.png
  107. linux/
  108. openbsd/
  109. scripts/
  110. test_spec.lua
  111. unsupported/
README.md

htop

by Hisham Muhammad hisham@gobolinux.org

2004 - 2015

Introduction

This is htop, an interactive process viewer. It requires ncurses. It is developed primarily on Linux, but we also have code for running under FreeBSD and Mac OS X (help and testing are wanted for these platforms!)

This software has evolved considerably over the years, and is reasonably complete, but there is always room for improvement.

Comparison between ‘htop’ and classic ‘top’

  • In ‘htop’ you can scroll the list vertically and horizontally to see all processes and full command lines.
  • In ‘top’ you are subject to a delay for each unassigned key you press (especially annoying when multi-key escape sequences are triggered by accident).
  • ‘htop’ starts faster (‘top’ seems to collect data for a while before displaying anything).
  • In ‘htop’ you don't need to type the process number to kill a process, in ‘top’ you do.
  • In ‘htop’ you don't need to type the process number or the priority value to renice a process, in ‘top’ you do.
  • In ‘htop’ you can kill multiple processes at once.
  • ‘top’ is older, hence, more tested.

Compilation instructions

This program is distributed as a standard autotools-based package. See the INSTALL file for detailed instructions, but you are probably used to the common ./configure/make/make install routine.

When fetching the code from the development repository, you need to run the ./autogen.sh script, which in turn requires autotools to be installed.

See the manual page (man htop) or the on-line help (‘F1’ or ‘h’ inside htop) for a list of supported key commands.

if not all keys work check your curses configuration.