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 364 Lines • ▼ Show 20 Line(s) | 443 | { | |||
484 | 486 | | |||
485 | // this is an important optimization, it tells Qt | 487 | // this is an important optimization, it tells Qt | ||
486 | // that TerminalDisplay will handle repainting its entire area. | 488 | // that TerminalDisplay will handle repainting its entire area. | ||
487 | setAttribute(Qt::WA_OpaquePaintEvent); | 489 | setAttribute(Qt::WA_OpaquePaintEvent); | ||
488 | 490 | | |||
489 | // Add the stretch item once, the KMessageWidgets are inserted at index 0. | 491 | // Add the stretch item once, the KMessageWidgets are inserted at index 0. | ||
490 | _verticalLayout->addStretch(); | 492 | _verticalLayout->addStretch(); | ||
491 | _verticalLayout->setSpacing(0); | 493 | _verticalLayout->setSpacing(0); | ||
492 | | ||||
493 | setLayout(_verticalLayout); | 494 | setLayout(_verticalLayout); | ||
494 | 495 | | |||
495 | // Take the scrollbar into account and add a margin to the layout. Without the timer the scrollbar width | 496 | // Take the scrollbar into account and add a margin to the layout. Without the timer the scrollbar width | ||
496 | // is garbage. | 497 | // is garbage. | ||
497 | QTimer::singleShot(0, this, [this]() { | 498 | QTimer::singleShot(0, this, [this]() { | ||
498 | const int scrollBarWidth = _scrollBar->isVisible() ? geometry().intersected(_scrollBar->geometry()).width() : 0; | 499 | const int scrollBarWidth = _scrollBar->isVisible() ? geometry().intersected(_scrollBar->geometry()).width() : 0; | ||
499 | _verticalLayout->setContentsMargins(0, 0, scrollBarWidth, 0); | 500 | _verticalLayout->setContentsMargins(0, 0, scrollBarWidth, 0); | ||
500 | }); | 501 | }); | ||
▲ Show 20 Lines • Show All 3428 Lines • ▼ Show 20 Line(s) | 3901 | { | |||
3929 | } | 3930 | } | ||
3930 | default: | 3931 | default: | ||
3931 | break; | 3932 | break; | ||
3932 | }; | 3933 | }; | ||
3933 | 3934 | | |||
3934 | return false; | 3935 | return false; | ||
3935 | } | 3936 | } | ||
3936 | 3937 | | |||
3938 | QScrollBar *TerminalDisplay::scrollBar() const { | ||||
3939 | return _scrollBar; | ||||
3940 | } | ||||
3941 | | ||||
3942 | TerminalWidget::TerminalWidget(int sessionId, QWidget *parent) : | ||||
3943 | QWidget(parent), | ||||
3944 | _terminalDisplay(new TerminalDisplay(this)), | ||||
3945 | _searchBar(new IncrementalSearchBar(this)) | ||||
3946 | { | ||||
3947 | _searchBar->setVisible(false); | ||||
3948 | | ||||
3949 | auto *vLayout = new QVBoxLayout(); | ||||
3950 | vLayout->addWidget(_terminalDisplay); | ||||
3951 | vLayout->setSpacing(0); | ||||
3952 | vLayout->setMargin(0); | ||||
3953 | setLayout(vLayout); | ||||
3954 | _terminalDisplay->setRandomSeed(sessionId * 31); | ||||
3955 | adjustSize(); | ||||
3956 | repositionSearchBar(geometry().size()); | ||||
3957 | } | ||||
3958 | | ||||
3959 | void TerminalWidget::repositionSearchBar(QSize size) | ||||
3960 | { | ||||
3961 | const auto width = _searchBar->geometry().width(); | ||||
3962 | const auto height = _searchBar->geometry().height(); | ||||
3963 | const auto x = size.width() - width - _terminalDisplay->scrollBar()->geometry().width(); | ||||
3964 | _searchBar->setGeometry(x, 0, width, height); | ||||
3965 | } | ||||
3966 | | ||||
3967 | void TerminalWidget::focusInEvent(QFocusEvent *event) | ||||
3968 | { | ||||
3969 | _terminalDisplay->setFocus(); | ||||
3970 | } | ||||
3971 | | ||||
3972 | void TerminalWidget::resizeEvent(QResizeEvent *event) | ||||
3973 | { | ||||
3974 | repositionSearchBar(event->size()); | ||||
3975 | } | ||||
3976 | | ||||
3977 | TerminalDisplay *TerminalWidget::terminalDisplay() const { | ||||
3978 | return _terminalDisplay; | ||||
3979 | } | ||||
3980 | | ||||
3981 | IncrementalSearchBar *TerminalWidget::searchBar() const { | ||||
3982 | return _searchBar; | ||||
3983 | } |