1
0
Fork 0

Compare commits

...

4 Commits

Author SHA1 Message Date
John Hernandez 0eaf0b8ade
Merge 0f361e6b52 into c6cf27e4e1 2024-03-05 00:08:04 +11:00
Michael Vetter c6cf27e4e1
Merge pull request #1952 from H3rnand3zzz/fix/alt-underscroll
Fix underscrolling issue for alternative scrolling
2024-03-01 13:02:34 +01:00
John Hernandez 4030b0936e
Fix underscrolling issue for alternative scrolling
When user was scrolling down using alt + mouse wheel/arrows, he would be
stuck in most of the cases after the buffer finishes
due to the part of code that moves the "cursor" up to show full last page.

New algorithm considers close to border cursor as passing for
DB loading condition,
at the same time it calculates offset, allowing flexible scroll size.

The problem was introduced by  @H3rnand3zzz in the following commit:
23692fedff
2024-01-25 20:25:01 +01:00
John Hernandez 0f361e6b52
Remove maxtabs limitation for statusbar 2024-01-19 16:25:27 +01:00
4 changed files with 25 additions and 19 deletions

View File

@ -1298,7 +1298,7 @@ static const struct cmd_t command_defs[] = {
CMD_DESC(
"Manage statusbar display preferences.")
CMD_ARGS(
{ "maxtabs <value>", "Set the maximum number of tabs to display, <value> must be between 0 and 10." },
{ "maxtabs <value>", "Set the maximum number of tabs to display, <value> must be more than or equal to 0." },
{ "tablen <value>", "Set the maximum number of characters to show as the tab name, 0 sets to unlimited." },
{ "tabmode default|dynamic|actlist", "Set the mode tabs are shown. `dynamic` is a mode that displays tabs conveniently around current tab, thus providing proper pagination. `actlist` setting shows only active tabs. `default` setting always shows tabs in 1 to max_tabs range." },
{ "show|hide name", "Show or hide names in tabs." },

View File

@ -6182,11 +6182,6 @@ cmd_statusbar(ProfWin* window, const char* const command, gchar** args)
auto_char char* err_msg = NULL;
gboolean res = strtoi_range(value, &intval, 0, INT_MAX, &err_msg);
if (res) {
if (intval < 0 || intval > 10) {
cons_bad_cmd_usage(command);
return TRUE;
}
prefs_set_statusbartabs(intval);
if (intval == 0) {
cons_show("Status bar tabs disabled.");

View File

@ -77,8 +77,10 @@ typedef struct _status_bar_t
static GTimeZone* tz;
static StatusBar* statusbar;
static WINDOW* statusbar_win;
static int left_part_size;
void _get_range_bounds(int* start, int* end, gboolean is_static);
static int _get_max_tabs();
static int _status_bar_draw_time(int pos);
static int _status_bar_draw_maintext(int pos);
static int _status_bar_draw_bracket(gboolean current, int pos, const char* ch);
@ -285,11 +287,14 @@ status_bar_draw(void)
werase(statusbar_win);
wbkgd(statusbar_win, theme_attrs(THEME_STATUS_TEXT));
gint max_tabs = prefs_get_statusbartabs();
gint max_tabs = _get_max_tabs();
int pos = 1;
pos = _status_bar_draw_time(pos);
pos = _status_bar_draw_maintext(pos);
left_part_size = pos;
if (max_tabs != 0)
pos = _status_bar_draw_tabs(pos);
@ -367,7 +372,7 @@ _status_bar_draw_tabs(int pos)
static gboolean
_has_new_msgs_beyond_range_on_side(gboolean left_side, int display_tabs_start, int display_tabs_end)
{
gint max_tabs = prefs_get_statusbartabs();
gint max_tabs = _get_max_tabs();
int tabs_count = g_hash_table_size(statusbar->tabs);
if (tabs_count <= max_tabs) {
return FALSE;
@ -389,7 +394,7 @@ _has_new_msgs_beyond_range_on_side(gboolean left_side, int display_tabs_start, i
static int
_status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end, gboolean is_static)
{
gint max_tabs = prefs_get_statusbartabs();
gint max_tabs = _get_max_tabs();
if (max_tabs == 0) {
return pos;
}
@ -620,7 +625,7 @@ _tabs_width(int start, int end)
gboolean show_number = prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER);
gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
gboolean show_read = prefs_get_boolean(PREF_STATUSBAR_SHOW_READ);
gint max_tabs = prefs_get_statusbartabs();
gint max_tabs = _get_max_tabs();
guint opened_tabs = g_hash_table_size(statusbar->tabs);
int width = start < 2 ? 1 : 4;
@ -718,7 +723,7 @@ void
_get_range_bounds(int* start, int* end, gboolean is_static)
{
int current_tab = statusbar->current_tab;
gint display_range = prefs_get_statusbartabs();
gint display_range = _get_max_tabs();
int total_tabs = g_hash_table_size(statusbar->tabs);
int side_range = display_range / 2;
@ -766,3 +771,9 @@ _count_digits_in_range(int start, int end)
return total_digits;
}
static int
_get_max_tabs()
{
return MIN(prefs_get_statusbartabs(), (getmaxx(stdscr) - left_part_size) / 3);
}

View File

@ -694,7 +694,7 @@ win_page_down(ProfWin* window, int scroll_size)
*page_start += scroll_size;
// Scrolled down after reaching the bottom of the page
if ((*page_start == total_rows || (*page_start == page_space && *page_start >= total_rows)) && window->type == WIN_CHAT) {
if ((*page_start > total_rows - page_space || (*page_start == page_space && *page_start >= total_rows)) && window->type == WIN_CHAT) {
int bf_size = buffer_size(window->layout->buffer);
if (bf_size > 0) {
ProfBuffEntry* last_entry = buffer_get_entry(window->layout->buffer, bf_size - 1);
@ -708,19 +708,19 @@ win_page_down(ProfWin* window, int scroll_size)
g_date_time_unref(now);
int offset = last_entry->y_end_pos - 1;
*page_start = offset;
*page_start = offset - page_space + scroll_size;
}
}
total_rows = getcury(window->layout->win);
// only got half a screen, show full screen
if ((total_rows - (*page_start)) < page_space)
// near the end, but will display only part of the page space, move a bit back to show full page
if ((total_rows - *page_start) < page_space) {
*page_start = total_rows - page_space;
// went past end, show full screen
else if (*page_start >= total_rows)
// went past end, show last page
} else if (*page_start >= total_rows) {
*page_start = total_rows - page_space - 1;
}
window->layout->paged = 1;
@ -730,7 +730,7 @@ win_page_down(ProfWin* window, int scroll_size)
}
// switch off page if last line and space line visible
if ((total_rows) - *page_start == page_space) {
if (total_rows - *page_start == page_space) {
window->layout->paged = 0;
}
}