Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for OSC 9 & 777 notifications and OSC 1337 sending files #1144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/terminal/terminaldisplay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,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)
Expand Down
8 changes: 6 additions & 2 deletions src/terminal/terminalframebuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,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 ), ds( s_width, s_height )
: rows(), icon_name(), window_title(), clipboard(), notification(), sendfile(), bell_count( 0 ), title_initialized( false ), ds( s_width, s_height )
{
assert( s_height > 0 );
assert( s_width > 0 );
Expand All @@ -89,7 +89,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 ),
clipboard( other.clipboard ), notification(other.notification), sendfile(other.sendfile), bell_count( other.bell_count ),
title_initialized( other.title_initialized ), ds( other.ds )
{
}
Expand All @@ -101,6 +101,8 @@ Framebuffer & Framebuffer::operator=( const Framebuffer &other )
icon_name = other.icon_name;
window_title = other.window_title;
clipboard = other.clipboard;
notification = other.notification;
sendfile = other.sendfile;
bell_count = other.bell_count;
title_initialized = other.title_initialized;
ds = other.ds;
Expand Down Expand Up @@ -384,6 +386,8 @@ void Framebuffer::reset( void )
rows = rows_type( height, newrow() );
window_title.clear();
clipboard.clear();
notification.clear();
sendfile.clear();
/* do not reset bell_count */
}

Expand Down
8 changes: 7 additions & 1 deletion src/terminal/terminalframebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ namespace Terminal {
title_type icon_name;
title_type window_title;
title_type clipboard;
title_type notification;
title_type sendfile;
unsigned int bell_count;
bool title_initialized; /* true if the window title has been set via an OSC */

Expand Down Expand Up @@ -453,9 +455,13 @@ namespace Terminal {
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; }
void set_notification( const title_type &s ) { notification = s; }
void set_sendfile( const title_type &s ) { sendfile = s; }
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 @@ -469,7 +475,7 @@ namespace Terminal {

bool operator==( const Framebuffer &x ) const
{
return ( rows == x.rows ) && ( window_title == x.window_title ) && ( clipboard == x.clipboard ) && ( bell_count == x.bell_count ) && ( ds == x.ds );
return ( rows == x.rows ) && ( window_title == x.window_title ) && ( clipboard == x.clipboard ) && ( bell_count == x.bell_count ) && ( ds == x.ds ) && ( notification == x.notification ) && (sendfile == x.sendfile);
}
};
}
Expand Down
17 changes: 17 additions & 0 deletions src/terminal/terminalfunctions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,23 @@ void Dispatcher::OSC_dispatch( const Parser::OSC_End *act __attribute((unused)),
Terminal::Framebuffer::title_type clipboard(
OSC_string.begin() + 5, 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