@@ -189,6 +189,10 @@ screen_reset(Screen *self) {
189189 self -> last_graphic_char = 0 ;
190190 self -> main_savepoint .is_valid = false;
191191 self -> alt_savepoint .is_valid = false;
192+ if (self -> extra_cursors .count ) {
193+ self -> extra_cursors .count = 0 ;
194+ self -> extra_cursors .dirty = true;
195+ }
192196 linebuf_clear (self -> linebuf , BLANK_CHAR );
193197 historybuf_clear (self -> historybuf );
194198 clear_hyperlink_pool (self -> hyperlink_pool );
@@ -673,6 +677,7 @@ dealloc(Screen* self) {
673677 free_hyperlink_pool (self -> hyperlink_pool );
674678 free (self -> as_ansi_buf .buf );
675679 free (self -> last_rendered_window_char .canvas );
680+ free (self -> extra_cursors .locations ); free (self -> paused_rendering .extra_cursors .locations );
676681 if (self -> lc ) { cleanup_list_of_chars (self -> lc ); free (self -> lc ); self -> lc = NULL ; }
677682 Py_TYPE (self )-> tp_free ((PyObject * )self );
678683} // }}}
@@ -1546,6 +1551,10 @@ screen_toggle_screen_buffer(Screen *self, bool save_cursor, bool clear_alt_scree
15461551 self -> is_dirty = true;
15471552 grman_mark_layers_dirty (self -> grman );
15481553 clear_all_selections (self );
1554+ if (self -> extra_cursors .count ) {
1555+ self -> extra_cursors .count = 0 ;
1556+ self -> extra_cursors .dirty = true;
1557+ }
15491558 global_state .check_for_active_animated_images = true;
15501559}
15511560
@@ -2475,6 +2484,10 @@ screen_erase_in_display(Screen *self, unsigned int how, bool private) {
24752484 /* fallthrough */
24762485 case 2 :
24772486 case 3 :
2487+ if (self -> extra_cursors .count ) {
2488+ self -> extra_cursors .count = 0 ;
2489+ self -> extra_cursors .dirty = true;
2490+ }
24782491 grman_clear (self -> grman , how == 3 , self -> cell_size );
24792492 a = 0 ; b = self -> lines ; nuke_multicell_chars = false;
24802493 break ;
@@ -3079,8 +3092,11 @@ screen_pause_rendering(Screen *self, bool pause, int for_in_ms) {
30793092 self -> is_dirty = true;
30803093 // ensure selection data is updated on GPU
30813094 self -> selections .last_rendered_count = SIZE_MAX ; self -> url_ranges .last_rendered_count = SIZE_MAX ;
3095+ self -> extra_cursors .dirty = true;
30823096 // free grman data
30833097 grman_pause_rendering (NULL , self -> paused_rendering .grman );
3098+ // free extra cursors
3099+ free (self -> paused_rendering .extra_cursors .locations ); zero_at_ptr (& self -> paused_rendering .extra_cursors );
30843100 return true;
30853101 }
30863102 if (self -> paused_rendering .expires_at ) return false;
@@ -3107,6 +3123,14 @@ screen_pause_rendering(Screen *self, bool pause, int for_in_ms) {
31073123 }
31083124 copy_selections (& self -> paused_rendering .selections , & self -> selections );
31093125 copy_selections (& self -> paused_rendering .url_ranges , & self -> url_ranges );
3126+ if (self -> extra_cursors .count ) {
3127+ self -> paused_rendering .extra_cursors .locations = calloc (self -> extra_cursors .count , sizeof (self -> extra_cursors .locations [0 ]));
3128+ if (self -> paused_rendering .extra_cursors .locations ) {
3129+ self -> paused_rendering .extra_cursors .count = self -> extra_cursors .count ;
3130+ self -> paused_rendering .extra_cursors .dirty = self -> extra_cursors .dirty ;
3131+ memcpy (self -> paused_rendering .extra_cursors .locations , self -> extra_cursors .locations , sizeof (self -> extra_cursors .locations [0 ]) * self -> extra_cursors .count );
3132+ }
3133+ }
31103134 grman_pause_rendering (self -> grman , self -> paused_rendering .grman );
31113135 return true;
31123136}
@@ -3558,7 +3582,13 @@ screen_apply_selection(Screen *self, void *address, size_t size) {
35583582 if (OPT (underline_hyperlinks ) == UNDERLINE_NEVER && s -> is_hyperlink ) continue ;
35593583 apply_selection (self , address , s , 2 );
35603584 }
3585+ uint8_t * a = address ;
35613586 sel -> last_rendered_count = sel -> count ;
3587+ ExtraCursors * ec = self -> paused_rendering .expires_at ? & self -> paused_rendering .extra_cursors : & self -> extra_cursors ;
3588+ for (unsigned i = 0 ; i < ec -> count ; i ++ ) {
3589+ if (ec -> locations [i ].cell < size ) a [ec -> locations [i ].cell ] |= (ec -> locations [i ].shape & 7 ) << 2 ;
3590+ }
3591+ ec -> dirty = false;
35623592}
35633593
35643594static index_type
@@ -4804,7 +4834,7 @@ screen_is_selection_dirty(Screen *self) {
48044834 IterationData q ;
48054835 if (self -> paused_rendering .expires_at ) return false;
48064836 if (self -> scrolled_by != self -> last_rendered .scrolled_by ) return true;
4807- if (self -> selections .last_rendered_count != self -> selections .count || self -> url_ranges .last_rendered_count != self -> url_ranges .count ) return true;
4837+ if (self -> selections .last_rendered_count != self -> selections .count || self -> url_ranges .last_rendered_count != self -> url_ranges .count || self -> extra_cursors . dirty ) return true;
48084838 for (size_t i = 0 ; i < self -> selections .count ; i ++ ) {
48094839 iteration_data (self -> selections .items + i , & q , self -> columns , 0 , self -> scrolled_by );
48104840 if (memcmp (& q , & self -> selections .items [i ].last_rendered , sizeof (IterationData )) != 0 ) return true;
0 commit comments