diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2015-03-24 23:12:43 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2015-03-24 23:12:43 -0300 |
commit | a93db5234c8e24c56c4b5b615de837afeeac5e74 (patch) | |
tree | f68394fa63113bc62798e1e9fff66caaae1a7f8a /MainPanel.c | |
parent | 38fd1bfaba8b742d476a146ee111bf24cce9193e (diff) |
handle clicks on panel header line
Diffstat (limited to 'MainPanel.c')
-rw-r--r-- | MainPanel.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/MainPanel.c b/MainPanel.c index 9927dee3..6276edbf 100644 --- a/MainPanel.c +++ b/MainPanel.c @@ -67,7 +67,21 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) { Htop_Reaction reaction = HTOP_OK; - if (ch != ERR && this->inc->active) { + if (EVENT_IS_HEADER_CLICK(ch)) { + int x = EVENT_HEADER_CLICK_GET_X(ch); + ProcessList* pl = this->state->pl; + Settings* settings = this->state->settings; + int hx = super->scrollH + x + 1; + ProcessField field = ProcessList_keyAt(pl, hx); + if (field == settings->sortKey) { + Settings_invertSortOrder(settings); + settings->treeView = false; + } else { + reaction |= Action_setSortKey(settings, field); + } + reaction |= HTOP_RECALCULATE; + result = HANDLED; + } else if (ch != ERR && this->inc->active) { bool filterChanged = IncSet_handleKey(this->inc, ch, super, (IncMode_GetPanelValue) MainPanel_getValue, NULL); if (filterChanged) { this->state->pl->incFilter = IncSet_filter(this->inc); |