aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-03-04 09:28:18 +0100
committerLukas Fleischer <calcurse@cryptocrack.de>2011-03-04 09:28:18 +0100
commit0d12a788ad181340c5ee24045d5749f035086404 (patch)
tree58603e80a922e22da8a10e2dab9ca161a79b9a62 /src/utils.c
parent4b8558ed47a0633017fd44505e8f7aecf81cadec (diff)
downloadcalcurse-0d12a788ad181340c5ee24045d5749f035086404.tar.gz
calcurse-0d12a788ad181340c5ee24045d5749f035086404.zip
Simplify print_in_middle() in "utils.c".
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/utils.c b/src/utils.c
index 28a7891..d4210c1 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -212,22 +212,17 @@ popup (int pop_row, int pop_col, int pop_y, int pop_x, char *title, char *msg,
void
print_in_middle (WINDOW *win, int starty, int startx, int width, char *string)
{
- int length, x, y;
- float temp;
+ int len = strlen (string);
+ int x, y;
- if (win == NULL)
- win = stdscr;
+ if (!win) win = stdscr;
getyx (win, y, x);
- if (startx != 0)
- x = startx;
- if (starty != 0)
- y = starty;
- if (width == 0)
- width = 80;
-
- length = strlen (string);
- temp = (width - length) / 2;
- x = startx + (int) temp;
+ if (startx) x = startx;
+ if (starty) y = starty;
+ if (!width) width = 80;
+
+ x += (width - len) / 2;
+
custom_apply_attr (win, ATTR_HIGHEST);
mvwprintw (win, y, x, "%s", string);
custom_remove_attr (win, ATTR_HIGHEST);