<commit_before>{View}  = require 'atom'
{$} = require 'atom'
AtomSharperErrorView = require './atom-sharper-error-view'
Convert = require 'ansi-to-html'
Vue = require 'vue'

module.exports =
# Internal: A tool-panel view for the test result output.
class AtomSharperOutputView extends View

  # Internal: Initialize test-status output view DOM contents.
  @content: ->
    @div class: 'tool-panel panel-bottom atom-sharper-pane', outlet: 'pane', =>
      @div class: 'atom-sharper-output-resizer', outlet: 'resizeHandle'
      @div class: "inset-panel", =>
        @div class: "panel-heading clearfix", =>
          @div class: 'btn-toolbar pull-left', =>
            @div class: 'btn-group btn-toggle', =>
              @button class: 'btn btn-default btn-fix', dataTab:'errors-output', 'Errors'
              @button class: 'btn btn-default btn-fix', dataTab:'build-output', 'Build output'
              @button class: 'btn btn-default btn-fix', dataTab:'omni-sharp-output', 'Omnisharp output'
        @div tabIndex: -1, class: 'atom-sharper-output omni-sharp-output padded', =>
            @div class: 'message', outlet: 'sharpAtomOutput'
        @div tabIndex: -1, class: 'atom-sharper-output errors-output', outlet: 'errorsOutput', =>
        @div tabIndex: -1, class: 'atom-sharper-output build-output padded', =>
  # Internal: Initialize the test-status output view and event handlers.
  initialize: ->

    @errorsOutput.append(new AtomSharperErrorView())
    @vm = new Vue
      data:
        selected: "errors"
      el: this[0]

    atom.workspaceView.command "atom-sharper:toggle-output", =>
      @toggle()

    atom.on("omni-sharp-server:out", (data) => @update data)
    atom.on("omni-sharp-server:err", (data) => @update data)
    atom.on "omni-sharp-server:start", @start

    @on 'mousedown', '.atom-sharper-output-resizer', (e) => @resizeStarted(e)
    @on 'click', '.btn-group .btn', (e) => @selectPane(e)

  selectPane: (e) =>
    this.find(".btn-group .btn").removeClass("selected")
    current = $(e.target)
    current.addClass("selected")
    targetOutput = current.attr("datatab");
    this.find(".atom-sharper-output").hide();
    this.find(".#{targetOutput}").show();


  resizeStarted: =>
    @fixedTop = @resizeHandle.offset().top
    @fixedHeight = $(".atom-sharper-pane").height()
    @fixedButtonBarHeight = this.find(".btn-group").height()
    $(document).on('mousemove', @resizePane)
    $(document).on('mouseup', @resizeStopped)

  resizeStopped: =>
    $(document).off('mousemove', @resizePane)
    $(document).off('mouseup', @resizeStopped)

  resizePane: ({pageY, which}) =>
    return @resizeStopped() unless which is 1
    h = @fixedHeight + (@fixedTop - pageY)
    $(".atom-sharper-pane").height(h)
    this.find(".atom-sharper-output").height(h-@fixedButtonBarHeight)

  start: (pid) =>
    @output = "<strong class'success'>Started Omnisharp server (#{pid})</strong>"
    @sharpAtomOutput.html(@output).css('font-size', "#{atom.config.getInt('editor.fontSize')}px")

  update: (output) ->
    @convert ?= new Convert<commit_msg>omni dock panel tab switching is now reactive<commit_after>{View}  = require 'atom'
{$} = require 'atom'
AtomSharperErrorView = require './atom-sharper-error-view'
Convert = require 'ansi-to-html'
Vue = require 'vue'

module.exports =
# Internal: A tool-panel view for the test result output.
class AtomSharperOutputView extends View

  # Internal: Initialize test-status output view DOM contents.
  @content: ->
    btn = (view, text) =>
      @button
        'v-attr' : "class: selected | btn-selected #{view}",
        'v-on' : "click: selectPane",
        'pane' : view
        text

    @div class: 'tool-panel panel-bottom atom-sharper-pane', outlet: 'pane', =>
      @div class: 'atom-sharper-output-resizer', outlet: 'resizeHandle'
      #header
      @div class: "inset-panel", =>
        @div class: "panel-heading clearfix", =>
          @div class: 'btn-toolbar pull-left', =>
            @div class: 'btn-group btn-toggle', =>
              btn "errors", "Errors"
              btn "build", "Build output"
              btn "omni", "Omnisharp output"
        #tab content panels
        @div 'v-attr' : 'class: selected | content-selected omni', =>
            @div class: 'message', outlet: 'sharpAtomOutput'
        @div 'v-attr' : 'class: selected | content-selected errors', outlet: 'errorsOutput'
        @div 'v-attr' : 'class: selected | content-selected build'

  # Internal: Initialize the test-status output view and event handlers.
  initialize: ->

    Vue.filter 'btn-selected', (value, expectedValue) =>
      selected = if value == expectedValue then "selected" else ""
      "btn btn-default btn-fix #{selected}"

    Vue.filter 'content-selected', (value, expectedValue) =>
      selected = if value == expectedValue then "" else "hide"
      "atom-sharper-output #{expectedValue}-output #{selected}"

    @errorsOutput.append(new AtomSharperErrorView())
    @vm = new Vue
      el: this[0]
      data:
        selected: "omni"
      methods:
        selectPane: ({target}) => @selectPane $(target).attr "pane"

    atom.workspaceView.command "atom-sharper:toggle-output", => @toggle()

    atom.on("omni-sharp-server:out", (data) => @update data)
    atom.on("omni-sharp-server:err", (data) => @update data)
    atom.on "omni-sharp-server:start", @start

    @on 'mousedown', '.atom-sharper-output-resizer', (e) => @resizeStarted(e)

  selectPane: (pane) => @vm.selected = pane

  resizeStarted: =>
    @fixedTop = @resizeHandle.offset().top
    @fixedHeight = $(".atom-sharper-pane").height()
    @fixedButtonBarHeight = this.find(".btn-group").height()
    $(document).on('mousemove', @resizePane)
    $(document).on('mouseup', @resizeStopped)

  resizeStopped: =>
    $(document).off('mousemove', @resizePane)
    $(document).off('mouseup', @resizeStopped)

  resizePane: ({pageY, which}) =>
    return @resizeStopped() unless which is 1
    h = @fixedHeight + (@fixedTop - pageY)
    $(".atom-sharper-pane").height(h)
    this.find(".atom-sharper-output").height(h-@fixedButtonBarHeight)

  start: (pid) =>
    @output = "<strong class'success'>Started Omnisharp server (#{pid})</strong>"
    @sharpAtomOutput.html(@output).css('font-size', "#{atom.config.getInt('editor.fontSize')}px")

  update: (output) ->
    @convert ?= new Convert
{'fraction_non_alphanumeric': 0.16897856242118536, 'fraction_numerical': 0.0011034047919293822, 'mean_word_length': 3.37888198757764, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 50, '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': '5904236', 'n_tokens_mistral': 2084, 'n_tokens_neox': 2026, 'n_words': 463}