@@ -56,22 +56,22 @@ Object* Action_pickFromVector(State* st, Panel* list, int x, bool follow) {
5656 Panel * panelFocus ;
5757 int ch ;
5858 bool unfollow = false;
59- int pid = follow ? MainPanel_selectedPid (mainPanel ) : -1 ;
60- if (follow && host -> pl -> following == -1 ) {
61- host -> pl -> following = pid ;
59+ int row = follow ? MainPanel_selectedRow (mainPanel ) : -1 ;
60+ if (follow && host -> activeTable -> following == -1 ) {
61+ host -> activeTable -> following = row ;
6262 unfollow = true;
6363 }
6464 ScreenManager_run (scr , & panelFocus , & ch , NULL );
6565 if (unfollow ) {
66- host -> pl -> following = -1 ;
66+ host -> activeTable -> following = -1 ;
6767 }
6868 ScreenManager_delete (scr );
6969 Panel_move ((Panel * )mainPanel , 0 , y );
7070 Panel_resize ((Panel * )mainPanel , COLS , LINES - y - 1 );
7171 if (panelFocus == list && ch == 13 ) {
7272 if (follow ) {
73- const Process * selected = (const Process * )Panel_getSelected ((Panel * )mainPanel );
74- if (selected && selected -> pid == pid )
73+ const Row * selected = (const Row * )Panel_getSelected ((Panel * )mainPanel );
74+ if (selected && selected -> id == row )
7575 return Panel_getSelected (list );
7676
7777 beep ();
@@ -99,7 +99,7 @@ static void Action_runSetup(State* st) {
9999
100100static bool changePriority (MainPanel * panel , int delta ) {
101101 bool anyTagged ;
102- bool ok = MainPanel_foreachProcess (panel , Process_changePriorityBy , (Arg ) { .i = delta }, & anyTagged );
102+ bool ok = MainPanel_foreachRow (panel , Process_changePriorityBy , (Arg ) { .i = delta }, & anyTagged );
103103 if (!ok )
104104 beep ();
105105 return anyTagged ;
@@ -121,36 +121,36 @@ bool Action_setUserOnly(const char* userName, uid_t* userId) {
121121 return false;
122122}
123123
124- static void tagAllChildren (Panel * panel , Process * parent ) {
124+ static void tagAllChildren (Panel * panel , Row * parent ) {
125125 parent -> tag = true;
126- pid_t ppid = parent -> pid ;
126+ int parent_id = parent -> id ;
127127 for (int i = 0 ; i < Panel_size (panel ); i ++ ) {
128- Process * p = (Process * ) Panel_get (panel , i );
129- if (!p -> tag && Process_isChildOf ( p , ppid )) {
130- tagAllChildren (panel , p );
128+ Row * row = (Row * ) Panel_get (panel , i );
129+ if (!row -> tag && Row_isChildOf ( row , parent_id )) {
130+ tagAllChildren (panel , row );
131131 }
132132 }
133133}
134134
135135static bool expandCollapse (Panel * panel ) {
136- Process * p = (Process * ) Panel_getSelected (panel );
137- if (!p )
136+ Row * row = (Row * ) Panel_getSelected (panel );
137+ if (!row )
138138 return false;
139139
140- p -> showChildren = !p -> showChildren ;
140+ row -> showChildren = !row -> showChildren ;
141141 return true;
142142}
143143
144144static bool collapseIntoParent (Panel * panel ) {
145- const Process * p = (Process * ) Panel_getSelected (panel );
146- if (!p )
145+ const Row * r = (Row * ) Panel_getSelected (panel );
146+ if (!r )
147147 return false;
148148
149- pid_t ppid = Process_getParentPid ( p );
149+ int parent_id = Row_getGroupOrParent ( r );
150150 for (int i = 0 ; i < Panel_size (panel ); i ++ ) {
151- Process * q = (Process * ) Panel_get (panel , i );
152- if (q -> pid == ppid ) {
153- q -> showChildren = false;
151+ Row * row = (Row * ) Panel_get (panel , i );
152+ if (row -> id == parent_id ) {
153+ row -> showChildren = false;
154154 Panel_setSelected (panel , i );
155155 return true;
156156 }
@@ -159,7 +159,7 @@ static bool collapseIntoParent(Panel* panel) {
159159}
160160
161161Htop_Reaction Action_setSortKey (Settings * settings , ProcessField sortKey ) {
162- ScreenSettings_setSortKey (settings -> ss , sortKey );
162+ ScreenSettings_setSortKey (settings -> ss , ( RowField ) sortKey );
163163 return HTOP_REFRESH | HTOP_SAVE_SETTINGS | HTOP_UPDATE_PANELHDR | HTOP_KEEP_FOLLOWING ;
164164}
165165
@@ -171,11 +171,11 @@ static Htop_Reaction actionSetSortColumn(State* st) {
171171 Panel_setHeader (sortPanel , "Sort by" );
172172 Machine * host = st -> host ;
173173 Settings * settings = host -> settings ;
174- const ProcessField * fields = settings -> ss -> fields ;
174+ const RowField * fields = settings -> ss -> fields ;
175175 Hashtable * dynamicColumns = settings -> dynamicColumns ;
176176 for (int i = 0 ; fields [i ]; i ++ ) {
177177 char * name = NULL ;
178- if (fields [i ] >= LAST_PROCESSFIELD ) {
178+ if (fields [i ] >= ROW_DYNAMIC_FIELDS ) {
179179 DynamicColumn * column = Hashtable_get (dynamicColumns , fields [i ]);
180180 if (!column )
181181 continue ;
@@ -195,7 +195,7 @@ static Htop_Reaction actionSetSortColumn(State* st) {
195195 }
196196 Object_delete (sortPanel );
197197
198- host -> pl -> needsSort = true;
198+ host -> activeTable -> needsSort = true;
199199
200200 return reaction | HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR ;
201201}
@@ -262,9 +262,9 @@ static Htop_Reaction actionToggleTreeView(State* st) {
262262 ss -> treeView = !ss -> treeView ;
263263
264264 if (!ss -> allBranchesCollapsed )
265- ProcessList_expandTree (host -> pl );
265+ Table_expandTree (host -> activeTable );
266266
267- host -> pl -> needsSort = true;
267+ host -> activeTable -> needsSort = true;
268268
269269 return HTOP_REFRESH | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR ;
270270}
@@ -282,17 +282,17 @@ static Htop_Reaction actionExpandOrCollapseAllBranches(State* st) {
282282 }
283283 ss -> allBranchesCollapsed = !ss -> allBranchesCollapsed ;
284284 if (ss -> allBranchesCollapsed )
285- ProcessList_collapseAllBranches (host -> pl );
285+ Table_collapseAllBranches (host -> activeTable );
286286 else
287- ProcessList_expandTree (host -> pl );
287+ Table_expandTree (host -> activeTable );
288288 return HTOP_REFRESH | HTOP_SAVE_SETTINGS ;
289289}
290290
291291static Htop_Reaction actionIncFilter (State * st ) {
292292 Machine * host = st -> host ;
293293 IncSet * inc = (st -> mainPanel )-> inc ;
294294 IncSet_activate (inc , INC_FILTER , (Panel * )st -> mainPanel );
295- host -> pl -> incFilter = IncSet_filter (inc );
295+ host -> activeTable -> incFilter = IncSet_filter (inc );
296296 return HTOP_REFRESH | HTOP_KEEP_FOLLOWING ;
297297}
298298
@@ -321,7 +321,7 @@ static Htop_Reaction actionLowerPriority(State* st) {
321321static Htop_Reaction actionInvertSortOrder (State * st ) {
322322 Machine * host = st -> host ;
323323 ScreenSettings_invertSortOrder (host -> settings -> ss );
324- host -> pl -> needsSort = true;
324+ host -> activeTable -> needsSort = true;
325325 return HTOP_REFRESH | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING | HTOP_UPDATE_PANELHDR ;
326326}
327327
@@ -397,11 +397,11 @@ static Htop_Reaction actionSetAffinity(State* st) {
397397 return HTOP_OK ;
398398
399399#if (defined(HAVE_LIBHWLOC ) || defined(HAVE_AFFINITY ))
400- const Process * p = (const Process * ) Panel_getSelected ((Panel * )st -> mainPanel );
401- if (!p )
400+ const Row * row = (const Row * ) Panel_getSelected ((Panel * )st -> mainPanel );
401+ if (!row )
402402 return HTOP_OK ;
403403
404- Affinity * affinity1 = Affinity_get (p , host );
404+ Affinity * affinity1 = Affinity_get (row , host );
405405 if (!affinity1 )
406406 return HTOP_OK ;
407407
@@ -412,7 +412,7 @@ static Htop_Reaction actionSetAffinity(State* st) {
412412 const void * set = Action_pickFromVector (st , affinityPanel , width , true);
413413 if (set ) {
414414 Affinity * affinity2 = AffinityPanel_getAffinity (affinityPanel , host );
415- bool ok = MainPanel_foreachProcess (st -> mainPanel , Affinity_set , (Arg ) { .v = affinity2 }, NULL );
415+ bool ok = MainPanel_foreachRow (st -> mainPanel , Affinity_set , (Arg ) { .v = affinity2 }, NULL );
416416 if (!ok )
417417 beep ();
418418 Affinity_delete (affinity2 );
@@ -459,7 +459,7 @@ static Htop_Reaction actionSetSchedPolicy(State* st) {
459459
460460 SchedulingArg v = { .policy = preSelectedPolicy , .priority = preSelectedPriority };
461461
462- bool ok = MainPanel_foreachProcess (st -> mainPanel , Scheduling_setPolicy , (Arg ) { .v = & v }, NULL );
462+ bool ok = MainPanel_foreachRow (st -> mainPanel , Scheduling_setPolicy , (Arg ) { .v = & v }, NULL );
463463 if (!ok )
464464 beep ();
465465 }
@@ -483,7 +483,7 @@ static Htop_Reaction actionKill(State* st) {
483483 Panel_setHeader ((Panel * )st -> mainPanel , "Sending..." );
484484 Panel_draw ((Panel * )st -> mainPanel , false, true, true, State_hideFunctionBar (st ));
485485 refresh ();
486- MainPanel_foreachProcess (st -> mainPanel , Process_sendSignal , (Arg ) { .i = sgn -> key }, NULL );
486+ MainPanel_foreachRow (st -> mainPanel , Process_sendSignal , (Arg ) { .i = sgn -> key }, NULL );
487487 napms (500 );
488488 }
489489 Panel_delete ((Object * )signalsPanel );
@@ -511,7 +511,7 @@ static Htop_Reaction actionFilterByUser(State* st) {
511511}
512512
513513Htop_Reaction Action_follow (State * st ) {
514- st -> host -> pl -> following = MainPanel_selectedPid (st -> mainPanel );
514+ st -> host -> activeTable -> following = MainPanel_selectedRow (st -> mainPanel );
515515 Panel_setSelectionColor ((Panel * )st -> mainPanel , PANEL_SELECTION_FOLLOW );
516516 return HTOP_KEEP_FOLLOWING ;
517517}
@@ -529,6 +529,8 @@ static Htop_Reaction actionLsof(State* st) {
529529 if (!p )
530530 return HTOP_OK ;
531531
532+ assert (Object_isA ((const Object * ) p , (const ObjectClass * ) & Process_class ));
533+
532534 OpenFilesScreen * ofs = OpenFilesScreen_new (p );
533535 InfoScreen_run ((InfoScreen * )ofs );
534536 OpenFilesScreen_delete ((Object * )ofs );
@@ -541,6 +543,9 @@ static Htop_Reaction actionShowLocks(State* st) {
541543 const Process * p = (Process * ) Panel_getSelected ((Panel * )st -> mainPanel );
542544 if (!p )
543545 return HTOP_OK ;
546+
547+ assert (Object_isA ((const Object * ) p , (const ObjectClass * ) & Process_class ));
548+
544549 ProcessLocksScreen * pls = ProcessLocksScreen_new (p );
545550 InfoScreen_run ((InfoScreen * )pls );
546551 ProcessLocksScreen_delete ((Object * )pls );
@@ -556,6 +561,7 @@ static Htop_Reaction actionStrace(State* st) {
556561 const Process * p = (Process * ) Panel_getSelected ((Panel * )st -> mainPanel );
557562 if (!p )
558563 return HTOP_OK ;
564+ assert (Object_isA ((const Object * ) p , (const ObjectClass * ) & Process_class ));
559565
560566 TraceScreen * ts = TraceScreen_new (p );
561567 bool ok = TraceScreen_forkTracer (ts );
@@ -569,11 +575,11 @@ static Htop_Reaction actionStrace(State* st) {
569575}
570576
571577static Htop_Reaction actionTag (State * st ) {
572- Process * p = (Process * ) Panel_getSelected ((Panel * )st -> mainPanel );
573- if (!p )
578+ Row * r = (Row * ) Panel_getSelected ((Panel * )st -> mainPanel );
579+ if (!r )
574580 return HTOP_OK ;
575581
576- Process_toggleTag ( p );
582+ Row_toggleTag ( r );
577583 Panel_onKey ((Panel * )st -> mainPanel , KEY_DOWN );
578584 return HTOP_OK ;
579585}
@@ -782,18 +788,18 @@ static Htop_Reaction actionHelp(State* st) {
782788
783789static Htop_Reaction actionUntagAll (State * st ) {
784790 for (int i = 0 ; i < Panel_size ((Panel * )st -> mainPanel ); i ++ ) {
785- Process * p = (Process * ) Panel_get ((Panel * )st -> mainPanel , i );
786- p -> tag = false;
791+ Row * row = (Row * ) Panel_get ((Panel * )st -> mainPanel , i );
792+ row -> tag = false;
787793 }
788794 return HTOP_REFRESH ;
789795}
790796
791797static Htop_Reaction actionTagAllChildren (State * st ) {
792- Process * p = (Process * ) Panel_getSelected ((Panel * )st -> mainPanel );
793- if (!p )
798+ Row * row = (Row * ) Panel_getSelected ((Panel * )st -> mainPanel );
799+ if (!row )
794800 return HTOP_OK ;
795801
796- tagAllChildren ((Panel * )st -> mainPanel , p );
802+ tagAllChildren ((Panel * )st -> mainPanel , row );
797803 return HTOP_OK ;
798804}
799805
@@ -802,6 +808,8 @@ static Htop_Reaction actionShowEnvScreen(State* st) {
802808 if (!p )
803809 return HTOP_OK ;
804810
811+ assert (Object_isA ((const Object * ) p , (const ObjectClass * ) & Process_class ));
812+
805813 EnvScreen * es = EnvScreen_new (p );
806814 InfoScreen_run ((InfoScreen * )es );
807815 EnvScreen_delete ((Object * )es );
@@ -815,6 +823,8 @@ static Htop_Reaction actionShowCommandScreen(State* st) {
815823 if (!p )
816824 return HTOP_OK ;
817825
826+ assert (Object_isA ((const Object * ) p , (const ObjectClass * ) & Process_class ));
827+
818828 CommandScreen * cmdScr = CommandScreen_new (p );
819829 InfoScreen_run ((InfoScreen * )cmdScr );
820830 CommandScreen_delete ((Object * )cmdScr );
0 commit comments