<commit_before>BrowserWindow = null # Defer require until actually used
RendererIpc = require 'ipc'

{$, View} = require 'atom-space-pen-views'
{CompositeDisposable} = require 'atom'
_ = require 'underscore-plus'
TabView = require './tab-view'

module.exports =
class TabBarView extends View
  @content: ->
    @ul tabindex: -1, class: "list-inline tab-bar inset-panel"

  initialize: (@pane) ->
    @subscriptions = new CompositeDisposable

    @subscriptions.add atom.commands.add @element,
      'tabs:close-tab': => @closeTab()
      'tabs:close-other-tabs': => @closeOtherTabs()
      'tabs:close-tabs-to-right': => @closeTabsToRight()
      'tabs:close-saved-tabs': => @closeSavedTabs()
      'tabs:close-all-tabs': => @closeAllTabs()
      'tabs:split-up': => @splitTab('splitUp')
      'tabs:split-down': => @splitTab('splitDown')
      'tabs:split-left': => @splitTab('splitLeft')
      'tabs:split-right': => @splitTab('splitRight')

    @on 'dragstart', '.sortable', @onDragStart
    @on 'dragend', '.sortable', @onDragEnd
    @on 'dragleave', @onDragLeave
    @on 'dragover', @onDragOver
    @on 'drop', @onDrop

    @paneContainer = @pane.getContainer()
    @addTabForItem(item) for item in @pane.getItems()

    @subscriptions.add @pane.onDidDestroy =>
      @unsubscribe()

    @subscriptions.add @pane.onDidAddItem ({item, index}) =>
      @addTabForItem(item, index)

    @subscriptions.add @pane.onDidMoveItem ({item, newIndex}) =>
      @moveItemTabToIndex(item, newIndex)

    @subscriptions.add @pane.onDidRemoveItem ({item}) =>
      @removeTabForItem(item)

    @subscriptions.add @pane.onDidChangeActiveItem =>
      @updateActiveTab()

    @subscriptions.add atom.config.observe 'tabs.tabScrolling', => @updateTabScrolling()
    @subscriptions.add atom.config.observe 'tabs.tabScrollingThreshold', => @updateTabScrollingThreshold()
    @subscriptions.add atom.config.observe 'tabs.alwaysShowTabBar', => @updateTabBarVisibility()

    @updateActiveTab()

    @on 'mousedown', '.tab', ({target, which, ctrlKey}) =>
      tab = $(target).closest('.tab')[0]
      if which is 3 or (which is 1 and ctrlKey is true)
        @find('.right-clicked').removeClass('right-clicked')
        tab.classList.add('right-clicked')
        false
      else if which is 2
        @pane.destroyItem(tab.item)
        false

    @on 'dblclick', ({target}) =>
      if target is @element
        atom.commands.dispatch(@element, 'application:new-file')
        false

    @on 'click', '.tab .close-icon', ({target}) =>
      tab = $(target).closest('.tab')[0]
      @pane.destroyItem(tab.item)
      false

    @on 'click', '.tab', ({target, which}) =>
      tab = $(target).closest('.tab')[0]
      if which is 1 and not target.classList.contains('close-icon')
        @pane.activateItem(tab.item)
        @pane.activate()
        false

    RendererIpc.on('tab:dropped', @onDropOnOtherWindow)

  unsubscribe: ->
    RendererIpc.removeListener('tab:dropped', @onDropOnOtherWindow)
    @subscriptions.dispose()

  addTabForItem: (item, index) ->
    tabView = new TabView()
    tabView.initialize(item)
    @insertTabAtIndex(tabView, index)
<commit_msg>Switch tabs onmousedown<commit_after>BrowserWindow = null # Defer require until actually used
RendererIpc = require 'ipc'

{$, View} = require 'atom-space-pen-views'
{CompositeDisposable} = require 'atom'
_ = require 'underscore-plus'
TabView = require './tab-view'

module.exports =
class TabBarView extends View
  @content: ->
    @ul tabindex: -1, class: "list-inline tab-bar inset-panel"

  initialize: (@pane) ->
    @subscriptions = new CompositeDisposable

    @subscriptions.add atom.commands.add @element,
      'tabs:close-tab': => @closeTab()
      'tabs:close-other-tabs': => @closeOtherTabs()
      'tabs:close-tabs-to-right': => @closeTabsToRight()
      'tabs:close-saved-tabs': => @closeSavedTabs()
      'tabs:close-all-tabs': => @closeAllTabs()
      'tabs:split-up': => @splitTab('splitUp')
      'tabs:split-down': => @splitTab('splitDown')
      'tabs:split-left': => @splitTab('splitLeft')
      'tabs:split-right': => @splitTab('splitRight')

    @on 'dragstart', '.sortable', @onDragStart
    @on 'dragend', '.sortable', @onDragEnd
    @on 'dragleave', @onDragLeave
    @on 'dragover', @onDragOver
    @on 'drop', @onDrop

    @paneContainer = @pane.getContainer()
    @addTabForItem(item) for item in @pane.getItems()

    @subscriptions.add @pane.onDidDestroy =>
      @unsubscribe()

    @subscriptions.add @pane.onDidAddItem ({item, index}) =>
      @addTabForItem(item, index)

    @subscriptions.add @pane.onDidMoveItem ({item, newIndex}) =>
      @moveItemTabToIndex(item, newIndex)

    @subscriptions.add @pane.onDidRemoveItem ({item}) =>
      @removeTabForItem(item)

    @subscriptions.add @pane.onDidChangeActiveItem =>
      @updateActiveTab()

    @subscriptions.add atom.config.observe 'tabs.tabScrolling', => @updateTabScrolling()
    @subscriptions.add atom.config.observe 'tabs.tabScrollingThreshold', => @updateTabScrollingThreshold()
    @subscriptions.add atom.config.observe 'tabs.alwaysShowTabBar', => @updateTabBarVisibility()

    @updateActiveTab()

    @on 'mousedown', '.tab', ({target, which, ctrlKey}) =>
      tab = $(target).closest('.tab')[0]
      if which is 3 or (which is 1 and ctrlKey is true)
        @find('.right-clicked').removeClass('right-clicked')
        tab.classList.add('right-clicked')
        false
      else if which is 2
        @pane.destroyItem(tab.item)
        false

    @on 'dblclick', ({target}) =>
      if target is @element
        atom.commands.dispatch(@element, 'application:new-file')
        false

    @on 'click', '.tab .close-icon', ({target}) =>
      tab = $(target).closest('.tab')[0]
      @pane.destroyItem(tab.item)
      false

    @on 'mousedown', '.tab', ({target, which}) =>
      tab = $(target).closest('.tab')[0]
      if which is 1 and not target.classList.contains('close-icon')
        @pane.activateItem(tab.item)
        @pane.activate()
        false

    RendererIpc.on('tab:dropped', @onDropOnOtherWindow)

  unsubscribe: ->
    RendererIpc.removeListener('tab:dropped', @onDropOnOtherWindow)
    @subscriptions.dispose()

  addTabForItem: (item, index) ->
    tabView = new TabView()
    tabView.initialize(item)
    @insertTabAtIndex(tabView, index)

{'fraction_non_alphanumeric': 0.15997470755611762, 'fraction_numerical': 0.002529244388239014, 'mean_word_length': 3.528990694345025, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3359144', 'n_tokens_mistral': 2109, 'n_tokens_neox': 2051, 'n_words': 402}