lib_util.c (b319d934379f5b819cd195be7e03dbd407566fd4) lib_util.c (84823cc70824c8d842f503d8c2e6d7b0c2d95b61)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2021-2022 Alfonso Sabato Siciliano
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 907 unchanged lines hidden (view full) ---

916
917 if ((maxheight = widget_max_height(conf)) == BSDDIALOG_ERROR)
918 return (BSDDIALOG_ERROR);
919
920 if (rows == BSDDIALOG_FULLSCREEN)
921 *h = maxheight;
922 else if (rows < BSDDIALOG_FULLSCREEN)
923 RETURN_ERROR("Negative (less than -1) height");
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2021-2022 Alfonso Sabato Siciliano
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 907 unchanged lines hidden (view full) ---

916
917 if ((maxheight = widget_max_height(conf)) == BSDDIALOG_ERROR)
918 return (BSDDIALOG_ERROR);
919
920 if (rows == BSDDIALOG_FULLSCREEN)
921 *h = maxheight;
922 else if (rows < BSDDIALOG_FULLSCREEN)
923 RETURN_ERROR("Negative (less than -1) height");
924 else if (rows > BSDDIALOG_AUTOSIZE) {
925 if ((*h = rows) > maxheight)
926 RETURN_ERROR("Height too big (> terminal height - "
927 "shadow)");
928 }
924 else if (rows > BSDDIALOG_AUTOSIZE) /* fixed rows */
925 *h = MIN(rows, maxheight); /* rows is at most maxheight */
929 /* rows == AUTOSIZE: each widget has to set its size */
930
931 if ((maxwidth = widget_max_width(conf)) == BSDDIALOG_ERROR)
932 return (BSDDIALOG_ERROR);
933
934 if (cols == BSDDIALOG_FULLSCREEN)
935 *w = maxwidth;
936 else if (cols < BSDDIALOG_FULLSCREEN)
937 RETURN_ERROR("Negative (less than -1) width");
926 /* rows == AUTOSIZE: each widget has to set its size */
927
928 if ((maxwidth = widget_max_width(conf)) == BSDDIALOG_ERROR)
929 return (BSDDIALOG_ERROR);
930
931 if (cols == BSDDIALOG_FULLSCREEN)
932 *w = maxwidth;
933 else if (cols < BSDDIALOG_FULLSCREEN)
934 RETURN_ERROR("Negative (less than -1) width");
938 else if (cols > BSDDIALOG_AUTOSIZE) {
939 if ((*w = cols) > maxwidth)
940 RETURN_ERROR("Width too big (> terminal width - "
941 "shadow)");
942 }
935 else if (cols > BSDDIALOG_AUTOSIZE) /* fixed cols */
936 *w = MIN(cols, maxwidth); /* cols is at most maxwidth */
943 /* cols == AUTOSIZE: each widget has to set its size */
944
945 return (0);
946}
947
948int
949set_widget_position(struct bsddialog_conf *conf, int *y, int *x, int h, int w)
950{

--- 260 unchanged lines hidden ---
937 /* cols == AUTOSIZE: each widget has to set its size */
938
939 return (0);
940}
941
942int
943set_widget_position(struct bsddialog_conf *conf, int *y, int *x, int h, int w)
944{

--- 260 unchanged lines hidden ---