Compare commits
5 Commits
e36f7d5964
...
build/mult
| Author | SHA1 | Date | |
|---|---|---|---|
| 886372caac | |||
| 0b0b02d6e0 | |||
| d748ffc527 | |||
|
fac1e224bc
|
|||
|
6ad8a19053
|
@@ -5,6 +5,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
autoconf \
|
||||
autoconf-archive \
|
||||
automake \
|
||||
ca-certificates \
|
||||
expect \
|
||||
gcc \
|
||||
git \
|
||||
@@ -36,7 +37,7 @@ RUN mkdir -p /usr/src/{stabber,libstrophe,profanity}
|
||||
WORKDIR /usr/src
|
||||
|
||||
#RUN git clone https://github.com/boothj5/stabber
|
||||
RUN git clone -c http.sslverify=false https://github.com/strophe/libstrophe
|
||||
RUN git clone --depth 1 https://git.jabber.space/devs/libstrophe-gh.git libstrophe
|
||||
|
||||
#WORKDIR /usr/src/stabber
|
||||
#RUN ./bootstrap.sh
|
||||
@@ -47,7 +48,7 @@ RUN git clone -c http.sslverify=false https://github.com/strophe/libstrophe
|
||||
WORKDIR /usr/src/libstrophe
|
||||
RUN ./bootstrap.sh
|
||||
RUN ./configure --prefix=/usr
|
||||
RUN make
|
||||
RUN make -j$(nproc)
|
||||
RUN make install
|
||||
|
||||
WORKDIR /usr/src/profanity
|
||||
|
||||
@@ -9,6 +9,7 @@ RUN dnf install -y \
|
||||
autoconf-archive \
|
||||
automake \
|
||||
awk \
|
||||
ca-certificates \
|
||||
expect-devel \
|
||||
gcc \
|
||||
git \
|
||||
@@ -56,11 +57,11 @@ WORKDIR /usr/src
|
||||
|
||||
WORKDIR /usr/src
|
||||
RUN mkdir -p /usr/src/libstrophe
|
||||
RUN git clone -c http.sslverify=false https://github.com/strophe/libstrophe
|
||||
RUN git clone --depth 1 https://git.jabber.space/devs/libstrophe-gh.git libstrophe
|
||||
WORKDIR /usr/src/libstrophe
|
||||
RUN ./bootstrap.sh
|
||||
RUN ./configure --prefix=/usr
|
||||
RUN make
|
||||
RUN make -j$(nproc)
|
||||
RUN make install
|
||||
|
||||
RUN mkdir -p /usr/src/profanity
|
||||
|
||||
@@ -6,6 +6,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
autoconf \
|
||||
autoconf-archive \
|
||||
automake \
|
||||
ca-certificates \
|
||||
expect \
|
||||
gcc \
|
||||
git \
|
||||
@@ -37,7 +38,7 @@ RUN mkdir -p /usr/src/{stabber,libstrophe,profanity}
|
||||
WORKDIR /usr/src
|
||||
|
||||
#RUN git clone https://github.com/boothj5/stabber
|
||||
RUN git clone -c http.sslverify=false https://github.com/strophe/libstrophe
|
||||
RUN git clone --depth 1 https://git.jabber.space/devs/libstrophe-gh.git libstrophe
|
||||
|
||||
# TODO: Re-enable once libmicrohttpd-dev has been updated.
|
||||
#WORKDIR /usr/src/stabber
|
||||
@@ -49,7 +50,7 @@ RUN git clone -c http.sslverify=false https://github.com/strophe/libstrophe
|
||||
WORKDIR /usr/src/libstrophe
|
||||
RUN ./bootstrap.sh
|
||||
RUN ./configure --prefix=/usr
|
||||
RUN make
|
||||
RUN make -j$(nproc)
|
||||
RUN make install
|
||||
|
||||
WORKDIR /usr/src/profanity
|
||||
|
||||
@@ -121,11 +121,11 @@ esac
|
||||
case "$ARCH" in
|
||||
linux*)
|
||||
echo
|
||||
echo "--> Building with ./configure ${tests[0]} --enable-valgrind $*"
|
||||
echo "--> Building with ./configure -C ${tests[0]} --enable-valgrind $*"
|
||||
echo
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
./configure ${tests[0]} --enable-valgrind $*
|
||||
./configure -C ${tests[0]} --enable-valgrind $*
|
||||
|
||||
$MAKE CC="${CC}"
|
||||
if grep '^ID=' /etc/os-release | grep -q -e debian; then
|
||||
@@ -140,11 +140,11 @@ esac
|
||||
for features in "${tests[@]}"
|
||||
do
|
||||
echo
|
||||
echo "--> Building with ./configure ${features} $*"
|
||||
echo "--> Building with ./configure -C ${features} $*"
|
||||
echo
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
./configure $features $*
|
||||
./configure -C $features $*
|
||||
|
||||
$MAKE CC="${CC}"
|
||||
$MAKE check
|
||||
|
||||
@@ -1,40 +1,36 @@
|
||||
/*
|
||||
* buffer.c
|
||||
* vim: expandtab:ts=4:sts=4:sw=4
|
||||
*
|
||||
* Message buffer implementation for CProof.
|
||||
*
|
||||
* This module provides an in-memory buffer for managing active chat entries in the
|
||||
* console-based XMPP client. Separate from persistent SQLite storage, it holds
|
||||
* messages and metadata solely for UI rendering, ensuring responsive scrolling and
|
||||
* display without exceeding ncurses pad limits (10k lines). By tracking rendered
|
||||
* line counts per entry, it proactively trims content to prevent overflow, enabling
|
||||
* seamless integration with ncurses for position-aware rendering.
|
||||
*
|
||||
* Key features and operations:
|
||||
* - Append/prepend entries (messages) with automatic line-based cleanup.
|
||||
* - Track cumulative lines for overflow prevention and efficient buffer sizing.
|
||||
* - Remove entries by ID or index; mark delivery receipts as received.
|
||||
* - Retrieve entries by index or ID for rendering and history queries.
|
||||
* - Store metadata including timestamps, senders, themes, and ncurses y-positions.
|
||||
*
|
||||
* CProof. Fork of Profanity (since 2025).
|
||||
*
|
||||
* Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
|
||||
* Copyright (C) 2019 - 2025 Michael Vetter <jubalh@iodoru.org>
|
||||
* Copyright (C) 2025 CProof Developers
|
||||
*
|
||||
* This file is part of Profanity.
|
||||
*
|
||||
* Profanity is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Profanity is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Profanity. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give permission to
|
||||
* link the code of portions of this program with the OpenSSL library under
|
||||
* certain conditions as described in each individual source file, and
|
||||
* distribute linked combinations including the two.
|
||||
*
|
||||
* You must obey the GNU General Public License in all respects for all of the
|
||||
* code used other than OpenSSL. If you modify file(s) with this exception, you
|
||||
* may extend this exception to your version of the file(s), but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version. If you delete this exception statement from all
|
||||
* source files in the program, then also delete it here.
|
||||
* Licensed under the GNU General Public License, version 3,
|
||||
* with the OpenSSL exception. See LICENSE for details.
|
||||
*
|
||||
* vim: expandtab:ts=4:sts=4:sw=4
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "ui/window_list.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -54,15 +50,8 @@
|
||||
#include "ui/window.h"
|
||||
#include "ui/buffer.h"
|
||||
|
||||
#define MAX_BUFFER_SIZE 200
|
||||
#define STRDUP_OR_NULL(str) ((str) ? strdup(str) : NULL)
|
||||
|
||||
struct prof_buff_t
|
||||
{
|
||||
GSList* entries;
|
||||
int lines;
|
||||
};
|
||||
|
||||
static void _free_entry(ProfBuffEntry* entry);
|
||||
static ProfBuffEntry* _create_entry(const char* show_char, int pad_indent, GDateTime* time, int flags, theme_item_t theme_item, const char* const display_from, const char* const from_jid, const char* const message, DeliveryReceipt* receipt, const char* const id, int y_start_pos, int y_end_pos);
|
||||
static void _buffer_add(ProfBuff buffer, const char* show_char, int pad_indent, GDateTime* time, int flags, theme_item_t theme_item, const char* const display_from, const char* const from_jid, const char* const message, DeliveryReceipt* receipt, const char* const id, int y_start_pos, int y_end_pos, gboolean append);
|
||||
@@ -108,23 +97,24 @@ _buffer_add(ProfBuff buffer, const char* show_char, int pad_indent, GDateTime* t
|
||||
|
||||
buffer->lines += e->_lines;
|
||||
|
||||
while (g_slist_length(buffer->entries) >= MAX_BUFFER_SIZE) {
|
||||
// With 10% margin to ensure overflow prevention
|
||||
while (buffer->lines >= PAD_SIZE - (PAD_SIZE / 10) && g_slist_length(buffer->entries) > 1) {
|
||||
// Delete message from the opposite size to free buffer
|
||||
GSList* buffer_entry_to_delete = append ? buffer->entries : g_slist_last(buffer->entries);
|
||||
ProfBuffEntry* entry_to_delete = (ProfBuffEntry*)buffer_entry_to_delete->data;
|
||||
// log_debug("(Messages left in buffer: %d) DELETING: %s", g_slist_length(buffer->entries), entry_to_delete->id);
|
||||
buffer->lines -= entry_to_delete->_lines;
|
||||
_free_entry(entry_to_delete);
|
||||
buffer->entries = g_slist_delete_link(buffer->entries, buffer_entry_to_delete);
|
||||
}
|
||||
|
||||
if (from_jid && y_end_pos == y_start_pos) {
|
||||
log_warning("Ncurses Overflow! From: %s, position: %d, ID: %s, append: %s, used message buffer size: %d, message buffer size: %d, rendered lines buffer size: %d",
|
||||
from_jid, y_start_pos, id, append ? "TRUE" : "FALSE", g_slist_length(buffer->entries), MAX_BUFFER_SIZE, PAD_SIZE);
|
||||
// At this point we have a message that caused overflow of the render buffer.
|
||||
// Ideally, we want to clean other messages to rerender everything properly. To do so,
|
||||
// first we need to determine the size of the message that we are trying to display,
|
||||
// then we need to print the message.
|
||||
// However, _buffer_add is too late in the code to do this, therefore it has to be done in the win_print_old_history.
|
||||
// win_redraw will redraw with entries above removed,
|
||||
// it will also recalculate actual size of the message that caused overflow
|
||||
int old_lines = buffer->lines;
|
||||
win_redraw(wins_get_current());
|
||||
log_debug("Ncurses Overflow! From: %s, position: %d, ID: %s, append: %s, used message buffer size: %d, rendered lines: (old: %d/ actual: %d/ max: %d)",
|
||||
from_jid, y_start_pos, id, append ? "TRUE" : "FALSE", g_slist_length(buffer->entries), old_lines, buffer->lines, PAD_SIZE);
|
||||
}
|
||||
|
||||
buffer->entries = append ? g_slist_append(buffer->entries, e) : g_slist_prepend(buffer->entries, e);
|
||||
|
||||
@@ -68,6 +68,12 @@ typedef struct prof_buff_entry_t
|
||||
char* id;
|
||||
} ProfBuffEntry;
|
||||
|
||||
struct prof_buff_t
|
||||
{
|
||||
GSList* entries;
|
||||
int lines;
|
||||
};
|
||||
|
||||
typedef struct prof_buff_t* ProfBuff;
|
||||
|
||||
ProfBuff buffer_create();
|
||||
|
||||
@@ -2003,6 +2003,10 @@ win_redraw(ProfWin* window)
|
||||
_win_print_internal(window, e->show_char, e->pad_indent, e->time, e->flags, e->theme_item, e->display_from, e->message, e->receipt);
|
||||
}
|
||||
e->y_end_pos = getcury(window->layout->win);
|
||||
// Recalculate lines (might be incorrect in case of NCurses overflow)
|
||||
window->layout->buffer->lines -= e->_lines;
|
||||
e->_lines = e->y_end_pos - e->y_start_pos;
|
||||
window->layout->buffer->lines += e->_lines;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user