Changeset View
Changeset View
Standalone View
Standalone View
src/TerminalDisplay.cpp
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | |||||
66 | #include "Screen.h" | 66 | #include "Screen.h" | ||
67 | #include "LineFont.h" | 67 | #include "LineFont.h" | ||
68 | #include "SessionController.h" | 68 | #include "SessionController.h" | ||
69 | #include "ExtendedCharTable.h" | 69 | #include "ExtendedCharTable.h" | ||
70 | #include "TerminalDisplayAccessible.h" | 70 | #include "TerminalDisplayAccessible.h" | ||
71 | #include "SessionManager.h" | 71 | #include "SessionManager.h" | ||
72 | #include "Session.h" | 72 | #include "Session.h" | ||
73 | #include "WindowSystemInfo.h" | 73 | #include "WindowSystemInfo.h" | ||
74 | #include "IncrementalSearchBar.h" | ||||
74 | 75 | | |||
75 | using namespace Konsole; | 76 | using namespace Konsole; | ||
76 | 77 | | |||
77 | #define REPCHAR "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ | 78 | #define REPCHAR "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ | ||
78 | "abcdefgjijklmnopqrstuvwxyz" \ | 79 | "abcdefgjijklmnopqrstuvwxyz" \ | ||
79 | "0123456789./+@" | 80 | "0123456789./+@" | ||
80 | 81 | | |||
81 | // we use this to force QPainter to display text in LTR mode | 82 | // we use this to force QPainter to display text in LTR mode | ||
Show All 22 Lines | 101 | /* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) | |||
104 | ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White | 105 | ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White | ||
105 | IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White | 106 | IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White | ||
106 | */ | 107 | */ | ||
107 | 108 | | |||
108 | ScreenWindow* TerminalDisplay::screenWindow() const | 109 | ScreenWindow* TerminalDisplay::screenWindow() const | ||
109 | { | 110 | { | ||
110 | return _screenWindow; | 111 | return _screenWindow; | ||
111 | } | 112 | } | ||
113 | | ||||
112 | void TerminalDisplay::setScreenWindow(ScreenWindow* window) | 114 | void TerminalDisplay::setScreenWindow(ScreenWindow* window) | ||
113 | { | 115 | { | ||
114 | // disconnect existing screen window if any | 116 | // disconnect existing screen window if any | ||
115 | if (!_screenWindow.isNull()) { | 117 | if (!_screenWindow.isNull()) { | ||
116 | disconnect(_screenWindow , nullptr , this , nullptr); | 118 | disconnect(_screenWindow , nullptr , this , nullptr); | ||
117 | } | 119 | } | ||
118 | 120 | | |||
119 | _screenWindow = window; | 121 | _screenWindow = window; | ||
▲ Show 20 Lines • Show All 365 Lines • ▼ Show 20 Line(s) | 444 | { | |||
485 | 487 | | |||
486 | // this is an important optimization, it tells Qt | 488 | // this is an important optimization, it tells Qt | ||
487 | // that TerminalDisplay will handle repainting its entire area. | 489 | // that TerminalDisplay will handle repainting its entire area. | ||
488 | setAttribute(Qt::WA_OpaquePaintEvent); | 490 | setAttribute(Qt::WA_OpaquePaintEvent); | ||
489 | 491 | | |||
490 | // Add the stretch item once, the KMessageWidgets are inserted at index 0. | 492 | // Add the stretch item once, the KMessageWidgets are inserted at index 0. | ||
491 | _verticalLayout->addStretch(); | 493 | _verticalLayout->addStretch(); | ||
492 | _verticalLayout->setSpacing(0); | 494 | _verticalLayout->setSpacing(0); | ||
493 | | ||||
494 | setLayout(_verticalLayout); | 495 | setLayout(_verticalLayout); | ||
495 | 496 | | |||
496 | // Take the scrollbar into account and add a margin to the layout. Without the timer the scrollbar width | 497 | // Take the scrollbar into account and add a margin to the layout. Without the timer the scrollbar width | ||
497 | // is garbage. | 498 | // is garbage. | ||
498 | QTimer::singleShot(0, this, [this]() { | 499 | QTimer::singleShot(0, this, [this]() { | ||
499 | const int scrollBarWidth = _scrollBar->isVisible() ? geometry().intersected(_scrollBar->geometry()).width() : 0; | 500 | const int scrollBarWidth = _scrollBar->isVisible() ? geometry().intersected(_scrollBar->geometry()).width() : 0; | ||
500 | _verticalLayout->setContentsMargins(0, 0, scrollBarWidth, 0); | 501 | _verticalLayout->setContentsMargins(0, 0, scrollBarWidth, 0); | ||
501 | }); | 502 | }); | ||
▲ Show 20 Lines • Show All 3423 Lines • ▼ Show 20 Line(s) | 3897 | { | |||
3925 | } | 3926 | } | ||
3926 | default: | 3927 | default: | ||
3927 | break; | 3928 | break; | ||
3928 | }; | 3929 | }; | ||
3929 | 3930 | | |||
3930 | return false; | 3931 | return false; | ||
3931 | } | 3932 | } | ||
3932 | 3933 | | |||
3934 | QScrollBar *TerminalDisplay::scrollBar() const { | ||||
3935 | return _scrollBar; | ||||
3936 | } | ||||
3937 | | ||||
3938 | TerminalWidget::TerminalWidget(int sessionId, QWidget *parent) : | ||||
3939 | QWidget(parent), | ||||
3940 | _terminalDisplay(new TerminalDisplay(this)), | ||||
3941 | _searchBar(new IncrementalSearchBar(this)) | ||||
3942 | { | ||||
3943 | _searchBar->setVisible(false); | ||||
3944 | | ||||
3945 | auto *vLayout = new QVBoxLayout(); | ||||
3946 | vLayout->addWidget(_terminalDisplay); | ||||
3947 | vLayout->setSpacing(0); | ||||
3948 | vLayout->setMargin(0); | ||||
3949 | setLayout(vLayout); | ||||
3950 | _terminalDisplay->setRandomSeed(sessionId * 31); | ||||
3951 | adjustSize(); | ||||
3952 | repositionSearchBar(geometry().size()); | ||||
3953 | } | ||||
3954 | | ||||
3955 | void TerminalWidget::repositionSearchBar(QSize size) | ||||
3956 | { | ||||
3957 | const auto width = _searchBar->geometry().width(); | ||||
3958 | const auto height = _searchBar->geometry().height(); | ||||
3959 | const auto x = size.width() - width - _terminalDisplay->scrollBar()->geometry().width(); | ||||
3960 | _searchBar->setGeometry(x, 0, width, height); | ||||
3961 | } | ||||
3962 | | ||||
3963 | void TerminalWidget::resizeEvent(QResizeEvent *event) | ||||
3964 | { | ||||
3965 | repositionSearchBar(event->size()); | ||||
3966 | } | ||||
3967 | | ||||
3968 | TerminalDisplay *TerminalWidget::terminalDisplay() const { | ||||
3969 | return _terminalDisplay; | ||||
3970 | } | ||||
3971 | | ||||
3972 | IncrementalSearchBar *TerminalWidget::searchBar() const { | ||||
3973 | return _searchBar; | ||||
3974 | } |