Skip to content

Commit

Permalink
TabBar: use struct Window instead of WINDOW*
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Aug 30, 2024
1 parent 25980e9 commit eb73e5f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
27 changes: 14 additions & 13 deletions src/TabBar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,35 @@
#include "Bindings.hxx"
#include "GlobalBindings.hxx"
#include "i18n.h"
#include "Window.hxx"

static void
PaintPageTab(WINDOW *w, Command cmd, const char *label, bool selected) noexcept
PaintPageTab(const Window window, Command cmd, const char *label, bool selected) noexcept
{
SelectStyle(w, selected ? Style::TITLE : Style::TITLE_BOLD);
SelectStyle(window.w, selected ? Style::TITLE : Style::TITLE_BOLD);
if (selected)
wattron(w, A_REVERSE);
window.AttributeOn(A_REVERSE);

waddch(w, ' ');
window.Char(' ');

const char *key = GetGlobalKeyBindings().GetFirstKeyName(cmd);
if (key != nullptr)
waddstr(w, key);
window.String(key);

SelectStyle(w, Style::TITLE);
SelectStyle(window.w, Style::TITLE);
if (selected)
wattron(w, A_REVERSE);
window.AttributeOn(A_REVERSE);

waddch(w, ':');
waddstr(w, label);
waddch(w, ' ');
window.Char(':');
window.String(label);
window.Char(' ');

if (selected)
wattroff(w, A_REVERSE);
window.AttributeOff(A_REVERSE);
}

void
PaintTabBar(WINDOW *w, const PageMeta &current_page_meta,
PaintTabBar(const Window window, const PageMeta &current_page_meta,
const char *current_page_title) noexcept
{
for (unsigned i = 0;; ++i) {
Expand All @@ -50,7 +51,7 @@ PaintTabBar(WINDOW *w, const PageMeta &current_page_meta,
if (title == nullptr)
title = my_gettext(page->title);

PaintPageTab(w, page->command, title,
PaintPageTab(window, page->command, title,
page == &current_page_meta);
}
}
10 changes: 3 additions & 7 deletions src/TabBar.hxx
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright The Music Player Daemon Project

#ifndef NCMPC_TAB_BAR_HXX
#define NCMPC_TAB_BAR_HXX

#include <curses.h>
#pragma once

struct Window;
struct PageMeta;

void
PaintTabBar(WINDOW *w, const PageMeta &current_page_meta,
PaintTabBar(Window window, const PageMeta &current_page_meta,
const char *current_page_title) noexcept;

#endif
2 changes: 1 addition & 1 deletion src/TitleBar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ TitleBar::Paint(const PageMeta &current_page_meta,

#ifndef NCMPC_MINI
if (options.welcome_screen_list) {
PaintTabBar(w, current_page_meta, title);
PaintTabBar(window, current_page_meta, title);
} else {
#else
(void)current_page_meta;
Expand Down

0 comments on commit eb73e5f

Please sign in to comment.