@@ -48,6 +48,7 @@ import ScrollbackState, { ScrollbackOptions, Cleaner } from './ScrollbackState'
48
48
import Block from './Block'
49
49
import getSize from './getSize'
50
50
import SplitHeader from './SplitHeader'
51
+ import { SplitPositionProps } from './SplitPosition'
51
52
import { NotebookImpl , isNotebookImpl , snapshot , FlightRecorder , tabAlignment } from './Snapshot'
52
53
import KuiConfiguration from '../../Client/KuiConfiguration'
53
54
import SessionInitStatus from '../../Client/SessionInitStatus'
@@ -103,35 +104,36 @@ export interface TerminalOptions {
103
104
noActiveInput ?: boolean
104
105
}
105
106
106
- type Props = TerminalOptions & {
107
- /** tab UUID */
108
- uuid : string
107
+ type Props = TerminalOptions &
108
+ SplitPositionProps & {
109
+ /** tab UUID */
110
+ uuid : string
109
111
110
- /** tab model */
111
- tab : KuiTab
112
+ /** tab model */
113
+ tab : KuiTab
112
114
113
- snapshot ?: Buffer
115
+ snapshot ?: Buffer
114
116
115
- tabTitle ?: string
117
+ tabTitle ?: string
116
118
117
- /** handler for terminal clear */
118
- onClear ?: ( ) => void
119
+ /** handler for terminal clear */
120
+ onClear ?: ( ) => void
119
121
120
- /** KuiConfiguration */
121
- config : KuiConfiguration
122
+ /** KuiConfiguration */
123
+ config : KuiConfiguration
122
124
123
- /** Toggle attribute on Tab DOM */
124
- toggleAttribute ( attr : string ) : void
125
+ /** Toggle attribute on Tab DOM */
126
+ toggleAttribute ( attr : string ) : void
125
127
126
- /** Status of the proxy session (for client-server architectures of Kui) */
127
- sessionInit : SessionInitStatus
128
+ /** Status of the proxy session (for client-server architectures of Kui) */
129
+ sessionInit : SessionInitStatus
128
130
129
- /** Are we to display one of the splits as a bottom strip? */
130
- hasBottomStrip : boolean
131
+ /** Toggle whether we have a left strip split */
132
+ willToggleLeftStripMode ( ) : void
131
133
132
- /** Toggle whether we have a bottom strip split */
133
- willToggleBottomStripMode ( ) : void
134
- }
134
+ /** Toggle whether we have a bottom strip split */
135
+ willToggleBottomStripMode ( ) : void
136
+ }
135
137
136
138
interface State {
137
139
/** This helps enforce sequential block execution semantics */
@@ -255,7 +257,9 @@ export default class ScrollableTerminal extends React.PureComponent<Props, State
255
257
position : split . position
256
258
} )
257
259
258
- if ( split . position === 'bottom-strip' ) {
260
+ if ( split . position === 'left-strip' ) {
261
+ this . props . willToggleLeftStripMode ( )
262
+ } else if ( split . position === 'bottom-strip' ) {
259
263
this . props . willToggleBottomStripMode ( )
260
264
}
261
265
@@ -473,7 +477,7 @@ export default class ScrollableTerminal extends React.PureComponent<Props, State
473
477
scrollableRef : undefined ,
474
478
475
479
position : opts . position || 'default' ,
476
- willToggleBottomStripMode : undefined
480
+ willToggleSplitPosition : undefined
477
481
}
478
482
479
483
const getBlockIndexFromEvent = ( evt : React . SyntheticEvent , doNotComplain = false ) => {
@@ -692,17 +696,35 @@ export default class ScrollableTerminal extends React.PureComponent<Props, State
692
696
}
693
697
}
694
698
695
- if ( this . props . willToggleBottomStripMode ) {
696
- state . willToggleBottomStripMode = ( ) => {
697
- const sbidx = this . findSplit ( this . state , sbuuid )
698
- if ( sbidx >= 0 ) {
699
- const scrollback = this . state . splits [ sbidx ]
700
- if ( scrollback . position === 'default' ) {
701
- scrollback . position = 'bottom-strip'
699
+ state . willToggleSplitPosition = ( ) => {
700
+ const sbidx = this . findSplit ( this . state , sbuuid )
701
+ if ( sbidx >= 0 ) {
702
+ const scrollback = this . state . splits [ sbidx ]
703
+ if ( scrollback . position === 'default' ) {
704
+ if ( this . props . hasBottomStrip ) {
705
+ // this split is default, and we have a bottom split; make this a left split
706
+ scrollback . position = 'left-strip'
707
+ this . props . willToggleLeftStripMode ( )
702
708
} else {
709
+ // this split is default, and we don't have a bottom split; make this a bottom split
710
+ scrollback . position = 'bottom-strip'
711
+ this . props . willToggleBottomStripMode ( )
712
+ }
713
+ } else if ( scrollback . position === 'bottom-strip' ) {
714
+ if ( this . props . hasLeftStrip ) {
715
+ // this split is bottom, and we have a left split; revert this to default
703
716
scrollback . position = 'default'
717
+ this . props . willToggleBottomStripMode ( )
718
+ } else {
719
+ // this split is bottom, and we don't have a left split; make this a left split
720
+ scrollback . position = 'left-strip'
721
+ this . props . willToggleLeftStripMode ( )
722
+ this . props . willToggleBottomStripMode ( )
704
723
}
705
- this . props . willToggleBottomStripMode ( )
724
+ } else {
725
+ // this split is left; always return to default
726
+ this . props . willToggleLeftStripMode ( )
727
+ scrollback . position = 'default'
706
728
}
707
729
}
708
730
}
@@ -1309,10 +1331,20 @@ export default class ScrollableTerminal extends React.PureComponent<Props, State
1309
1331
// a bottom strip... we have a choice: either turn the bottom
1310
1332
// strip into a default split, or refuse the request to
1311
1333
// close. For now, we opt for the former
1312
- if ( this . props . hasBottomStrip && curState . splits . length === 2 && curState . splits [ idx ] . position === 'default' ) {
1334
+ if (
1335
+ ( this . props . hasBottomStrip || this . props . hasLeftStrip ) &&
1336
+ curState . splits . length === 2 &&
1337
+ curState . splits [ idx ] . position === 'default'
1338
+ ) {
1313
1339
const otherSplit = curState . splits [ 1 - idx ]
1314
1340
otherSplit . position = 'default'
1315
- setTimeout ( ( ) => this . props . willToggleBottomStripMode ( ) )
1341
+ setTimeout ( ( ) => {
1342
+ if ( this . props . hasBottomStrip ) {
1343
+ this . props . willToggleBottomStripMode ( )
1344
+ } else {
1345
+ this . props . willToggleLeftStripMode ( )
1346
+ }
1347
+ } )
1316
1348
}
1317
1349
1318
1350
eventBus . emitTabLayoutChange ( sbuuid )
@@ -1325,7 +1357,10 @@ export default class ScrollableTerminal extends React.PureComponent<Props, State
1325
1357
this . scrollbackCounter --
1326
1358
}
1327
1359
1328
- if ( curState . splits [ idx ] . position !== 'default' ) {
1360
+ if ( curState . splits [ idx ] . position === 'left-strip' ) {
1361
+ // then we are closing the left strip
1362
+ setTimeout ( ( ) => this . props . willToggleLeftStripMode ( ) )
1363
+ } else if ( curState . splits [ idx ] . position === 'bottom-strip' ) {
1329
1364
// then we are closing the bottom strip
1330
1365
setTimeout ( ( ) => this . props . willToggleBottomStripMode ( ) )
1331
1366
}
@@ -1611,12 +1646,19 @@ export default class ScrollableTerminal extends React.PureComponent<Props, State
1611
1646
{ this . state . splits . length > 1 && (
1612
1647
< SplitHeader
1613
1648
position = { scrollback . position }
1614
- onRemove = { ! this . props . hasBottomStrip || this . state . splits . length >= 2 ? scrollback . remove : undefined }
1649
+ onRemove = { scrollback . remove }
1615
1650
onClear = { scrollback . clear }
1616
1651
onInvert = { scrollback . invert }
1617
- willToggleBottomStripMode = {
1618
- ( ! this . props . hasBottomStrip || scrollback . position === 'bottom-strip' ) &&
1619
- scrollback . willToggleBottomStripMode
1652
+ hasLeftStrip = { this . props . hasLeftStrip }
1653
+ hasBottomStrip = { this . props . hasBottomStrip }
1654
+ willToggleSplitPosition = {
1655
+ this . props . hasLeftStrip && this . props . hasBottomStrip && scrollback . position === 'default'
1656
+ ? undefined // have both strips already and this is a default split? no toggle for you!
1657
+ : ( this . props . hasLeftStrip || this . props . hasBottomStrip ) &&
1658
+ this . state . splits . length === 2 &&
1659
+ scrollback . position === 'default'
1660
+ ? undefined // have 2 splits, and one of them is non-default, and this is a default? also no toggler for you
1661
+ : scrollback . willToggleSplitPosition
1620
1662
}
1621
1663
/>
1622
1664
) }
0 commit comments