diff --git a/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp b/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp --- a/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp +++ b/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp @@ -969,9 +969,30 @@ m_consoleRect.setWidth (winSize.width () / fm.averageCharWidth ()); m_consoleRect.setHeight (winSize.height () / fm.lineSpacing ()); - m_bufferSize.rwidth () = m_consoleRect.width (); - m_bufferSize.rheight () = qMax (m_bufferSize.height (), - m_consoleRect.height ()); + // Don't shrink the size of the buffer. That way wide lines won't be + // truncated and will reappear if the window is enlarged again later. + + if (m_consoleRect.width () > m_bufferSize.width ()) + m_bufferSize.rwidth () = m_consoleRect.width (); + + if (qMax (m_bufferSize.height (), m_consoleRect.height ()) + > m_bufferSize.height ()) + m_bufferSize.rheight () = qMax (m_bufferSize.height (), + m_consoleRect.height ()); + + // Store the terminal size in the environment. When Octave is + // initialized, we ask the command editor (usually readline) to prefer + // using these values rather than querying the terminal so that the + // buffer size can be larger than the size of the window that the + // command editor will actually use. + + qputenv ("LINES", QByteArray::number (m_consoleRect.height ())); + qputenv ("COLUMNS", QByteArray::number (m_consoleRect.width ())); + + // Force the command line editor (usually readline) to notice the + // change in screen size as soon as possible. + + q->set_screen_size (m_consoleRect.height (), m_consoleRect.width ()); m_consoleRect.moveLeft (0); if (m_consoleRect.bottom () >= m_bufferSize.height ()) @@ -1333,6 +1354,9 @@ connect (this, SIGNAL (set_global_shortcuts_signal (bool)), parent, SLOT (set_global_shortcuts (bool))); + connect (this, SIGNAL (set_screen_size_signal (int, int)), + parent, SLOT (set_screen_size (int, int))); + setAcceptDrops (true); } @@ -1727,3 +1751,9 @@ } } +void QWinTerminalImpl::set_screen_size (int ht, int wd) +{ + d->log ("emit set_screen_size (%d, %d)\n", ht, wd); + + emit set_screen_size_signal (ht, wd); +} diff --git a/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.h b/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.h --- a/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.h +++ b/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.h @@ -76,6 +76,7 @@ void terminated (void); void titleChanged (const QString&); void set_global_shortcuts_signal (bool); + void set_screen_size_signal (int, int); protected: void viewPaintEvent (QConsoleView*, QPaintEvent*); @@ -98,6 +99,8 @@ void dragEnterEvent(QDragEnterEvent *event); void dropEvent(QDropEvent *event); + void set_screen_size (int ht, int wd); + private slots: void scrollValueChanged (int value); void monitorConsole (void); diff --git a/libinterp/corefcn/sysdep.cc b/libinterp/corefcn/sysdep.cc --- a/libinterp/corefcn/sysdep.cc +++ b/libinterp/corefcn/sysdep.cc @@ -169,13 +169,21 @@ { w32_set_quiet_shutdown (); } + +static void +w32_init (void) +{ + w32_set_octave_home (); + + command_editor::prefer_env_winsize (true); +} #endif #if defined (__MINGW32__) static void MINGW_init (void) { - w32_set_octave_home (); + w32_init (); } #endif @@ -183,7 +191,7 @@ static void MSVC_init (void) { - w32_set_octave_home (); + w32_init (); } #endif