Skip to content

Commit ce1eb91

Browse files
committed
Addressing last review comments
1 parent a5145d5 commit ce1eb91

5 files changed

Lines changed: 17 additions & 15 deletions

File tree

src/terminal/terminaldisplay.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,7 @@ bool Display::put_row( bool initialized,
388388
frame.append_silent_move( frame_y, frame_x - clear_count );
389389
frame.update_rendition( blank_renditions );
390390
frame.update_hyperlink( blank_hyperlink );
391-
bool can_use_erase
392-
= has_bce || ( frame.current_rendition == initial_rendition() && frame.current_hyperlink.empty() );
393-
if ( can_use_erase && has_ech && clear_count > 4 ) {
391+
if ( can_use_erase( frame ) && has_ech && clear_count > 4 ) {
394392
snprintf( tmp, 64, "\033[%dX", clear_count );
395393
frame.append( tmp );
396394
} else {
@@ -442,9 +440,7 @@ bool Display::put_row( bool initialized,
442440
frame.update_rendition( blank_renditions );
443441
frame.update_hyperlink( blank_hyperlink );
444442

445-
bool can_use_erase
446-
= has_bce || ( frame.current_rendition == initial_rendition() && frame.current_hyperlink.empty() );
447-
if ( can_use_erase && !wrap_this ) {
443+
if ( can_use_erase( frame ) && !wrap_this ) {
448444
frame.append( "\033[K" );
449445
} else {
450446
frame.append( clear_count, ' ' );
@@ -472,6 +468,11 @@ bool Display::put_row( bool initialized,
472468
return false;
473469
}
474470

471+
bool Display::can_use_erase( const FrameState& frame ) const
472+
{
473+
return has_bce || ( frame.current_rendition == initial_rendition() && frame.current_hyperlink.empty() );
474+
}
475+
475476
FrameState::FrameState( const Framebuffer& s_last )
476477
: str(), cursor_x( 0 ), cursor_y( 0 ), current_rendition( 0 ), current_hyperlink(),
477478
cursor_visible( s_last.ds.cursor_visible ), last_frame( s_last )

src/terminal/terminaldisplay.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ class Display
8383
const Row& old_row,
8484
bool wrap ) const;
8585

86+
bool can_use_erase( const FrameState& frame ) const;
87+
8688
public:
8789
std::string open() const;
8890
std::string close() const;

src/terminal/terminalframebuffer.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ std::string Renditions::sgr( void ) const
606606

607607
bool Hyperlink::operator==( const Hyperlink& x ) const
608608
{
609-
if ( rep == nullptr && x.rep == nullptr ) {
609+
if ( rep == x.rep ) {
610610
return true;
611611
}
612612
if ( rep == nullptr || x.rep == nullptr ) {
@@ -621,14 +621,12 @@ std::string Hyperlink::osc8() const
621621
std::string ret;
622622

623623
ret.append( "\033]8;" );
624-
if ( empty() ) {
625-
ret.append( ";\033\\" );
626-
return ret;
627-
}
628624

629-
ret.append( rep->params );
625+
if ( *this )
626+
ret.append( rep->params );
630627
ret.append( ";" );
631-
ret.append( rep->url );
628+
if ( *this )
629+
ret.append( rep->url );
632630

633631
ret.append( "\033\\" );
634632
return ret;

src/terminal/terminalframebuffer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class Hyperlink
110110
std::string osc8() const;
111111

112112
bool empty() const { return rep == nullptr; }
113+
operator bool() const { return !empty(); }
113114

114115
bool operator==( const Hyperlink& x ) const;
115116

src/terminal/terminalfunctions.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,8 @@ static void OSC_8( const std::string& OSC_string, Framebuffer* fb )
619619
return;
620620
}
621621

622-
fb->ds.set_hyperlink(
623-
Hyperlink( OSC_string.substr( 2, second_semicolon - 2 ), OSC_string.substr( second_semicolon + 1 ) ) );
622+
std::string url = OSC_string.substr( second_semicolon + 1 );
623+
fb->ds.set_hyperlink( Hyperlink( OSC_string.substr( 2, second_semicolon - 2 ), std::move( url ) ) );
624624
}
625625

626626
/* xterm uses an Operating System Command to set the window title */

0 commit comments

Comments
 (0)