Skip to content

Commit 234358b

Browse files
committed
Resolve conflicts
2 parents 1105d48 + b0eb2e5 commit 234358b

5 files changed

+59
-7
lines changed

src/terminal/terminaldisplay.cc

+14-1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ std::string Display::new_frame( bool initialized, const Framebuffer& last, const
142142
frame.append( "\033[?25l" );
143143
}
144144

145+
/* is cursor style initialized? */
146+
if ( !initialized ) {
147+
frame.cursor_style = Terminal::CursorStyle::BLINKING_BLOCK;
148+
frame.append( "\033[0 q" );
149+
}
150+
145151
int frame_y = 0;
146152
Framebuffer::row_pointer blank_row;
147153
Framebuffer::rows_type rows( frame.last_frame.get_rows() );
@@ -267,6 +273,13 @@ std::string Display::new_frame( bool initialized, const Framebuffer& last, const
267273
}
268274
}
269275

276+
/* has cursor style changed? */
277+
if ( ( !initialized ) || ( f.ds.cursor_style != frame.cursor_style ) ) {
278+
char cursor_style_sequence_buf[6];
279+
snprintf( cursor_style_sequence_buf, sizeof cursor_style_sequence_buf, "\033[%d q", f.ds.cursor_style );
280+
frame.append( cursor_style_sequence_buf );
281+
}
282+
270283
/* have renditions changed? */
271284
frame.update_rendition( f.ds.get_renditions(), !initialized );
272285

@@ -460,7 +473,7 @@ bool Display::put_row( bool initialized,
460473

461474
FrameState::FrameState( const Framebuffer& s_last )
462475
: str(), cursor_x( 0 ), cursor_y( 0 ), current_rendition( 0 ), cursor_visible( s_last.ds.cursor_visible ),
463-
last_frame( s_last )
476+
cursor_style( s_last.ds.cursor_style ), last_frame( s_last )
464477
{
465478
/* Preallocate for better performance. Make a guess-- doesn't matter for correctness */
466479
str.reserve( last_frame.ds.get_width() * last_frame.ds.get_height() * 4 );

src/terminal/terminaldisplay.h

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class FrameState
4545
int cursor_x, cursor_y;
4646
Renditions current_rendition;
4747
bool cursor_visible;
48+
int cursor_style;
4849

4950
const Framebuffer& last_frame;
5051

src/terminal/terminalframebuffer.cc

+6-4
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ void DrawState::reinitialize_tabs( unsigned int start )
6262
DrawState::DrawState( int s_width, int s_height )
6363
: width( s_width ), height( s_height ), cursor_col( 0 ), cursor_row( 0 ), combining_char_col( 0 ),
6464
combining_char_row( 0 ), default_tabs( true ), tabs( s_width ), scrolling_region_top_row( 0 ),
65-
scrolling_region_bottom_row( height - 1 ), renditions( 0 ), save(), next_print_will_wrap( false ),
66-
origin_mode( false ), auto_wrap_mode( true ), insert_mode( false ), cursor_visible( true ),
67-
reverse_video( false ), bracketed_paste( false ), mouse_reporting_mode( MOUSE_REPORTING_NONE ),
68-
mouse_focus_event( false ), mouse_alternate_scroll( false ), mouse_encoding_mode( MOUSE_ENCODING_DEFAULT ),
65+
scrolling_region_bottom_row( height - 1 ), renditions( 0 ), save(),
66+
cursor_style( Terminal::CursorStyle::BLINKING_BLOCK ), next_print_will_wrap( false ), origin_mode( false ),
67+
auto_wrap_mode( true ), insert_mode( false ), cursor_visible( true ), reverse_video( false ),
68+
bracketed_paste( false ), mouse_reporting_mode( MOUSE_REPORTING_NONE ), mouse_focus_event( false ),
69+
mouse_alternate_scroll( false ), mouse_encoding_mode( MOUSE_ENCODING_DEFAULT ),
6970
application_mode_cursor_keys( false )
7071
{
7172
reinitialize_tabs( 0 );
@@ -387,6 +388,7 @@ void Framebuffer::soft_reset( void )
387388
ds.insert_mode = false;
388389
ds.origin_mode = false;
389390
ds.cursor_visible = true; /* per xterm and gnome-terminal */
391+
ds.cursor_style = Terminal::CursorStyle::BLINKING_BLOCK;
390392
ds.application_mode_cursor_keys = false;
391393
ds.set_scrolling_region( 0, ds.get_height() - 1 );
392394
ds.add_rendition( 0 );

src/terminal/terminalframebuffer.h

+17-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,21 @@
4545
/* Terminal framebuffer */
4646

4747
namespace Terminal {
48+
using std::make_shared;
49+
using std::shared_ptr;
4850
using color_type = uint32_t;
4951

52+
enum CursorStyle
53+
{
54+
BLINKING_BLOCK = 0,
55+
BLINKING_BLOCK_DEFAULT = 1,
56+
STEADY_BLOCK = 2,
57+
BLINKING_UNDERLINE = 3,
58+
STEADY_UNDERLINE = 4,
59+
BLINKING_BAR = 5,
60+
STEADY_BAR = 6,
61+
};
62+
5063
class Renditions
5164
{
5265
public:
@@ -275,6 +288,7 @@ class DrawState
275288
SavedCursor save;
276289

277290
public:
291+
int cursor_style;
278292
bool next_print_will_wrap;
279293
bool origin_mode;
280294
bool auto_wrap_mode;
@@ -353,8 +367,9 @@ class DrawState
353367
return ( width == x.width ) && ( height == x.height ) && ( cursor_col == x.cursor_col )
354368
&& ( cursor_row == x.cursor_row ) && ( cursor_visible == x.cursor_visible )
355369
&& ( reverse_video == x.reverse_video ) && ( renditions == x.renditions )
356-
&& ( bracketed_paste == x.bracketed_paste ) && ( mouse_reporting_mode == x.mouse_reporting_mode )
357-
&& ( mouse_focus_event == x.mouse_focus_event ) && ( mouse_alternate_scroll == x.mouse_alternate_scroll )
370+
&& ( cursor_style == x.cursor_style ) && ( bracketed_paste == x.bracketed_paste )
371+
&& ( mouse_reporting_mode == x.mouse_reporting_mode ) && ( mouse_focus_event == x.mouse_focus_event )
372+
&& ( mouse_alternate_scroll == x.mouse_alternate_scroll )
358373
&& ( mouse_encoding_mode == x.mouse_encoding_mode );
359374
}
360375
};

src/terminal/terminalfunctions.cc

+21
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,27 @@ static void clearline( Framebuffer* fb, int row, int start, int end )
5151
}
5252
}
5353

54+
/* cursor style */
55+
static void CSI_DECSCUSR( Framebuffer* fb, Dispatcher* dispatch )
56+
{
57+
int style = dispatch->getparam( 0, 0 );
58+
switch ( style ) {
59+
case 0:
60+
case 1:
61+
case 2:
62+
case 3:
63+
case 4:
64+
case 5:
65+
case 6:
66+
fb->ds.cursor_style = style;
67+
break;
68+
default:
69+
break;
70+
}
71+
}
72+
73+
static Function func_CSI_DECSCUSR( CSI, " q", CSI_DECSCUSR );
74+
5475
/* erase in line */
5576
static void CSI_EL( Framebuffer* fb, Dispatcher* dispatch )
5677
{

0 commit comments

Comments
 (0)