<commit_before>ipc = require 'ipc'
path = require 'path'
{Disposable, CompositeDisposable} = require 'event-kit'
Grim = require 'grim'
scrollbarStyle = require 'scrollbar-style'
{callAttachHooks} = require 'space-pen'
WorkspaceView = null

module.exports =
class WorkspaceElement extends HTMLElement
  createdCallback: ->
    @subscriptions = new CompositeDisposable
    atom.commands.setRootNode(this)
    @initializeContent()
    @observeScrollbarStyle()
    @observeTextEditorFontConfig()
    @createSpacePenShim()

  attachedCallback: ->
    callAttachHooks(this)
    @focus()

  detachedCallback: ->
    @model.destroy()

  initializeContent: ->
    @classList.add 'workspace'
    @setAttribute 'tabindex', -1


    @verticalAxis = document.createElement('div')
    @verticalAxis.classList.add('vertical')

    @horizontalAxis = document.createElement('div')
    @horizontalAxis.classList.add('horizontal')
    @horizontalAxis.appendChild(@verticalAxis)

    @appendChild(@horizontalAxis)

  observeScrollbarStyle: ->
    @subscriptions.add scrollbarStyle.onValue (style) =>
      switch style
        when 'legacy'
          @classList.remove('scrollbars-visible-when-scrolling')
          @classList.add("scrollbars-visible-always")
        when 'overlay'
          @classList.remove('scrollbars-visible-always')
          @classList.add("scrollbars-visible-when-scrolling")

  observeTextEditorFontConfig: ->
    @subscriptions.add atom.config.observe 'editor.fontSize', @setTextEditorFontSize
    @subscriptions.add atom.config.observe 'editor.fontFamily', @setTextEditorFontFamily
    @subscriptions.add atom.config.observe 'editor.lineHeight', @setTextEditorLineHeight

  createSpacePenShim: ->
    WorkspaceView ?= require './workspace-view'
    @__spacePenView = new WorkspaceView(this)

  getModel: -> @model

  setModel: (@model) ->
    @paneContainer = @model.getView(@model.paneContainer)
    @verticalAxis.appendChild(@paneContainer)

    @addEventListener 'focus', @handleFocus.bind(this)
    handleWindowFocus = @handleWindowFocus.bind(this)
    window.addEventListener 'focus', handleWindowFocus
    @subscriptions.add(new Disposable => window.removeEventListener 'focus', handleWindowFocus)

    @__spacePenView.setModel(@model)

  # Essential: Focus the pane directly above the active pane.
  focusPaneViewAbove: -> @panes.focusPaneViewAbove()

  # Essential: Focus the pane directly below the active pane.
  focusPaneViewBelow: -> @panes.focusPaneViewBelow()

  # Essential: Focus the pane directly to the left of the active pane.
  focusPaneViewOnLeft: -> @panes.focusPaneViewOnLeft()

  # Essential: Focus the pane directly to the right of the active pane.
  focusPaneViewOnRight: -> @panes.focusPaneViewOnRight()

  ###
  Section: Private
  ###

  setTextEditorFontSize: (fontSize) ->
    atom.themes.updateGlobalEditorStyle('font-size', fontSize + 'px')

  setTextEditorFontFamily: (fontFamily) ->
    atom.themes.updateGlobalEditorStyle('font-family', fontFamily)

  setTextEditorLineHeight: (lineHeight) ->
    atom.themes.updateGlobalEditorStyle('line-height', lineHeight)

  handleFocus: (event) ->
    @model.getActivePane().activate()<commit_msg>Remove methods carried over from old view<commit_after>ipc = require 'ipc'
path = require 'path'
{Disposable, CompositeDisposable} = require 'event-kit'
Grim = require 'grim'
scrollbarStyle = require 'scrollbar-style'
{callAttachHooks} = require 'space-pen'
WorkspaceView = null

module.exports =
class WorkspaceElement extends HTMLElement
  createdCallback: ->
    @subscriptions = new CompositeDisposable
    atom.commands.setRootNode(this)
    @initializeContent()
    @observeScrollbarStyle()
    @observeTextEditorFontConfig()
    @createSpacePenShim()

  attachedCallback: ->
    callAttachHooks(this)
    @focus()

  detachedCallback: ->
    @model.destroy()

  initializeContent: ->
    @classList.add 'workspace'
    @setAttribute 'tabindex', -1


    @verticalAxis = document.createElement('div')
    @verticalAxis.classList.add('vertical')

    @horizontalAxis = document.createElement('div')
    @horizontalAxis.classList.add('horizontal')
    @horizontalAxis.appendChild(@verticalAxis)

    @appendChild(@horizontalAxis)

  observeScrollbarStyle: ->
    @subscriptions.add scrollbarStyle.onValue (style) =>
      switch style
        when 'legacy'
          @classList.remove('scrollbars-visible-when-scrolling')
          @classList.add("scrollbars-visible-always")
        when 'overlay'
          @classList.remove('scrollbars-visible-always')
          @classList.add("scrollbars-visible-when-scrolling")

  observeTextEditorFontConfig: ->
    @subscriptions.add atom.config.observe 'editor.fontSize', @setTextEditorFontSize
    @subscriptions.add atom.config.observe 'editor.fontFamily', @setTextEditorFontFamily
    @subscriptions.add atom.config.observe 'editor.lineHeight', @setTextEditorLineHeight

  createSpacePenShim: ->
    WorkspaceView ?= require './workspace-view'
    @__spacePenView = new WorkspaceView(this)

  getModel: -> @model

  setModel: (@model) ->
    @paneContainer = @model.getView(@model.paneContainer)
    @verticalAxis.appendChild(@paneContainer)

    @addEventListener 'focus', @handleFocus.bind(this)
    handleWindowFocus = @handleWindowFocus.bind(this)
    window.addEventListener 'focus', handleWindowFocus
    @subscriptions.add(new Disposable => window.removeEventListener 'focus', handleWindowFocus)

    @__spacePenView.setModel(@model)

  setTextEditorFontSize: (fontSize) ->
    atom.themes.updateGlobalEditorStyle('font-size', fontSize + 'px')

  setTextEditorFontFamily: (fontFamily) ->
    atom.themes.updateGlobalEditorStyle('font-family', fontFamily)

  setTextEditorLineHeight: (lineHeight) ->
    atom.themes.updateGlobalEditorStyle('line-height', lineHeight)

  handleFocus: (event) ->
    @model.getActivePane().activate()
{'fraction_non_alphanumeric': 0.1164138401227203, 'fraction_numerical': 0.0003408897221748764, 'mean_word_length': 4.515037593984962, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, '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': '6484746', 'n_tokens_mistral': 1725, 'n_tokens_neox': 1677, 'n_words': 307}