InfoBox: scroll to the last inserted line reliably
need to use a text mark; we can simplify this task somewhat by exploiting the fact that the text cursor is a default defined text mark
This commit is contained in:
parent
2d2a549341
commit
ee67e4914c
2 changed files with 55 additions and 5 deletions
|
|
@ -63,9 +63,9 @@ namespace panel{
|
|||
scroller_.set_shadow_type (Gtk::SHADOW_NONE);
|
||||
scroller_.set_border_width (10);
|
||||
|
||||
scroller_.add (textLog_);
|
||||
// the vertical scrollbar will always be necessary....
|
||||
scroller_.set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
|
||||
scroller_.add (textLog_);
|
||||
|
||||
textLog_.set_editable (false);
|
||||
|
||||
|
|
@ -95,9 +95,16 @@ namespace panel{
|
|||
|
||||
static uint bangNo{0};
|
||||
static _Fmt msgTemplate{"Bang #%d\n"};
|
||||
|
||||
// According to the Gtkmm tutorial, TextView::scroll_to(iter) is not reliable;
|
||||
// rather we need to use a text mark and set that text mark to the insert position.
|
||||
// Actually, there is always one predefined text mark called "insert", which corresponds
|
||||
// to the text cursor. Thus it suffices to navigate to text end, insert and scroll into view.
|
||||
auto buff = textLog_.get_buffer();
|
||||
auto pos = buff->insert (buff->end(), ustring{msgTemplate % ++bangNo});
|
||||
textLog_.scroll_to (pos);
|
||||
auto cursor = buff->get_insert();
|
||||
buff->move_mark (cursor, buff->end());
|
||||
buff->insert (buff->end(), ustring{msgTemplate % ++bangNo});
|
||||
textLog_.scroll_to (cursor);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1391,15 +1391,29 @@
|
|||
<node CREATED="1504203746239" ID="ID_697660682" MODIFIED="1504203776630" TEXT="Scroll-Pane">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node CREATED="1504203749815" ID="ID_1057483680" MODIFIED="1504203782093" STYLE="fork" TEXT="Textanzeige-Box">
|
||||
<node CREATED="1504203749815" ID="ID_1057483680" MODIFIED="1504220218336" STYLE="fork" TEXT="Textanzeige-Box">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1504215911647" ID="ID_1066629131" MODIFIED="1504215914707" TEXT="GtkTextView"/>
|
||||
<node CREATED="1504215958961" ID="ID_55797578" LINK="https://developer.gnome.org/gtkmm-tutorial/stable/sec-textview-buffer.html.en#textview-formatting" MODIFIED="1504215966443" TEXT="Formattierung">
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
<node CREATED="1504219859389" ID="ID_653669269" MODIFIED="1504220132294" TEXT="Scrollen zum zuletzt eingefügten Text">
|
||||
<arrowlink COLOR="#9bbabd" DESTINATION="ID_429138159" ENDARROW="Default" ENDINCLINATION="-1413;0;" ID="Arrow_ID_1025095859" STARTARROW="None" STARTINCLINATION="-1151;202;"/>
|
||||
<icon BUILTIN="idea"/>
|
||||
<node CREATED="1504220139416" ID="ID_1997485219" MODIFIED="1504220211965" TEXT="scroll_to(iterator) funktioniert nicht">
|
||||
<icon BUILTIN="stop-sign"/>
|
||||
</node>
|
||||
<node CREATED="1504220198880" ID="ID_1877499848" MODIFIED="1504220208979" TEXT="muß Marke verwenden">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1504216221389" ID="ID_355253225" MODIFIED="1504216223713" TEXT="Marks">
|
||||
<node CREATED="1504216224349" ID="ID_1372118244" MODIFIED="1504216245727" TEXT="was ist die "insert"-Mark?">
|
||||
<icon BUILTIN="help"/>
|
||||
</node>
|
||||
<node CREATED="1504219835536" ID="ID_1720205947" MODIFIED="1504219841735" TEXT="der Text-Cursor">
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1504203754175" ID="ID_580465154" MODIFIED="1504203763065" TEXT="Fehler-Level erkennen"/>
|
||||
|
|
@ -18527,9 +18541,35 @@
|
|||
</html>
|
||||
</richcontent>
|
||||
</node>
|
||||
<node CREATED="1504215825762" ID="ID_429138159" MODIFIED="1504215831637" TEXT="zur letzten Zeile scrollen">
|
||||
<node CREATED="1504215825762" ID="ID_429138159" MODIFIED="1504220029652" TEXT="zur letzten Zeile scrollen">
|
||||
<linktarget COLOR="#9bbabd" DESTINATION="ID_429138159" ENDARROW="Default" ENDINCLINATION="-1413;0;" ID="Arrow_ID_1025095859" SOURCE="ID_653669269" STARTARROW="None" STARTINCLINATION="-1151;202;"/>
|
||||
<node CREATED="1504220167228" ID="ID_622474093" MODIFIED="1504220186708" TEXT="scroll_to(iterator) ist ungenau">
|
||||
<icon BUILTIN="broken-line"/>
|
||||
</node>
|
||||
<node CREATED="1504215849336" ID="ID_832996389" MODIFIED="1504215853816" TEXT="Marker setzen">
|
||||
<icon BUILTIN="idea"/>
|
||||
<node CREATED="1504220053691" ID="ID_905781900" MODIFIED="1504220060382" TEXT="benannt oder anonym"/>
|
||||
<node CREATED="1504220061178" ID="ID_474843943" MODIFIED="1504220121853" TEXT=""Gravity" beachten">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<ul>
|
||||
<li>
|
||||
left gravity: Marker bleibt beim Einfügen an dieser Stelle links von der Einfügung stehen
|
||||
</li>
|
||||
<li>
|
||||
right gravity: Marker wird durch Einfügen an dieser Stelle nach rechts geschoben
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
Beachte: der Text-Cursor (Marker "insert") hat right gravity
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1504215832746" ID="ID_751207346" LINK="https://developer.gnome.org/gtkmm-tutorial/stable/sec-multithread-example.html.en" MODIFIED="1504215873156">
|
||||
<richcontent TYPE="NODE"><html>
|
||||
|
|
@ -18547,6 +18587,9 @@
|
|||
</html>
|
||||
</richcontent>
|
||||
</node>
|
||||
<node CREATED="1504219929260" ID="ID_1037649590" MODIFIED="1504219963912" TEXT="Trick: Cursor ist ein Marker namens "insert"">
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
|
|||
Loading…
Reference in a new issue