[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#419947: [newt] Characters in titlebar are sometimes unbalanced



Package: cdebconf-newt-udeb
Version: 0.115
Severity: minor
Tags: patch

The attached patch makes sure characters surrounding the title are always even
(see also #416543).

I've tested it mainly on show_select_window() using the ad-hoc
config/template files attached which create a title of the form
"[title_len....]" so that it is possible to verify that the title is
never cut (it always ends with "]").

regards,
Davide


-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.18-1-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Index: src/modules/frontend/newt/newt.c
===================================================================
--- src/modules/frontend/newt/newt.c	(revision 46471)
+++ src/modules/frontend/newt/newt.c	(working copy)
@@ -183,11 +183,11 @@
             if (asprintf(&buf, "[%s] %s", sigils[i][1], title) == -1)
                 buf = NULL;
     }
-    if (buf != NULL) {
-        newtCenteredWindow(width, height, buf);
+    if (buf != NULL) {		/* Make sure borders surrounding the title are always balanced */
+        newtCenteredWindow(width - (((width - strlen(buf))%2)?1:0), height, buf);
         free(buf);
     } else {
-        newtCenteredWindow(width, height, title);
+        newtCenteredWindow(width - (((width - strlen(title))%2)?1:0), height, title);
     }
 }
 
#!/bin/sh -e
# Test for titlebar at different sizes both at "critical"
# and "high" prioriy (sigil is respectively "[!!]" and "[!]")

. /usr/share/debconf/confmodule

fixed_pattern="[]"
fixed_len=$(echo ${#fixed_pattern})

x="...................................................................................................."


for i in $(seq 4 8) ; do
    len=$(( ${#fixed_pattern} + ${#i} ))
    title="$(echo "[${i}${x:0:$(( ${i} - ${len} ))}]")"

    for prio in "high" "critical" ; do
	db_title "${title}"
	db_fset longselect/select seen false
	db_input ${prio} longselect/select || true
	db_go
    done

done
Template: longselect/select
Type: select
Choices: test 01, test 02, test 03
Description: Descrizione
 Descrizione lunga

Template: test-help/boolean
Type: boolean
Default: true
Description: Enter a boolean value
 domanda booleana.

Attachment: signature.asc
Description: Digital signature


Reply to: