From 0d12a788ad181340c5ee24045d5749f035086404 Mon Sep 17 00:00:00 2001
From: Lukas Fleischer <calcurse@cryptocrack.de>
Date: Fri, 4 Mar 2011 09:28:18 +0100
Subject: Simplify print_in_middle() in "utils.c".

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
---
 src/utils.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

(limited to 'src')

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);
-- 
cgit v1.2.3-70-g09d2