]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/entry.cpp
Make sure that at least one line of text is always rendered
[libs/gltk.git] / source / entry.cpp
index 654ac6c673f17025917f72ad1af4bf0cdcde0631..3fa4c91bb36423d64e10986bafcd156e995fdf28 100644 (file)
@@ -27,6 +27,7 @@ Entry::Entry(const Resources &r, const string &t):
        multiline(false),
        edit_pos(0),
        first_row(0),
+       visible_rows(1),
        text_part(0),
        slider(0)
 {
@@ -187,7 +188,7 @@ void Entry::check_view_range()
        unsigned line_spacing = static_cast<unsigned>(font_size*6/5);
 
        const Sides &margin = text_part->get_margin();
-       visible_rows = (geom.h-margin.top-margin.bottom)/line_spacing;
+       visible_rows = max((geom.h-margin.top-margin.bottom)/line_spacing, 1U);
 
        unsigned row, col;
        text.offset_to_coords(edit_pos, row, col);