Skip to content

Commit 5ab7159

Browse files
committed
notifications+files OCS (mobile-shell#1144)
1 parent 39175c6 commit 5ab7159

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

src/terminal/terminaldisplay.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,28 @@ std::string Display::new_frame( bool initialized, const Framebuffer& last, const
111111
}
112112
frame.append( '\007' );
113113
}
114+
/* has notification changed? */
115+
if (f.get_notification() != frame.last_frame.get_notification()) {
116+
frame.append( "\033]" );
117+
const title_type &notification( f.get_notification() );
118+
for ( title_type::const_iterator i = notification.begin();
119+
i != notification.end();
120+
i++ ) {
121+
frame.append( *i );
122+
}
123+
frame.append( '\007' );
124+
}
125+
/* has sendfile changed? */
126+
if (f.get_sendfile() != frame.last_frame.get_sendfile()) {
127+
frame.append( "\033]1337;" );
128+
const title_type &sendfile( f.get_sendfile() );
129+
for ( title_type::const_iterator i = sendfile.begin();
130+
i != sendfile.end();
131+
i++ ) {
132+
frame.append( *i );
133+
}
134+
frame.append( '\007' );
135+
}
114136

115137
/* has reverse video state changed? */
116138
if ( ( !initialized ) || ( f.ds.reverse_video != frame.last_frame.ds.reverse_video ) ) {

src/terminal/terminalframebuffer.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ DrawState::DrawState( int s_width, int s_height )
7474

7575
Framebuffer::Framebuffer( int s_width, int s_height )
7676
: rows(), icon_name(), window_title(), clipboard(), bell_count( 0 ), title_initialized( false ),
77+
notification(), sendfile(),
7778
clipboard_seqnum( 0 ),
7879
ds( s_width, s_height )
7980
{
@@ -87,6 +88,7 @@ Framebuffer::Framebuffer( int s_width, int s_height )
8788
Framebuffer::Framebuffer( const Framebuffer& other )
8889
: rows( other.rows ), icon_name( other.icon_name ), window_title( other.window_title ),
8990
clipboard( other.clipboard ), bell_count( other.bell_count ), title_initialized( other.title_initialized ),
91+
notification( other.notification ), sendfile( other.sendfile ),
9092
clipboard_seqnum( other.clipboard_seqnum ),
9193
ds( other.ds )
9294
{}
@@ -100,6 +102,8 @@ Framebuffer& Framebuffer::operator=( const Framebuffer& other )
100102
clipboard = other.clipboard;
101103
bell_count = other.bell_count;
102104
title_initialized = other.title_initialized;
105+
notification = other.notification;
106+
sendfile = other.sendfile;
103107
clipboard_seqnum = other.clipboard_seqnum;
104108
ds = other.ds;
105109
}
@@ -382,6 +386,8 @@ void Framebuffer::reset( void )
382386
ds = DrawState( width, height );
383387
rows = rows_type( height, newrow() );
384388
window_title.clear();
389+
notification.clear();
390+
sendfile.clear();
385391
clipboard.clear();
386392
clipboard_seqnum = 0;
387393
/* do not reset bell_count */

src/terminal/terminalframebuffer.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@ class Framebuffer
406406
title_type clipboard;
407407
unsigned int bell_count;
408408
bool title_initialized; /* true if the window title has been set via an OSC */
409+
title_type notification;
410+
title_type sendfile;
409411
uint8_t clipboard_seqnum;
410412

411413
row_pointer newrow( void )
@@ -484,10 +486,14 @@ class Framebuffer
484486
void set_icon_name( const title_type& s ) { icon_name = s; }
485487
void set_window_title( const title_type& s ) { window_title = s; }
486488
void set_clipboard( const title_type& s ) { clipboard = s; clipboard_seqnum++; } // Rolling over 255 -> 0 is okay
489+
void set_notification( const title_type &s ) { notification = s; }
490+
void set_sendfile( const title_type &s ) { sendfile = s; }
487491
uint8_t get_clipboard_seqnum ( void ) const { return clipboard_seqnum; }
488492
const title_type& get_icon_name( void ) const { return icon_name; }
489493
const title_type& get_window_title( void ) const { return window_title; }
490494
const title_type& get_clipboard( void ) const { return clipboard; }
495+
const title_type & get_notification( void ) const { return notification; }
496+
const title_type & get_sendfile( void ) const { return sendfile; }
491497

492498
void prefix_window_title( const title_type& s );
493499

@@ -502,6 +508,7 @@ class Framebuffer
502508
bool operator==( const Framebuffer& x ) const
503509
{
504510
return ( rows == x.rows ) && ( window_title == x.window_title ) && ( clipboard == x.clipboard )
511+
&& ( notification == x.notification ) && ( sendfile == x.sendfile )
505512
&& ( clipboard_seqnum == x.clipboard_seqnum )
506513
&& ( bell_count == x.bell_count ) && ( ds == x.ds );
507514
}

src/terminal/terminalfunctions.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,23 @@ void Dispatcher::OSC_dispatch( const Parser::OSC_End* act __attribute( ( unused
663663
capture this part */
664664
Terminal::Framebuffer::title_type clipboard( OSC_string.begin() + 3, OSC_string.end() );
665665
fb->set_clipboard( clipboard );
666+
} else if ( OSC_string.size() >= 2 && OSC_string[0] == L'9' &&
667+
OSC_string[1] == L';') {
668+
Terminal::Framebuffer::title_type notification(
669+
OSC_string.begin(), OSC_string.end() );
670+
fb->set_notification( notification );
671+
} else if ( OSC_string.size() >= 4 && OSC_string[0] == L'7' &&
672+
OSC_string[1] == L'7' && OSC_string[2] == L'7' &&
673+
OSC_string[3] == L';') {
674+
Terminal::Framebuffer::title_type notification(
675+
OSC_string.begin(), OSC_string.end() );
676+
fb->set_notification( notification );
677+
} else if ( OSC_string.size() >= 5 && OSC_string[0] == L'1' &&
678+
OSC_string[1] == L'3' && OSC_string[2] == L'3' &&
679+
OSC_string[3] == L'7' && OSC_string[4] == L';') {
680+
Terminal::Framebuffer::title_type sendfile(
681+
OSC_string.begin() + 5, OSC_string.end() );
682+
fb->set_sendfile( sendfile );
666683
/* handle osc terminal title sequence */
667684
} else if ( OSC_string.size() >= 1 ) {
668685
long cmd_num = -1;

0 commit comments

Comments
 (0)