Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
BenBE committed Dec 26, 2023
1 parent a98fc47 commit 6aa9ef2
Show file tree
Hide file tree
Showing 45 changed files with 685 additions and 715 deletions.
84 changes: 42 additions & 42 deletions AffinityPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,57 +202,57 @@ static HandlerResult AffinityPanel_eventHandler(Panel* super, int ch) {
bool keepSelected = true;

switch (ch) {
case KEY_MOUSE:
case KEY_RECLICK:
case ' ':
#ifdef HAVE_LIBHWLOC
if (selected->value == 2) {
/* Item was selected, so remove this mask from the top cpuset. */
hwloc_bitmap_andnot(this->workCpuset, this->workCpuset, selected->cpuset);
selected->value = 0;
} else {
/* Item was not or only partial selected, so set all bits from this object
in the top cpuset. */
hwloc_bitmap_or(this->workCpuset, this->workCpuset, selected->cpuset);
selected->value = 2;
}
#else
selected->value = selected->value ? 0 : 2; /* toggle between 0 and 2 */
#endif
case KEY_MOUSE:
case KEY_RECLICK:
case ' ':
#ifdef HAVE_LIBHWLOC
if (selected->value == 2) {
/* Item was selected, so remove this mask from the top cpuset. */
hwloc_bitmap_andnot(this->workCpuset, this->workCpuset, selected->cpuset);
selected->value = 0;
} else {
/* Item was not or only partial selected, so set all bits from this object
in the top cpuset. */
hwloc_bitmap_or(this->workCpuset, this->workCpuset, selected->cpuset);
selected->value = 2;
}
#else
selected->value = selected->value ? 0 : 2; /* toggle between 0 and 2 */
#endif

result = HANDLED;
break;
result = HANDLED;
break;

#ifdef HAVE_LIBHWLOC
#ifdef HAVE_LIBHWLOC

case KEY_F(1):
hwloc_bitmap_copy(this->workCpuset, this->allCpuset);
result = HANDLED;
break;
case KEY_F(1):
hwloc_bitmap_copy(this->workCpuset, this->allCpuset);
result = HANDLED;
break;

case KEY_F(2):
this->topoView = !this->topoView;
keepSelected = false;
case KEY_F(2):
this->topoView = !this->topoView;
keepSelected = false;

result = HANDLED;
break;
result = HANDLED;
break;

case KEY_F(3):
case '-':
case '+':
if (selected->sub_tree)
selected->sub_tree = 1 + !(selected->sub_tree - 1); /* toggle between 1 and 2 */
case KEY_F(3):
case '-':
case '+':
if (selected->sub_tree)
selected->sub_tree = 1 + !(selected->sub_tree - 1); /* toggle between 1 and 2 */

result = HANDLED;
break;
result = HANDLED;
break;

#endif
#endif

case 0x0a:
case 0x0d:
case KEY_ENTER:
result = BREAK_LOOP;
break;
case 0x0a:
case 0x0d:
case KEY_ENTER:
result = BREAK_LOOP;
break;
}

if (HANDLED == result)
Expand Down
5 changes: 1 addition & 4 deletions AvailableColumnsPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ static HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch) {
switch (ch) {
case 13:
case KEY_ENTER:
case KEY_F(5):
{
case KEY_F(5): {
const ListItem* selected = (ListItem*) Panel_getSelected(super);
if (!selected)
break;
Expand All @@ -65,11 +64,9 @@ static HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch) {
break;
}
default:
{
if (0 < ch && ch < 255 && isgraph((unsigned char)ch))
result = Panel_selectByTyping(super, ch);
break;
}
}
return result;
}
Expand Down
6 changes: 2 additions & 4 deletions AvailableMetersPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,22 @@ static HandlerResult AvailableMetersPanel_eventHandler(Panel* super, int ch) {
case KEY_F(5):
case 'l':
case 'L':
{
AvailableMetersPanel_addMeter(header, this->meterPanels[0], Platform_meterTypes[type], param, 0);
result = HANDLED;
update = true;
break;
}
case 0x0a:
case 0x0d:
case KEY_ENTER:
case KEY_F(6):
case 'r':
case 'R':
{
AvailableMetersPanel_addMeter(header, this->meterPanels[this->columns - 1], Platform_meterTypes[type], param, this->columns - 1);
result = (KEY_LEFT << 16) | SYNTH_KEY;
update = true;
break;
}
}

if (update) {
Settings* settings = this->host->settings;
settings->changed = true;
Expand All @@ -88,6 +85,7 @@ static HandlerResult AvailableMetersPanel_eventHandler(Panel* super, int ch) {
Header_draw(header);
ScreenManager_resize(this->scr);
}

return result;
}

Expand Down
20 changes: 10 additions & 10 deletions BatteryMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ static void BatteryMeter_updateValues(Meter* this) {

const char* text;
switch (isOnAC) {
case AC_PRESENT:
text = this->mode == TEXT_METERMODE ? " (Running on A/C)" : "(A/C)";
break;
case AC_ABSENT:
text = this->mode == TEXT_METERMODE ? " (Running on battery)" : "(bat)";
break;
case AC_ERROR:
default:
text = "";
break;
case AC_PRESENT:
text = this->mode == TEXT_METERMODE ? " (Running on A/C)" : "(A/C)";
break;
case AC_ABSENT:
text = this->mode == TEXT_METERMODE ? " (Running on battery)" : "(bat)";
break;
case AC_ERROR:
default:
text = "";
break;
}

xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%.1f%%%s", percent, text);
Expand Down
4 changes: 2 additions & 2 deletions CRT.c
Original file line number Diff line number Diff line change
Expand Up @@ -1113,8 +1113,8 @@ void CRT_setColors(int colorScheme) {
for (short int j = 0; j < 8; j++) {
if (ColorIndex(i, j) != ColorIndexGrayBlack && ColorIndex(i, j) != ColorIndexWhiteDefault) {
short int bg = (colorScheme != COLORSCHEME_BLACKNIGHT)
? (j == 0 ? -1 : j)
: j;
? (j == 0 ? -1 : j)
: j;
init_pair(ColorIndex(i, j), i, bg);
}
}
Expand Down
45 changes: 23 additions & 22 deletions ColorsPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,31 @@ static HandlerResult ColorsPanel_eventHandler(Panel* super, int ch) {
ColorsPanel* this = (ColorsPanel*) super;

HandlerResult result = IGNORED;
int mark;

switch (ch) {
case 0x0a:
case 0x0d:
case KEY_ENTER:
case KEY_MOUSE:
case KEY_RECLICK:
case ' ':
mark = Panel_getSelectedIndex(super);
assert(mark >= 0);
assert(mark < LAST_COLORSCHEME);
for (int i = 0; ColorSchemeNames[i] != NULL; i++)
CheckItem_set((CheckItem*)Panel_get(super, i), false);
CheckItem_set((CheckItem*)Panel_get(super, mark), true);

this->settings->colorScheme = mark;
this->settings->changed = true;
this->settings->lastUpdate++;

CRT_setColors(mark);
clear();

result = HANDLED | REDRAW;
case 0x0a:
case 0x0d:
case KEY_ENTER:
case KEY_MOUSE:
case KEY_RECLICK:
case ' ': {
int mark = Panel_getSelectedIndex(super);
assert(mark >= 0);
assert(mark < LAST_COLORSCHEME);

for (int i = 0; ColorSchemeNames[i] != NULL; i++)
CheckItem_set((CheckItem*)Panel_get(super, i), false);
CheckItem_set((CheckItem*)Panel_get(super, mark), true);

this->settings->colorScheme = mark;
this->settings->changed = true;
this->settings->lastUpdate++;

CRT_setColors(mark);
clear();

result = HANDLED | REDRAW;
}
}

return result;
Expand Down
25 changes: 5 additions & 20 deletions ColumnsPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) {
case KEY_ENTER:
case KEY_MOUSE:
case KEY_RECLICK:
{
if (selected < size - 1) {
this->moving = !(this->moving);
Panel_setSelectionColor(super, this->moving ? PANEL_SELECTION_FOLLOW : PANEL_SELECTION_FOCUS);
Expand All @@ -56,59 +55,45 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) {
result = HANDLED;
}
break;
}
case KEY_UP:
{
if (!this->moving) {
if (!this->moving)
break;
}
}
/* else fallthrough */
case KEY_F(7):
case '[':
case '-':
{
if (selected < size - 1)
Panel_moveSelectedUp(super);
result = HANDLED;
break;
}
case KEY_DOWN:
{
if (!this->moving) {
if (!this->moving)
break;
}
}
/* else fallthrough */
case KEY_F(8):
case ']':
case '+':
{
if (selected < size - 2)
Panel_moveSelectedDown(super);
result = HANDLED;
break;
}
case KEY_F(9):
case KEY_DC:
{
if (selected < size - 1) {
if (selected < size - 1)
Panel_remove(super, selected);
}
result = HANDLED;
break;
}
default:
{
if (0 < ch && ch < 255 && isgraph((unsigned char)ch))
result = Panel_selectByTyping(super, ch);
if (result == BREAK_LOOP)
result = IGNORED;
break;
}
}

if (result == HANDLED)
ColumnsPanel_update(super);

return result;
}

Expand Down
7 changes: 3 additions & 4 deletions CommandLine.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ static CommandLineStatus parseArguments(int argc, char** argv, CommandLineSettin
while ((opt = getopt_long(argc, argv, "hVMCs:td:n:u::Up:F:H::", long_opts, &opti))) {
if (opt == EOF)
break;

switch (opt) {
case 'h':
printHelpFlag(program);
Expand Down Expand Up @@ -192,8 +193,7 @@ static CommandLineStatus parseArguments(int argc, char** argv, CommandLineSettin
return STATUS_ERROR_EXIT;
}
break;
case 'u':
{
case 'u': {
const char* username = optarg;
if (!username && optind < argc && argv[optind] != NULL &&
(argv[optind][0] != '\0' && argv[optind][0] != '-')) {
Expand Down Expand Up @@ -246,11 +246,10 @@ static CommandLineStatus parseArguments(int argc, char** argv, CommandLineSettin

break;
}
case 'F': {
case 'F':
assert(optarg);
free_and_xStrdup(&flags->commFilter, optarg);
break;
}
case 'H': {
const char* delay = optarg;
if (!delay && optind < argc && argv[optind] != NULL &&
Expand Down
25 changes: 12 additions & 13 deletions DiskIOMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,23 @@ static void DiskIOMeter_updateValues(Meter* this) {

static void DiskIOMeter_display(ATTR_UNUSED const Object* cast, RichString* out) {
switch (status) {
case RATESTATUS_NODATA:
RichString_writeAscii(out, CRT_colors[METER_VALUE_ERROR], "no data");
return;
case RATESTATUS_INIT:
RichString_writeAscii(out, CRT_colors[METER_VALUE], "initializing...");
return;
case RATESTATUS_STALE:
RichString_writeAscii(out, CRT_colors[METER_VALUE_WARN], "stale data");
return;
case RATESTATUS_DATA:
break;
case RATESTATUS_NODATA:
RichString_writeAscii(out, CRT_colors[METER_VALUE_ERROR], "no data");
return;
case RATESTATUS_INIT:
RichString_writeAscii(out, CRT_colors[METER_VALUE], "initializing...");
return;
case RATESTATUS_STALE:
RichString_writeAscii(out, CRT_colors[METER_VALUE_WARN], "stale data");
return;
case RATESTATUS_DATA:
break;
}

char buffer[16];
int len;

int color = cached_utilisation_diff > 40.0 ? METER_VALUE_NOTICE : METER_VALUE;
len = xSnprintf(buffer, sizeof(buffer), "%.1f%%", cached_utilisation_diff);
int len = xSnprintf(buffer, sizeof(buffer), "%.1f%%", cached_utilisation_diff);
RichString_appendnAscii(out, CRT_colors[color], buffer, len);

RichString_appendAscii(out, CRT_colors[METER_TEXT], " read: ");
Expand Down

0 comments on commit 6aa9ef2

Please sign in to comment.