Skip to content

Commit

Permalink
notifications+files OCS (mobile-shell#1144)
Browse files Browse the repository at this point in the history
  • Loading branch information
msva committed Jun 17, 2024
1 parent 39175c6 commit 5ab7159
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/terminal/terminaldisplay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,28 @@ std::string Display::new_frame( bool initialized, const Framebuffer& last, const
}
frame.append( '\007' );
}
/* has notification changed? */
if (f.get_notification() != frame.last_frame.get_notification()) {
frame.append( "\033]" );
const title_type &notification( f.get_notification() );
for ( title_type::const_iterator i = notification.begin();
i != notification.end();
i++ ) {
frame.append( *i );
}
frame.append( '\007' );
}
/* has sendfile changed? */
if (f.get_sendfile() != frame.last_frame.get_sendfile()) {
frame.append( "\033]1337;" );
const title_type &sendfile( f.get_sendfile() );
for ( title_type::const_iterator i = sendfile.begin();
i != sendfile.end();
i++ ) {
frame.append( *i );
}
frame.append( '\007' );
}

/* has reverse video state changed? */
if ( ( !initialized ) || ( f.ds.reverse_video != frame.last_frame.ds.reverse_video ) ) {
Expand Down
6 changes: 6 additions & 0 deletions src/terminal/terminalframebuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ DrawState::DrawState( int s_width, int s_height )

Framebuffer::Framebuffer( int s_width, int s_height )
: rows(), icon_name(), window_title(), clipboard(), bell_count( 0 ), title_initialized( false ),
notification(), sendfile(),
clipboard_seqnum( 0 ),
ds( s_width, s_height )
{
Expand All @@ -87,6 +88,7 @@ Framebuffer::Framebuffer( int s_width, int s_height )
Framebuffer::Framebuffer( const Framebuffer& other )
: rows( other.rows ), icon_name( other.icon_name ), window_title( other.window_title ),
clipboard( other.clipboard ), bell_count( other.bell_count ), title_initialized( other.title_initialized ),
notification( other.notification ), sendfile( other.sendfile ),
clipboard_seqnum( other.clipboard_seqnum ),
ds( other.ds )
{}
Expand All @@ -100,6 +102,8 @@ Framebuffer& Framebuffer::operator=( const Framebuffer& other )
clipboard = other.clipboard;
bell_count = other.bell_count;
title_initialized = other.title_initialized;
notification = other.notification;
sendfile = other.sendfile;
clipboard_seqnum = other.clipboard_seqnum;
ds = other.ds;
}
Expand Down Expand Up @@ -382,6 +386,8 @@ void Framebuffer::reset( void )
ds = DrawState( width, height );
rows = rows_type( height, newrow() );
window_title.clear();
notification.clear();
sendfile.clear();
clipboard.clear();
clipboard_seqnum = 0;
/* do not reset bell_count */
Expand Down
7 changes: 7 additions & 0 deletions src/terminal/terminalframebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ class Framebuffer
title_type clipboard;
unsigned int bell_count;
bool title_initialized; /* true if the window title has been set via an OSC */
title_type notification;
title_type sendfile;
uint8_t clipboard_seqnum;

row_pointer newrow( void )
Expand Down Expand Up @@ -484,10 +486,14 @@ class Framebuffer
void set_icon_name( const title_type& s ) { icon_name = s; }
void set_window_title( const title_type& s ) { window_title = s; }
void set_clipboard( const title_type& s ) { clipboard = s; clipboard_seqnum++; } // Rolling over 255 -> 0 is okay
void set_notification( const title_type &s ) { notification = s; }
void set_sendfile( const title_type &s ) { sendfile = s; }
uint8_t get_clipboard_seqnum ( void ) const { return clipboard_seqnum; }
const title_type& get_icon_name( void ) const { return icon_name; }
const title_type& get_window_title( void ) const { return window_title; }
const title_type& get_clipboard( void ) const { return clipboard; }
const title_type & get_notification( void ) const { return notification; }
const title_type & get_sendfile( void ) const { return sendfile; }

void prefix_window_title( const title_type& s );

Expand All @@ -502,6 +508,7 @@ class Framebuffer
bool operator==( const Framebuffer& x ) const
{
return ( rows == x.rows ) && ( window_title == x.window_title ) && ( clipboard == x.clipboard )
&& ( notification == x.notification ) && ( sendfile == x.sendfile )
&& ( clipboard_seqnum == x.clipboard_seqnum )
&& ( bell_count == x.bell_count ) && ( ds == x.ds );
}
Expand Down
17 changes: 17 additions & 0 deletions src/terminal/terminalfunctions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,23 @@ void Dispatcher::OSC_dispatch( const Parser::OSC_End* act __attribute( ( unused
capture this part */
Terminal::Framebuffer::title_type clipboard( OSC_string.begin() + 3, OSC_string.end() );
fb->set_clipboard( clipboard );
} else if ( OSC_string.size() >= 2 && OSC_string[0] == L'9' &&
OSC_string[1] == L';') {
Terminal::Framebuffer::title_type notification(
OSC_string.begin(), OSC_string.end() );
fb->set_notification( notification );
} else if ( OSC_string.size() >= 4 && OSC_string[0] == L'7' &&
OSC_string[1] == L'7' && OSC_string[2] == L'7' &&
OSC_string[3] == L';') {
Terminal::Framebuffer::title_type notification(
OSC_string.begin(), OSC_string.end() );
fb->set_notification( notification );
} else if ( OSC_string.size() >= 5 && OSC_string[0] == L'1' &&
OSC_string[1] == L'3' && OSC_string[2] == L'3' &&
OSC_string[3] == L'7' && OSC_string[4] == L';') {
Terminal::Framebuffer::title_type sendfile(
OSC_string.begin() + 5, OSC_string.end() );
fb->set_sendfile( sendfile );
/* handle osc terminal title sequence */
} else if ( OSC_string.size() >= 1 ) {
long cmd_num = -1;
Expand Down

0 comments on commit 5ab7159

Please sign in to comment.