Auto-scroll ConversationView, fix RunView append

This commit is contained in:
Jaidyn Ann 2021-07-21 12:10:20 -05:00
parent 20c6b9fc30
commit 9245dc7135
2 changed files with 10 additions and 5 deletions

View File

@ -136,9 +136,9 @@ ConversationView::ImMessage(BMessage* msg)
case IM_MESSAGE_SENT:
case IM_LOGS_RECEIVED:
{
_AppendOrEnqueueMessage(msg);
if (im_what == IM_MESSAGE_SENT)
fReceiveView->ScrollToBottom();
_AppendOrEnqueueMessage(msg);
break;
}
case IM_ROOM_JOINED:
@ -146,12 +146,14 @@ ConversationView::ImMessage(BMessage* msg)
BMessage msg;
msg.AddString("body", "** You joined the room.\n");
_AppendOrEnqueueMessage(&msg);
fReceiveView->ScrollToBottom();
}
case IM_ROOM_CREATED:
{
BMessage msg;
msg.AddString("body", "** You created the room.\n");
_AppendOrEnqueueMessage(&msg);
fReceiveView->ScrollToBottom();
}
case IM_ROOM_PARTICIPANT_JOINED:
{
@ -373,6 +375,7 @@ ConversationView::_UserMessage(const char* format, const char* bodyFormat,
BMessage newMsg;
newMsg.AddString("body", newBody);
_AppendOrEnqueueMessage(&newMsg);
fReceiveView->ScrollToBottom();
}

View File

@ -9,7 +9,6 @@
#include <Locale.h>
#include <MenuItem.h>
#include <PopUpMenu.h>
#include <ScrollBar.h>
#include <TextView.h>
#include <Window.h>
@ -98,18 +97,21 @@ RunView::Insert(const char* text, const text_run_array* runs)
if (lastEnd < specStart) {
BString normie;
buf.CopyCharsInto(normie, lastEnd, specStart - lastEnd);
BTextView::Insert(normie.String(), runs);
BTextView::Insert(TextLength(), normie.String(), normie.Length(),
runs);
}
BString special;
buf.CopyCharsInto(special, specStart, specEnd - specStart);
BTextView::Insert(special.String(), &fUrlRun);
BTextView::Insert(TextLength(), special.String(), special.Length(),
&fUrlRun);
lastEnd = specEnd;
}
if (lastEnd < length) {
BString remaining;
buf.CopyCharsInto(remaining, lastEnd, length - lastEnd);
BTextView::Insert(remaining.String(), runs);
BTextView::Insert(TextLength(), remaining.String(), remaining.Length(),
runs);
}
}