forgecrafted / rulerz

[Looking for maintainer] A simple Atom package to mark your cursor position with a ruler.
MIT License
6 stars 7 forks source link

Does not display on Atom 208 #10

Closed JohnMurga closed 9 years ago

JohnMurga commented 9 years ago

Other similar packages have the same issue with 208

cmtonkinson commented 9 years ago

Duplicate of #8

JohnMurga commented 9 years ago

Not really ... But I guess the net effect is similar : https://github.com/atom/atom/issues/7204 I raised the issue on Atom also as it affects a few packages on 208 (while 207 is fine)

cmtonkinson commented 9 years ago

@JohnMurga looks like you're right, these are distinct-but-related changes that happened in quick succession.

cmtonkinson commented 9 years ago

Going to investigate using Markers instead of relying on manipulating layers in the editor directly.

JohnMurga commented 9 years ago

I got a response that may be useful ... https://github.com/atom/atom/issues/7204#event-327883949

cmtonkinson commented 9 years ago

Good call, @JohnMurga. Inserting into the shadowRoot gets it closer, but still having issues. First, the ruler gets thrown off horizontally by e.g. having line numbers enabled, and second, when the ruler is positioned correctly, it overlays the cursor so you don't see the blink effect.

Opacity could be a solution to the latter but it's probably not worth thinking too hard about before we figure out if adding a custom element to the shadowRoot is even the right way to move forward. Considered using Markers instead of "manual" DOM manipulation - thoughts anyone?

cmtonkinson commented 9 years ago

Another idea entirely is to replace all of the JS code with a pure-CSS solution. The following is a rough draft:

atom-text-editor.is-focused::shadow {
  .cursors {
    .cursor::before {
      content: " ";
      display: block;
      height: 100%;
      width: 1px;
      transform: translateX(-0px) scaleY(1000);
      border-left: 1px solid @text-color-subtle;
      overflow: hidden;
    }
  }
}

Two problems with this approach though:

  1. The ruler blinks with the cursor (and since .cursors.blink-off uses opacity instead of rgba, I don't see a clean way around this)
  2. Using translateX(-1px) to align the ruler perfectly with the cusor, hides the cursor (even when setting a negative z-index to try to force the ruler "behind" the cursor)
cmtonkinson commented 9 years ago

Instead of appending the Element to the old underlayer, it is now appended to the .lines div within the ShadowRoot of the editor. If this isn't best practice, someone holler - this editor moves too damn fast for me to keep up with standards sometimes, especially in the face of all this 1.0 deprecation ;-)