summaryrefslogtreecommitdiffstats
path: root/AffinityPanel.c
diff options
context:
space:
mode:
authorBert Wesarg <bert.wesarg@googlemail.com>2020-08-31 22:22:22 +0200
committerBert Wesarg <bert.wesarg@googlemail.com>2020-08-31 22:22:22 +0200
commit19359cec5a282350380a32981b09da0b4883fcda (patch)
treee873340797a832e68f24ca1209bc20f3ce3a7039 /AffinityPanel.c
parentb0f1336f79e5f07f591e05ceec13637b7452a15c (diff)
affinity panel: use the tree collapsing as in the process list
With one exception, the root node does also have a `-`/`+` as a prefix.
Diffstat (limited to 'AffinityPanel.c')
-rw-r--r--AffinityPanel.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/AffinityPanel.c b/AffinityPanel.c
index 91a9d456..1ffa9008 100644
--- a/AffinityPanel.c
+++ b/AffinityPanel.c
@@ -27,7 +27,7 @@ in the source distribution for its full text.
typedef struct MaskItem_ {
Object super;
const char* text;
- const char* indent;
+ const char* indent; /* used also as an condition whether this is a tree node */
int value; /* tri-state: 0 - off, 1 - some set, 2 - all set */
int sub_tree; /* tri-state: 0 - no sub-tree, 1 - open sub-tree, 2 - closed sub-tree */
Vector *children;
@@ -64,11 +64,12 @@ static void MaskItem_display(Object* cast, RichString* out) {
RichString_append(out, CRT_colors[CHECK_MARK], " ");
RichString_append(out, CRT_colors[CHECK_BOX], "]");
RichString_append(out, CRT_colors[CHECK_TEXT], " ");
- if (this->indent)
+ if (this->indent) {
RichString_append(out, CRT_colors[PROCESS_TREE], this->indent);
- if (this->sub_tree) {
- RichString_append(out, CRT_colors[ PROCESS_TREE],
- this->sub_tree == 1 ? "[-]" : "[+]");
+ RichString_append(out, CRT_colors[PROCESS_TREE],
+ this->sub_tree == 2
+ ? CRT_treeStr[TREE_STR_OPEN]
+ : CRT_treeStr[TREE_STR_SHUT]);
RichString_append(out, CRT_colors[CHECK_TEXT], " ");
}
RichString_append(out, CRT_colors[CHECK_TEXT], this->text);
@@ -84,7 +85,7 @@ static ObjectClass MaskItem_class = {
static MaskItem* MaskItem_newMask(const char* text, const char* indent, hwloc_bitmap_t cpuset, bool owner) {
MaskItem* this = AllocThis(MaskItem);
this->text = xStrdup(text);
- this->indent = xStrdup(indent);
+ this->indent = xStrdup(indent); /* nonnull for tree node */
this->value = 0;
this->ownCpuset = owner;
this->cpuset = cpuset;
@@ -98,7 +99,7 @@ static MaskItem* MaskItem_newMask(const char* text, const char* indent, hwloc_bi
static MaskItem* MaskItem_newSingleton(const char* text, int cpu, bool isSet) {
MaskItem* this = AllocThis(MaskItem);
this->text = xStrdup(text);
- this->indent = NULL;
+ this->indent = NULL; /* not a tree node */
this->sub_tree = 0;
this->children = Vector_new(Class(MaskItem), true, DEFAULT_SIZE);
@@ -279,9 +280,8 @@ static MaskItem *AffinityPanel_addObject(AffinityPanel* this, hwloc_obj_t obj, u
size_t len = strlen(&indent_buf[off]);
off += len, left -= len;
}
- xSnprintf(&indent_buf[off], left, "%s%s ",
- obj->next_sibling ? CRT_treeStr[TREE_STR_RTEE] : CRT_treeStr[TREE_STR_BEND],
- CRT_treeStr[TREE_STR_HORZ]);
+ xSnprintf(&indent_buf[off], left, "%s",
+ obj->next_sibling ? CRT_treeStr[TREE_STR_RTEE] : CRT_treeStr[TREE_STR_BEND]);
size_t len = strlen(&indent_buf[off]);
off += len, left -= len;
}
@@ -302,8 +302,8 @@ static MaskItem *AffinityPanel_addObject(AffinityPanel* this, hwloc_obj_t obj, u
item->sub_tree = 2;
}
- /* "[x] " + "|- " * depth + ("[+] ")? + name */
- unsigned width = 4 + 3 * depth + (item->sub_tree ? 4 : 0) + strlen(buf);
+ /* "[x] " + "|- " * depth + ("- ")?(if root node) + name */
+ unsigned width = 4 + 3 * depth + (2 * !depth) + strlen(buf);
if (width > this->width)
this->width = width;

© 2014-2024 Faster IT GmbH | imprint | privacy policy