Skip to content

Commit

Permalink
Merge pull request #1214 from contour-terminal/feature/config-option-…
Browse files Browse the repository at this point in the history
…size-indicator

Add config option to enable/disable size indicator on resize and make resize indicator small
  • Loading branch information
Utkarsh-khambra committed Sep 24, 2023
2 parents 5dbc034 + cf79252 commit eb1b44a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 7 deletions.
8 changes: 8 additions & 0 deletions docs/configuration/profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ profiles:
```


### `size_indicator_on_resize`
configuration option determines whether or not the size indicator will be shown when terminal will resized.
``` yaml
profiles:
profile_name:
size_indicator_on_resize: true
```


### `fullscreen`
configuration option determines whether the terminal's screen should be put into fullscreen mode when the terminal profile is activated. Fullscreen mode expands the terminal window to occupy the entire screen, providing a distraction-free environment for your terminal sessions.
Expand Down
1 change: 1 addition & 0 deletions metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
<li>Adds config option `profile.*.frozen_dec_modes` to permanently enable/disable certain DEC modes.</li>
<li>Adds capital `A` and `I` keys to switch from normal mode back to insert mode, too.</li>
<li>Adds size indicator window on resize (#1203).</li>
<li>Adds config entry `profile.*.size_indicator_on_resize` to control size indicator on resize and makes resize indicator small.</li>
</ul>
</description>
</release>
Expand Down
6 changes: 6 additions & 0 deletions src/contour/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,12 @@ namespace
logger);
tryLoadChildRelative(
usedKeys, profile, basePath, "show_title_bar", terminalProfile.show_title_bar, logger);
tryLoadChildRelative(usedKeys,
profile,
basePath,
"size_indicator_on_resize",
terminalProfile.sizeIndicatorOnResize,
logger);
tryLoadChildRelative(usedKeys,
profile,
basePath,
Expand Down
1 change: 1 addition & 0 deletions src/contour/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ struct TerminalProfile
bool maximized = false;
bool fullscreen = false;
bool show_title_bar = true;
bool sizeIndicatorOnResize = true;
bool mouse_hide_while_typing = true;
terminal::RefreshRate refreshRate = { 0.0 }; // 0=auto
terminal::LineOffset copyLastMarkRangeOffset = terminal::LineOffset(0);
Expand Down
3 changes: 3 additions & 0 deletions src/contour/TerminalSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class TerminalSession: public QAbstractItemModel, public terminal::Terminal::Eve
Q_PROPERTY(int id READ id)
Q_PROPERTY(int pageLineCount READ pageLineCount NOTIFY lineCountChanged)
Q_PROPERTY(int pageColumnsCount READ pageColumnsCount NOTIFY columnsCountChanged)
Q_PROPERTY(bool showResizeIndicator READ showResizeIndicator)
Q_PROPERTY(int historyLineCount READ historyLineCount NOTIFY historyLineCountChanged)
Q_PROPERTY(int scrollOffset READ scrollOffset WRITE setScrollOffset NOTIFY scrollOffsetChanged)
Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
Expand Down Expand Up @@ -155,6 +156,8 @@ class TerminalSession: public QAbstractItemModel, public terminal::Terminal::Eve

int pageColumnsCount() const noexcept { return unbox(_terminal.pageSize().columns); }

bool showResizeIndicator() const noexcept { return _config.profile().sizeIndicatorOnResize; }

int historyLineCount() const noexcept { return unbox(_terminal.currentScreen().historyLineCount()); }

int scrollOffset() const noexcept { return unbox(terminal().viewport().scrollOffset()); }
Expand Down
5 changes: 5 additions & 0 deletions src/contour/contour.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ profiles:
# When this profile is *activated*, this flag decides
# whether or not the title bar will be shown
show_title_bar: true

# When this profile is *activated*, this flag decides
# whether or not the size indicator on resize will be shown.
size_indicator_on_resize: true

# When this profile is being *activated*, this flag decides
# whether or not to put the terminal's screen into fullscreen mode.
#
Expand Down
11 changes: 4 additions & 7 deletions src/contour/ui.template/Terminal.qml.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ ContourTerminal
anchors.centerIn: parent
border.width: 1
border.color: "black"
property int minWidth: 70
property int minHeight: 30
width: vtWidget.width * 0.1 < minWidth ? minWidth : vtWidget.width * 0.1
height: vtWidget.height * 0.1 < minHeight ? minHeight : vtWidget.height * 0.1
property int margin: 10
color: "white"
visible : false
focus : false
Expand Down Expand Up @@ -178,11 +175,13 @@ ContourTerminal
}

function updateSizeWidget() {
if (vtWidget.session.upTime > 1.0)
if (vtWidget.session.upTime > 1.0 && vtWidget.session.showResizeIndicator)
{
sizeWidget.visible = true
sizeWidgetTimer.running = true
sizeWidgetText.text = "Size: " + vtWidget.session.pageColumnsCount.toString() + " x " + vtWidget.session.pageLineCount.toString()
sizeWidget.width = sizeWidgetText.contentWidth + sizeWidget.margin
sizeWidget.height = sizeWidgetText.contentHeight
}
}

Expand All @@ -199,8 +198,6 @@ ContourTerminal

function updateFontSize() {
sizeWidgetText.font.pointSize = vtWidget.session.fontSize
sizeWidget.minWidth = vtWidget.session.fontSize * 10
sizeWidget.minHeight = vtWidget.session.fontSize * 3
}

onSessionChanged: (s) => {
Expand Down

0 comments on commit eb1b44a

Please sign in to comment.