| 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 | 
 | 
| 15 | int 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 | 
 | 
| 24 | int centery() { | 
| 25 |     int y = (LINES / 2); | 
| 26 |     return y; | 
| 27 | } | 
| 28 | 
 |