<commit_before>class WebTermView extends KDView

  constructor: (options = {}, data) ->

    super options, data
    @initBackoff()

  viewAppended: ->

    @container = new KDView
      cssClass : "console ubuntu-mono green-on-black"
      bind     : "scroll"
    @container.on "scroll", =>
      @container.$().scrollLeft 0
    @addSubView @container

    @terminal = new WebTerm.Terminal @container.$()
    # KD.track "userOpenedTerminal", KD.getSingleton("groupsController").getCurrentGroup()
    @options.advancedSettings ?= no
    if @options.advancedSettings
      @advancedSettings = new KDButtonViewWithMenu
        style         : 'editor-advanced-settings-menu'
        icon          : yes
        iconOnly      : yes
        iconClass     : "cog"
        type          : "contextmenu"
        delegate      : @
        itemClass     : WebtermSettingsView
        click         : (pubInst, event)-> @contextMenu event
        menu          : @getAdvancedSettingsMenuItems.bind @
      @addSubView @advancedSettings

    @terminal.sessionEndedCallback = (sessions) =>
      @emit "WebTerm.terminated"
      @clearConnectionAttempts()

    @terminal.setTitleCallback = (title) =>
      #@tabPane.setTitle title

    @terminal.flushedCallback = =>
      @emit 'WebTerm.flushed'

    @listenWindowResize()

    @focused = true

    @on "ReceivedClickElsewhere", =>
      @focused = false
      @terminal.setFocused false
      KD.getSingleton('windowController').removeLayer @

    @on "KDObjectWillBeDestroyed", @bound "clearConnectionAttempts"

    $(window).on "blur", =>
      @terminal.setFocused false

    $(window).on "focus", =>
      @terminal.setFocused @focused

    $(document).on "paste", (event) =>
      if @focused
        @terminal.server.input event.originalEvent.clipboardData.getData("text/plain")
        @setKeyView()

    @bindEvent 'contextmenu'

    @utils.defer =>

      vmc = KD.getSingleton 'vmController'
      if vmc.vms.length > 1
        vmselection = new VMSelection
        vmselection.once 'VMSelected', (vm)=>
          @_vmName = vm
          do @connectToTerminal
      else
        @_vmName = vmc.vms.first
        do @connectToTerminal

  connectToTerminal:-><commit_msg>Terminal: AppView: Let the webtermpaneview handles vm selections<commit_after>class WebTermView extends KDView

  constructor: (options = {}, data) ->

    super options, data

    @_vmName = options.vmName  if options.vmName

    @initBackoff()

  viewAppended: ->

    @container = new KDView
      cssClass : "console ubuntu-mono green-on-black"
      bind     : "scroll"
    @container.on "scroll", =>
      @container.$().scrollLeft 0
    @addSubView @container

    @terminal = new WebTerm.Terminal @container.$()
    # KD.track "userOpenedTerminal", KD.getSingleton("groupsController").getCurrentGroup()
    @options.advancedSettings ?= no
    if @options.advancedSettings
      @advancedSettings = new KDButtonViewWithMenu
        style         : 'editor-advanced-settings-menu'
        icon          : yes
        iconOnly      : yes
        iconClass     : "cog"
        type          : "contextmenu"
        delegate      : @
        itemClass     : WebtermSettingsView
        click         : (pubInst, event)-> @contextMenu event
        menu          : @getAdvancedSettingsMenuItems.bind @
      @addSubView @advancedSettings

    @terminal.sessionEndedCallback = (sessions) =>
      @emit "WebTerm.terminated"
      @clearConnectionAttempts()

    @terminal.setTitleCallback = (title) =>
      #@tabPane.setTitle title

    @terminal.flushedCallback = =>
      @emit 'WebTerm.flushed'

    @listenWindowResize()

    @focused = true

    @on "ReceivedClickElsewhere", =>
      @focused = false
      @terminal.setFocused false
      KD.getSingleton('windowController').removeLayer @

    @on "KDObjectWillBeDestroyed", @bound "clearConnectionAttempts"

    $(window).on "blur", =>
      @terminal.setFocused false

    $(window).on "focus", =>
      @terminal.setFocused @focused

    $(document).on "paste", (event) =>
      if @focused
        @terminal.server.input event.originalEvent.clipboardData.getData("text/plain")
        @setKeyView()

    @bindEvent 'contextmenu'

    @connectToTerminal()

  connectToTerminal:->
{'fraction_non_alphanumeric': 0.11241492607369162, 'fraction_numerical': 0.0007040600797934757, 'mean_word_length': 2.554628857381151, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 30, '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': '4202880', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1205, 'n_words': 249}