Index

ncurses-minesweeper / 48085a2

Terminal game of Minesweeper, implemented in C with ncurses.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
4817 Oct 2021 18:26c10793dUpdate repository endpoint in comment blocksJosh Stockin111G

Blob @ ncurses-minesweeper / src / draw / text.c

text/plain786 bytesdownload raw
1/* ncurses-minesweeper Copyright (c) 2021 Joshua 'joshuas3' Stockin
2 * <https://joshstock.in>
3 * <https://git.joshstock.in/ncurses-minesweeper>
4 *
5 * This software is licensed and distributed under the terms of the MIT License.
6 * See the MIT License in the LICENSE file of this project's root folder.
7 *
8 * This comment block and its contents, including this disclaimer, MUST be
9 * preserved in all copies or distributions of this software's source.
10 */
11
12#include <ncurses.h>
13#include <string.h>
14
15int centerx(const char* txt) { // try to return the best X value to center string txt in view
16 size_t ln = strlen(txt);
17 int x = (int)(COLS / 2) - (int)(ln / 2);
18 if (x > 0)
19 return x;
20 else
21 return 0;
22}
23
24int centery() {
25 int y = (LINES / 2);
26 return y;
27}
28