romgrk / termrk

Terminal for atom, using pty.js & term.js
MIT License
33 stars 7 forks source link

Trying to scroll up on text breaks termrk, and throws error until atom is restarted #25

Closed bizarrechaos closed 9 years ago

bizarrechaos commented 9 years ago

[Enter steps to reproduce below:]

  1. Open termrk (using command palette or key shortcut)
  2. ls -a on a large directory (or any command that fills the panel)
  3. Try to scroll up.

Atom Version: 0.209.0 System: Mac OS X 10.8.5 Thrown From: Termrk package, v0.1.17

Stack Trace

Uncaught TypeError: Cannot read property '0' of undefined

At ~/.atom/packages/Termrk/node_modules/term.js/src/term.js:1208

TypeError: Cannot read property '0' of undefined
  at Terminal.refresh (~/.atom/packages/Termrk/node_modules/term.js/src/term.js:1208:18)
  at Terminal.refresh (~/.atom/packages/Termrk/lib/termjs-fix.coffee:127:9)
  at Terminal.scrollDisp (~/.atom/packages/Termrk/node_modules/term.js/src/term.js:1401:8)
  at TermrkView.module.exports.TermrkView.terminalMousewheel (~/.atom/packages/Termrk/lib/termrk-view.coffee:163:19)
  at TermrkView.terminalMousewheel (~/.atom/packages/Termrk/lib/termrk-view.coffee:2:1)

Commands

     -0:11.9.0 termrk:toggle (atom-workspace.workspace.scrollbars-visible-always.theme-seti-syntax.theme-seti-ui)

Config

{
  "core": {
    "ignoredNames": [
      ".git",
      ".svn",
      ".DS_Store"
    ],
    "disabledPackages": [
      "ask-stack",
      "ask-stack",
      "linter-pylint"
    ],
    "themes": [
      "seti-ui",
      "seti-syntax"
    ]
  }
}

Installed Packages

# User
Termrk, v0.1.17
autocomplete-python, v0.4.2
highlight-selected, v0.9.3
linter, v0.12.7
linter-pep8, v0.2.0
minimap, v4.10.0
minimap-highlight-selected, v4.3.0
python-isort, v0.0.7
seti-syntax, v0.4.0
seti-ui, v0.7.1

# Dev
No dev packages
ghost commented 9 years ago

Hello all,

I corrected this issue by modifing the terminalMousewheel event in lib/termk-view.coffee file, as follows:


terminalMousewheel: (event) =>
        deltaY  = event.wheelDeltaY
     #This line breaks things on OS X 
     #deltaY/120 is not needed for scrolling
        #deltaY /= 120
        deltaY *= -1
        @terminal.scrollDisp(deltaY)

From what I can tell, the way that the delta Y values from the "mouse wheel" are being used is causing the problem. Depending on your operating system, the way in which this value is interpreted varies. If this is the case, the way this mouse event is handled needs to be universal.

Mozilla has some good documentation talking about these delta values - https://developer.mozilla.org/en-US/docs/Web/Events/mousewheel

ghost commented 9 years ago

This solution works for me as well, does it work for anyone else? I changed how scrolling was handled -- I pretty much looked how term.js does it, and converted it over to CoffeeScript.


terminalMousewheel: (event) =>
        #This breaks everything :(
        #deltaY  = event.wheelDeltaY
        #deltaY /= 120
        #deltaY *= -1
        #Works on OSX only?
        #deltaY = event.wheelDeltaY
        #deltaY *= -1
        #Possible catch-all solution?
        deltaY = event.wheelDeltaY
        #Handle scrolling based on the event type
        #Based on how term.js handles mouse scrolling
        if event.type is 'DOMMouseScroll'
          deltaY += if event.detail < 0 then -1 else 1
          deltaY *= -1 #Correct scrolling direction
        else
          deltaY += if event.wheelDeltaY > 0 then -1 else 1
          deltaY *= -1 #Correct scrolling direction
        @terminal.scrollDisp(deltaY)

romgrk commented 9 years ago

This has been reported as fixed. Closing, but reopen if it's not the case.