From 6007b4dc41fe0786871b6269c535570b89961709 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Tue, 28 Apr 2020 21:32:46 +1200 Subject: [PATCH] do not crash in a terminal < 76 columns wide for https://bugs.launchpad.net/ubuntu-z-systems/+bug/1874314 --- DESIGN.md | 8 +++++--- subiquitycore/ui/anchors.py | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 458b4d31..8447bec4 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -27,9 +27,11 @@ 3. Make the common case as easy as possible by doing things like thinking about which widget should be highlighted when a screen is first shown. -4. Subiquity is functional in an 80x24 terminal. It doesn't matter if it falls - apart in a smaller terminal and obviously you can get more information on a - larger terminal at once, but it needs to work in 80x24. +4. Subiquity is functional in an 80x24 terminal. It doesn't matter if it + becomes unusable in a smaller terminal (although it shouldn't crash, as we + support people logging in via ssh and they can resize their terminal + however they like) and obviously you can get more information on a larger + terminal at once, but it needs to work in 80x24. ### urwid specific ranting diff --git a/subiquitycore/ui/anchors.py b/subiquitycore/ui/anchors.py index 1f8f558b..6f7dbf2e 100644 --- a/subiquitycore/ui/anchors.py +++ b/subiquitycore/ui/anchors.py @@ -54,6 +54,9 @@ class HeaderColumns(Columns): center = max(int_scale(79, 101, maxcol + 1), 76) message = center - btn pad = (maxcol - center)//2 + if pad <= 0: + pad = 1 + message = maxcol - 2 - btn return [pad, message, btn, pad]