Skip to content

Commit

Permalink
renamed setting, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Apr 12, 2022
1 parent 4cf9eda commit be72cd5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 35 deletions.
38 changes: 16 additions & 22 deletions tabby-core/src/components/splitTab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
* Changes the size of the focused pane in the given direction
*/
resizePane (direction: ResizeDirection): void {
const resizeIncrement = this.config.store.appearance.paneResize
const resizeStep = this.config.store.terminal.paneResizeStep

// The direction of the resize pane, vertically or horizontally
let directionvh: SplitOrientation = 'h'
Expand All @@ -547,50 +547,44 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
return
}

let cur: BaseTabComponent | SplitContainer = this.focusedTab
let currentContainer: BaseTabComponent | SplitContainer = this.focusedTab
let child: BaseTabComponent | SplitContainer | null = this.focusedTab
let curSplitOrientation: SplitOrientation | null = null

// Find the first split that is in the orientations that the user chooses to change
while (curSplitOrientation !== directionvh) {
const par = this.getParentOf(cur)
if (par == null) {
const parentContainer = this.getParentOf(currentContainer)
if (!parentContainer) {
return
}
child = cur
cur = par
if (cur instanceof SplitContainer) {
curSplitOrientation = cur.orientation
child = currentContainer
currentContainer = parentContainer
if (currentContainer instanceof SplitContainer) {
curSplitOrientation = currentContainer.orientation
}
}
const curSplit: SplitContainer = cur as SplitContainer

if (!(currentContainer instanceof SplitContainer)) {
return
}

// Determine which index in the ratios refers to the child that will be modified
const currentChildIndex = (cur as SplitContainer).children.indexOf(child)
const currentChildIndex = currentContainer.children.indexOf(child)

let updatedRatio = 0
if (isDecreasing) {
updatedRatio = curSplit.ratios[currentChildIndex] - resizeIncrement
updatedRatio = currentContainer.ratios[currentChildIndex] - resizeStep
if (updatedRatio < 0) {
return
}
} else {
updatedRatio = curSplit.ratios[currentChildIndex] + resizeIncrement
updatedRatio = currentContainer.ratios[currentChildIndex] + resizeStep
if (updatedRatio > 1) {
return
}
}
const ratioModifier = resizeIncrement / curSplit.ratios.length

// Modify all the ratios evenly to normalize the pane sizes
curSplit.ratios.forEach((ratio) => {
if (isDecreasing) {
curSplit.ratios[ratio] += ratioModifier
} else {
curSplit.ratios[ratio] -= ratioModifier
}
})
curSplit.ratios[currentChildIndex] = updatedRatio
currentContainer.ratios[currentChildIndex] = updatedRatio
this.layout()
}

Expand Down
2 changes: 1 addition & 1 deletion tabby-core/src/configDefaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ appearance:
frame: thin
css: '/* * { color: blue !important; } */'
opacity: 1.0
paneResize: 0.1
vibrancy: false
vibrancyType: 'blur'
terminal:
showBuiltinProfiles: true
showRecentProfiles: 3
paneResizeStep: 0.1
hotkeys:
profile:
__nonStructural: true
Expand Down
27 changes: 15 additions & 12 deletions tabby-settings/src/components/windowSettingsTab.component.pug
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,6 @@ h3.mb-3(translate) Window
step='0.01'
)

.form-line()
.header
.title(translate) Pane Resize Increment
input(
type='range',
[(ngModel)]='config.store.appearance.paneResize',
(ngModelChange)='saveConfiguration();',
min='0.1',
max='0.9',
step='0.05'
)

.form-line(*ngIf='platform.supportsWindowControls')
.header
.title(translate) Window frame
Expand Down Expand Up @@ -316,6 +304,21 @@ h3.mt-4(translate) Tabs
(ngModelChange)='config.save();',
)

h3.mt-4(translate) Panes

.form-line()
.header
.title(translate) Pane resize step
.description(translate) For keyboard shortcuts
input(
type='range',
[(ngModel)]='config.store.terminal.paneResizeStep',
(ngModelChange)='saveConfiguration();',
min='0.1',
max='0.9',
step='0.05'
)

h3.mt-4(translate) Hacks

.form-line
Expand Down

0 comments on commit be72cd5

Please sign in to comment.