-
-
Notifications
You must be signed in to change notification settings - Fork 577
PCP: DynamicScreens #1102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PCP: DynamicScreens #1102
Changes from all commits
6a27de7
6f4d75a
2069fb9
383dfcf
2dc6d1f
fbc8242
a0b1439
1e585f3
f65ef79
a920974
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -25,6 +25,8 @@ in the source distribution for its full text. | |||
| #include "CRT.h" | ||||
| #include "DynamicColumn.h" | ||||
| #include "DynamicMeter.h" | ||||
| #include "DynamicScreen.h" | ||||
| #include "GenericDataList.h" | ||||
| #include "Hashtable.h" | ||||
| #include "Header.h" | ||||
| #include "IncSet.h" | ||||
|
|
@@ -328,11 +330,18 @@ int CommandLine_run(const char* name, int argc, char** argv) { | |||
| dc = Hashtable_new(0, true); | ||||
|
|
||||
| ProcessList* pl = ProcessList_new(ut, dm, dc, flags.pidMatchList, flags.userId); | ||||
|
|
||||
| Settings* settings = Settings_new(pl->activeCPUs, dc); | ||||
| fprintf(stderr, "Settings created\n"); | ||||
| Hashtable* dt = DynamicScreens_new(settings); | ||||
| fprintf(stderr, "DynamicScreens created\n"); | ||||
| GenericDataList* gl = GenericDataList_new(); | ||||
| fprintf(stderr, "GenericDataList created\n"); | ||||
|
|
||||
| pl->settings = settings; | ||||
| if (gl) | ||||
| gl->settings = settings; | ||||
|
|
||||
| Header* header = Header_new(pl, settings, 2); | ||||
| Header* header = Header_new(pl, gl, settings, 2); | ||||
|
|
||||
| Header_populateFromSettings(header); | ||||
|
|
||||
|
|
@@ -362,7 +371,7 @@ int CommandLine_run(const char* name, int argc, char** argv) { | |||
| CRT_init(settings, flags.allowUnicode); | ||||
|
|
||||
| MainPanel* panel = MainPanel_new(); | ||||
| ProcessList_setPanel(pl, (Panel*) panel); | ||||
| MainPanel* genericDataPanel = MainPanel_new(); | ||||
|
|
||||
| MainPanel_updateLabels(panel, settings->ss->treeView, flags.commFilter); | ||||
|
|
||||
|
|
@@ -372,12 +381,18 @@ int CommandLine_run(const char* name, int argc, char** argv) { | |||
| .pl = pl, | ||||
| .mainPanel = panel, | ||||
| .header = header, | ||||
| .pauseProcessUpdate = false, | ||||
| .hideProcessSelection = false, | ||||
| .pauseUpdate = false, | ||||
| .hideSelection = false, | ||||
| .hideMeters = false, | ||||
| }; | ||||
|
|
||||
| MainPanel_setState(panel, &state); | ||||
| panel->state = &state; | ||||
| genericDataPanel->state = &state; | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be ... ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @natoscott I think we need a new panel working in parallel with/instead MainPanel. This is a big part of what I'm talking about so far... Line 215 in bc22bee
also, @BenBE told me before how to do that: @natoscott I need your help here...
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will have to wait for next week; not in town tomorrow and the day after (giving a talk for a small conference). Changes-wise it boils down to creating inherited classes similar to what can be seen with
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @BenBE ping - can you post that detailed writeup here when you get a free minute? :) Thanks! |
||||
|
|
||||
| ProcessList_setPanel(pl, (Panel*) panel); | ||||
| if (gl) | ||||
| GenericDataList_setPanel(gl, (Panel*) genericDataPanel); | ||||
|
|
||||
| if (flags.commFilter) | ||||
| setCommFilter(&state, &(flags.commFilter)); | ||||
|
|
||||
|
|
@@ -405,6 +420,7 @@ int CommandLine_run(const char* name, int argc, char** argv) { | |||
|
|
||||
| Header_delete(header); | ||||
| ProcessList_delete(pl); | ||||
| GenericDataList_delete(gl); | ||||
|
|
||||
| ScreenManager_delete(scr); | ||||
| MetersPanel_cleanup(); | ||||
|
|
@@ -420,6 +436,7 @@ int CommandLine_run(const char* name, int argc, char** argv) { | |||
| Settings_delete(settings); | ||||
| DynamicColumns_delete(dc); | ||||
| DynamicMeters_delete(dm); | ||||
| DynamicScreens_delete(dt); | ||||
|
|
||||
| return 0; | ||||
| } | ||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| htop - DynamicScreen.c | ||
| (C) 2022 Sohaib Mohammed | ||
| (C) 2022 htop dev team | ||
| (C) 2022 Red Hat, Inc. All Rights Reserved. | ||
| Released under the GNU GPLv2+, see the COPYING file | ||
| in the source distribution for its full text. | ||
| */ | ||
|
|
||
| #include "DynamicScreen.h" | ||
|
|
||
| #include <stdbool.h> | ||
| #include <stddef.h> | ||
|
|
||
| #include "Hashtable.h" | ||
| #include "Platform.h" | ||
| #include "XUtils.h" | ||
|
|
||
|
|
||
| Hashtable* DynamicScreens_new(Settings* settings) { | ||
| return Platform_dynamicScreens(settings); | ||
| } | ||
|
|
||
| void DynamicScreens_delete(Hashtable* dynamics) { | ||
| if (dynamics) { | ||
| Platform_dynamicScreensDone(dynamics); | ||
| Hashtable_delete(dynamics); | ||
| } | ||
| } | ||
|
|
||
| typedef struct { | ||
| ht_key_t key; | ||
| const char* name; | ||
| bool found; | ||
| } DynamicIterator; | ||
|
|
||
| static void DynamicScreen_compare(ht_key_t key, void* value, void* data) { | ||
| const DynamicScreen* screen = (const DynamicScreen*)value; | ||
| DynamicIterator* iter = (DynamicIterator*)data; | ||
| if (String_eq(iter->name, screen->name)) { | ||
| iter->found = true; | ||
| iter->key = key; | ||
| } | ||
| } | ||
|
|
||
| bool DynamicScreen_search(Hashtable* dynamics, const char* name, ht_key_t* key) { | ||
| DynamicIterator iter = { .key = 0, .name = name, .found = false }; | ||
| if (dynamics) | ||
| Hashtable_foreach(dynamics, DynamicScreen_compare, &iter); | ||
| if (key) | ||
| *key = iter.key; | ||
| return iter.found; | ||
| } | ||
|
|
||
| const char* DynamicScreen_lookup(Hashtable* dynamics, ht_key_t key) { | ||
| const DynamicScreen* screen = Hashtable_get(dynamics, key); | ||
| return screen ? screen->name : NULL; | ||
| } | ||
|
|
||
| void DynamicScreen_availableColumns(char* currentScreen) { | ||
| Platform_dynamicScreenAvailableColumns(currentScreen); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #ifndef HEADER_DynamicScreen | ||
| #define HEADER_DynamicScreen | ||
|
|
||
| #include <stdbool.h> | ||
|
|
||
| #include "Hashtable.h" | ||
| #include "Settings.h" | ||
|
|
||
|
|
||
| typedef struct DynamicScreen_ { | ||
| char name[32]; /* unique name, cannot contain spaces */ | ||
| char* caption; | ||
| char* fields; | ||
| char* sortKey; | ||
| int direction; | ||
| } DynamicScreen; | ||
|
|
||
| Hashtable* DynamicScreens_new(Settings* settings); | ||
|
|
||
| void DynamicScreens_delete(Hashtable* dynamics); | ||
|
|
||
| const char* DynamicScreen_lookup(Hashtable* dynamics, unsigned int key); | ||
|
|
||
| bool DynamicScreen_search(Hashtable* dynamics, const char* name, unsigned int* key); | ||
|
|
||
| void DynamicScreen_availableColumns(char* currentScreen); | ||
|
|
||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| htop - GenericData.c | ||
| (C) 2022 Sohaib Mohammed | ||
| (C) 2022 htop dev team | ||
| (C) 2022 Red Hat, Inc. | ||
| Released under the GNU GPLv2+, see the COPYING file | ||
| in the source distribution for its full text. | ||
| */ | ||
|
|
||
| #include "GenericData.h" | ||
|
|
||
| #include <assert.h> | ||
|
|
||
| #include "CRT.h" | ||
| #include "Macros.h" | ||
| #include "Process.h" | ||
| #include "RichString.h" | ||
| #include "Settings.h" | ||
|
|
||
|
|
||
| void GenericData_init(GenericData* this, const Settings* settings) { | ||
| this->settings = settings; | ||
| } | ||
|
|
||
| void GenericData_done(ATTR_UNUSED GenericData* this) { | ||
| assert (this != NULL); | ||
| } | ||
|
|
||
| void GenericData_writeField(ATTR_UNUSED const GenericData* this, ATTR_UNUSED RichString* str, ATTR_UNUSED int field) { | ||
| return; | ||
| } | ||
|
|
||
| void GenericData_display(const Object* cast, RichString* out) { | ||
| const GenericData* this = (const GenericData*) cast; | ||
| const ProcessField* fields = this->settings->ss->fields; | ||
| for (int i = 0; fields[i]; i++) | ||
| As_GenericData(this)->writeField(this, out, i); | ||
| } | ||
|
|
||
| int GenericData_compare(const void* v1, const void* v2) { | ||
| const GenericData* g1 = (const GenericData*)v1; | ||
| const GenericData* g2 = (const GenericData*)v2; | ||
|
|
||
| const Settings* settings = g1->settings; | ||
| const ScreenSettings* ss = settings->ss; | ||
|
|
||
| ProcessField key = ScreenSettings_getActiveSortKey(ss); | ||
|
|
||
| int result = GenericData_compareByKey(g1, g2, key); | ||
|
|
||
| return (ScreenSettings_getActiveDirection(ss) == 1) ? result : -result; | ||
| } | ||
|
|
||
| int GenericData_compareByKey_Base(const GenericData* g1, const GenericData* g2, ATTR_UNUSED ProcessField key) { | ||
| // TODO | ||
| (void) g1; | ||
| (void) g2; | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| const GenericDataClass GenericData_class = { | ||
| .super = { | ||
| .extends = Class(Object), | ||
| .display = GenericData_display, | ||
| .compare = GenericData_compare, | ||
| }, | ||
| .writeField = GenericData_writeField, | ||
| }; |
Uh oh!
There was an error while loading. Please reload this page.