Index

ncurses-minesweeper / f87f675

Terminal game of Minesweeper, implemented in C with ncurses.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
2417 Sep 2020 22:4163b24cbFix copyright disclaimerJosh Stockin111G

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

text/plain782 bytesdownload raw
1/* ncurses-minesweeper Copyright (c) 2020 Joshua 'joshuas3' Stockin
2 * <https://joshstock.in>
3 * <https://github.com/JoshuaS3/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 - 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