Settings.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #ifndef HEADER_Settings
  2. #define HEADER_Settings
  3. /*
  4. htop - Settings.h
  5. (C) 2004-2011 Hisham H. Muhammad
  6. Released under the GNU GPLv2+, see the COPYING file
  7. in the source distribution for its full text.
  8. */
  9. #include <stdbool.h>
  10. #include <stddef.h>
  11. #include <stdint.h>
  12. #include "Hashtable.h"
  13. #include "HeaderLayout.h"
  14. #include "MeterMode.h"
  15. #include "Row.h"
  16. #include "RowField.h"
  17. #define DEFAULT_DELAY 15
  18. #define CONFIG_READER_MIN_VERSION 3
  19. struct DynamicScreen_; // IWYU pragma: keep
  20. struct Machine_; // IWYU pragma: keep
  21. struct Table_; // IWYU pragma: keep
  22. typedef struct {
  23. const char* name;
  24. const char* columns;
  25. const char* sortKey;
  26. const char* treeSortKey;
  27. } ScreenDefaults;
  28. typedef struct {
  29. size_t len;
  30. char** names;
  31. MeterModeId* modes;
  32. } MeterColumnSetting;
  33. typedef struct ScreenSettings_ {
  34. char* heading; /* user-editable screen name (pretty) */
  35. char* dynamic; /* from DynamicScreen config (fixed) */
  36. struct Table_* table;
  37. RowField* fields;
  38. uint32_t flags;
  39. int direction;
  40. int treeDirection;
  41. RowField sortKey;
  42. RowField treeSortKey;
  43. bool treeView;
  44. bool treeViewAlwaysByPID;
  45. bool allBranchesCollapsed;
  46. } ScreenSettings;
  47. typedef struct Settings_ {
  48. char* filename;
  49. char* initialFilename;
  50. bool writeConfig; /* whether to write the current settings on exit */
  51. int config_version;
  52. HeaderLayout hLayout;
  53. MeterColumnSetting* hColumns;
  54. Hashtable* dynamicColumns; /* runtime-discovered columns */
  55. Hashtable* dynamicMeters; /* runtime-discovered meters */
  56. Hashtable* dynamicScreens; /* runtime-discovered screens */
  57. ScreenSettings** screens;
  58. unsigned int nScreens;
  59. unsigned int ssIndex;
  60. ScreenSettings* ss;
  61. int colorScheme;
  62. int delay;
  63. bool countCPUsFromOne;
  64. bool detailedCPUTime;
  65. bool showCPUUsage;
  66. bool showCPUFrequency;
  67. #ifdef BUILD_WITH_CPU_TEMP
  68. bool showCPUTemperature;
  69. bool degreeFahrenheit;
  70. #endif
  71. bool showProgramPath;
  72. bool shadowOtherUsers;
  73. bool showThreadNames;
  74. bool hideKernelThreads;
  75. bool hideRunningInContainer;
  76. bool hideUserlandThreads;
  77. bool highlightBaseName;
  78. bool highlightDeletedExe;
  79. bool shadowDistPathPrefix;
  80. bool highlightMegabytes;
  81. bool highlightThreads;
  82. bool highlightChanges;
  83. int highlightDelaySecs;
  84. bool findCommInCmdline;
  85. bool stripExeFromCmdline;
  86. bool showMergedCommand;
  87. bool updateProcessNames;
  88. bool accountGuestInCPUMeter;
  89. bool headerMargin;
  90. bool screenTabs;
  91. #ifdef HAVE_GETMOUSE
  92. bool enableMouse;
  93. #endif
  94. int hideFunctionBar; // 0 - off, 1 - on ESC until next input, 2 - permanently
  95. #ifdef HAVE_LIBHWLOC
  96. bool topologyAffinity;
  97. #endif
  98. bool changed;
  99. uint64_t lastUpdate;
  100. } Settings;
  101. #define Settings_cpuId(settings, cpu) ((settings)->countCPUsFromOne ? (cpu)+1 : (cpu))
  102. static inline RowField ScreenSettings_getActiveSortKey(const ScreenSettings* this) {
  103. return (this->treeView)
  104. ? (this->treeViewAlwaysByPID ? 1 : this->treeSortKey)
  105. : this->sortKey;
  106. }
  107. static inline int ScreenSettings_getActiveDirection(const ScreenSettings* this) {
  108. return this->treeView ? this->treeDirection : this->direction;
  109. }
  110. void Settings_delete(Settings* this);
  111. int Settings_write(const Settings* this, bool onCrash);
  112. Settings* Settings_new(const struct Machine_* host, Hashtable* dynamicMeters, Hashtable* dynamicColumns, Hashtable* dynamicScreens);
  113. ScreenSettings* Settings_newScreen(Settings* this, const ScreenDefaults* defaults);
  114. ScreenSettings* Settings_newDynamicScreen(Settings* this, const char* tab, const struct DynamicScreen_* screen, struct Table_* table);
  115. void ScreenSettings_delete(ScreenSettings* this);
  116. void ScreenSettings_invertSortOrder(ScreenSettings* this);
  117. void ScreenSettings_setSortKey(ScreenSettings* this, RowField sortKey);
  118. void Settings_enableReadonly(void);
  119. bool Settings_isReadonly(void);
  120. void Settings_setHeaderLayout(Settings* this, HeaderLayout hLayout);
  121. #endif