Added paging #4
4
menu.c
4
menu.c
@ -40,7 +40,7 @@ void get_console_dimensions(int* width, int* height)
|
||||
*height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
|
||||
}
|
||||
|
||||
void page(const struct MenuPage *pages, const size_t page_count) {
|
||||
void page(const struct MenuPage *pages, const size_t page_count, const bool infinite_loop) {
|
||||
unsigned int page_index = 0;
|
||||
bool action_performed, loop, pageChanged = true;
|
||||
char pageKey, itemKey;
|
||||
@ -87,7 +87,7 @@ void page(const struct MenuPage *pages, const size_t page_count) {
|
||||
} while (loop || pageChanged);
|
||||
|
||||
page_index = 0;
|
||||
} while (1);
|
||||
} while (infinite_loop);
|
||||
}
|
||||
|
||||
void show_menu(const int itemc, const struct MenuItem itemv[], const char title[], const struct MenuBorder *border)
|
||||
|
11
menu.h
11
menu.h
@ -3,7 +3,6 @@
|
||||
#include "pch.h"
|
||||
|
||||
|
||||
|
||||
/// <summary>Represents one menu item in a menu.</summary>
|
||||
struct MenuItem {
|
||||
char* text;
|
||||
@ -11,8 +10,6 @@ struct MenuItem {
|
||||
void* (*action)(void);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// <summary>Represents a border in which a menu is displayed.</summary>
|
||||
struct MenuBorder {
|
||||
char line_vertical;
|
||||
@ -27,6 +24,7 @@ struct MenuBorder {
|
||||
|
||||
const extern struct MenuBorder DEFAULT, MODERN, NO_BORDER, SOLID;
|
||||
|
||||
|
||||
/// <summary>Represents a page in the menu.</summary>
|
||||
struct MenuPage {
|
||||
const struct MenuItem* items;
|
||||
@ -36,6 +34,13 @@ struct MenuPage {
|
||||
const struct MenuBorder* border;
|
||||
};
|
||||
|
||||
|
||||
/// <summary>Constructs a menu with a specific amount of pages</summary>
|
||||
/// <param name="pages">An array of all pages to display.</param>
|
||||
/// <param name="page_count">The length of the array <c>pages</c>.</param>
|
||||
/// <param name="infinite_loop">Always display the first page after a loopback=false item finished executing.</param>
|
||||
void page(const struct MenuPage* pages, const size_t page_count, const bool infinite_loop);
|
||||
|
||||
/// <summary>Displaces a CUI menu to the user</summary>
|
||||
/// <param name="itemc">The length of the array <c>itemv</c> of menu items.</param>
|
||||
/// <param name="itemv">An array of all menu items to display in the menu.</param>
|
||||
|
Reference in New Issue
Block a user