@@ -46,6 +46,9 @@ var TabGroup = Module("tabGroup", {
46
46
* @return {GroupItem }
47
47
*/
48
48
getGroup : function getGroup ( name , count ) {
49
+ if ( ! this . TV )
50
+ return null ;
51
+
49
52
let i = 0 ;
50
53
if ( ! count )
51
54
count = 1 ;
@@ -83,6 +86,9 @@ var TabGroup = Module("tabGroup", {
83
86
* @param {Boolean } wrap
84
87
*/
85
88
switchTo : function ( spec , wrap ) {
89
+ if ( ! tabGroup . TV )
90
+ return ;
91
+
86
92
const GI = tabGroup . tabView . GroupItems ;
87
93
let current = GI . getActiveGroupItem ( ) || GI . getActiveOrphanTab ( ) ;
88
94
let groups = GI . groupItems ;
@@ -150,6 +156,9 @@ var TabGroup = Module("tabGroup", {
150
156
* @return {GroupItem } created GroupItem instance
151
157
*/
152
158
createGroup : function createGroup ( name , shouldSwitch , tab ) {
159
+ if ( ! tabGroup . TV )
160
+ return null ;
161
+
153
162
let pageBounds = tabGroup . tabView . Items . getPageBounds ( ) ;
154
163
pageBounds . inset ( 20 , 20 ) ;
155
164
let box = new tabGroup . tabView . Rect ( pageBounds ) ;
@@ -185,6 +194,9 @@ var TabGroup = Module("tabGroup", {
185
194
* if {group} doesn't exist.
186
195
*/
187
196
moveTab : function moveTabToGroup ( tab , group , shouldSwitch ) {
197
+ if ( ! tabGroup . TV )
198
+ return ;
199
+
188
200
liberator . assert ( tab && ! tab . pinned , "Cannot move an AppTab" ) ;
189
201
190
202
let groupItem = ( group instanceof tabGroup . tabView . GroupItem ) ? group : tabGroup . getGroup ( group ) ;
@@ -202,6 +214,9 @@ var TabGroup = Module("tabGroup", {
202
214
* @param {string } groupName
203
215
*/
204
216
remove : function removeGroup ( groupName ) {
217
+ if ( ! tabGroup . TV )
218
+ return ;
219
+
205
220
const GI = tabGroup . tabView . GroupItems ;
206
221
let activeGroup = GI . getActiveGroupItem ( ) ;
207
222
let group = groupName ? tabGroup . getGroup ( groupName ) : activeGroup ;
@@ -252,12 +267,12 @@ var TabGroup = Module("tabGroup", {
252
267
253
268
mappings . add ( [ modes . NORMAL ] , [ "<C-S-n>" , "<C-S-PageDown>" ] ,
254
269
"Switch to next tab group" ,
255
- function ( count ) { tabGroup . switchTo ( "+" + ( count || 1 ) , true ) ; } ,
270
+ function ( count ) { if ( tabGroup . TV ) tabGroup . switchTo ( "+" + ( count || 1 ) , true ) ; } ,
256
271
{ count : true } ) ;
257
272
258
273
mappings . add ( [ modes . NORMAL ] , [ "<C-S-p>" , "<C-S-PageUp>" ] ,
259
274
"Switch to previous tab group" ,
260
- function ( count ) { tabGroup . switchTo ( "-" + ( count || 1 ) , true ) ; } ,
275
+ function ( count ) { if ( tabGroup . TV ) tabGroup . switchTo ( "-" + ( count || 1 ) , true ) ; } ,
261
276
{ count : true } ) ;
262
277
} ,
263
278
@@ -269,21 +284,24 @@ var TabGroup = Module("tabGroup", {
269
284
* take up the current tab to the group if bang(!) specified.
270
285
*/
271
286
new Command ( [ "add" ] , "Create a new tab group" ,
272
- function ( args ) { tabGroup . createGroup ( args . literalArg , true , args . bang ? tabs . getTab ( ) : null ) ; } ,
287
+ function ( args ) { if ( tabGroup . TV ) tabGroup . createGroup ( args . literalArg , true , args . bang ? tabs . getTab ( ) : null ) ; } ,
273
288
{ bang : true , literal : 0 } ) ,
274
289
/**
275
290
* Panorama SubCommand list
276
291
* list current tab groups
277
292
*/
278
293
new Command ( [ "list" , "ls" ] , "List current tab groups" ,
279
- function ( args ) { completion . listCompleter ( "tabgroup" ) ; } ,
294
+ function ( args ) { if ( tabGroup . TV ) completion . listCompleter ( "tabgroup" ) ; } ,
280
295
{ bang : false , argCount : 0 } ) ,
281
296
/**
282
297
* Panorama SubCommad pullTab
283
298
* pull the other group's tab
284
299
*/
285
300
new Command ( [ "pull[tab]" ] , "Pull a tab from another group" ,
286
301
function ( args ) {
302
+ if ( ! tabGroup . TV )
303
+ return ;
304
+
287
305
let activeGroup = tabGroup . tabView . GroupItems . getActiveGroupItem ( ) ;
288
306
if ( ! activeGroup ) {
289
307
liberator . echoerr ( "Cannot pull tab to the current group" ) ;
@@ -314,6 +332,9 @@ var TabGroup = Module("tabGroup", {
314
332
*/
315
333
new Command ( [ "push[tab]" , "stash" ] , "Move the current tab to another group" ,
316
334
function ( args ) {
335
+ if ( ! tabGroup . TV )
336
+ return ;
337
+
317
338
let currentTab = tabs . getTab ( ) ;
318
339
if ( currentTab . pinned ) {
319
340
liberator . echoerr ( "Cannot move an App Tab" ) ;
@@ -341,7 +362,7 @@ var TabGroup = Module("tabGroup", {
341
362
* remove the current group if {group} is ommited.
342
363
*/
343
364
new Command ( [ "remove" , "rm" ] , "Close the tab group (including all tabs!)" ,
344
- function ( args ) { tabGroup . remove ( args . literalArg ) ; } ,
365
+ function ( args ) { if ( tabGroup . TV ) tabGroup . remove ( args . literalArg ) ; } ,
345
366
{
346
367
literal : 0 ,
347
368
completer : function ( context ) completion . tabgroup ( context , false ) ,
@@ -353,6 +374,9 @@ var TabGroup = Module("tabGroup", {
353
374
*/
354
375
new Command ( [ "rename" , "mv" ] , "Rename current tab group (or reset to '(Untitled)')." ,
355
376
function ( args ) {
377
+ if ( ! tabGroup . TV )
378
+ return ;
379
+
356
380
let title = args . literalArg ;
357
381
if ( ! title ) {
358
382
if ( args . bang )
@@ -370,7 +394,7 @@ var TabGroup = Module("tabGroup", {
370
394
literal : 0 ,
371
395
completer : function ( context ) {
372
396
context . title = [ "Rename current group" ] ;
373
- let activeGroup = tabGroup . tabView . GroupItems . getActiveGroupItem ( ) ;
397
+ let activeGroup = tabGroup . TV && tabGroup . tabView . GroupItems . getActiveGroupItem ( ) ;
374
398
let title = activeGroup ? activeGroup . getTitle ( ) : "" ;
375
399
context . completions = title ? [ [ title , "" ] ] : [ ] ;
376
400
}
@@ -382,6 +406,9 @@ var TabGroup = Module("tabGroup", {
382
406
*/
383
407
new Command ( [ "switch" ] , "Switch to another group" ,
384
408
function ( args ) {
409
+ if ( ! tabGroup . TV )
410
+ return ;
411
+
385
412
if ( args . count > 0 )
386
413
tabGroup . switchTo ( "+" + args . count , true ) ;
387
414
else
@@ -404,15 +431,20 @@ var TabGroup = Module("tabGroup", {
404
431
405
432
completion : function ( ) {
406
433
completion . tabgroup = function TabGroupCompleter ( context , excludeActiveGroup ) {
434
+ context . title = [ "Tab Group" ] ;
435
+ context . anchored = false ;
436
+ if ( ! tabGroup . TV ) {
437
+ context . completions = [ ] ;
438
+ return ;
439
+ }
440
+
407
441
const GI = tabGroup . tabView . GroupItems ;
408
442
let groupItems = GI . groupItems ;
409
443
if ( excludeActiveGroup ) {
410
444
let activeGroup = GI . getActiveGroupItem ( ) ;
411
445
if ( activeGroup )
412
446
groupItems = groupItems . filter ( function ( group ) group . id != activeGroup . id ) ;
413
447
}
414
- context . title = [ "Tab Group" ] ;
415
- context . anchored = false ;
416
448
context . completions = groupItems . map ( function ( group ) {
417
449
let title = group . id + ": " + ( group . getTitle ( ) || "(Untitled)" ) ;
418
450
let desc = "Tabs: " + group . getChildren ( ) . length ;
0 commit comments