Sublime Forum

A preview of side by side compare package ... and questions

#1

I am writing a package for side by side comparison between files and clipboard content and more.

Here is a preview screenshot. I guess I do not need to explain too much on what it does. And in case anyone wonder, the 2 panes scroll together if you have a long document, I just cannot show it in screenshots.


I almost complete the basic features of this package but I am stucked at several points that I hope some of you may be able to help me out.

  1. I know I can add a little icon next to the line number by using add_region. But can I use my custom png? I’ve tried that I can use any picture that’s in the the “Theme - Default” folder. But is it a bad practice if I ask people to put new pictures in that folder? Or there are other ways to use my custom png that I am missing?

  2. As you guys can see in the screen shot, I use a empty line for lines that appear in one document but not the others. But I still think that if I can make arbitrary spaces between lines that would be great. If jps is hearing this…please please I need this api >_<

  3. is there a way to get the end line char using in the document? (now I am assuming all files use \n)

0 Likes

#2
  1. I believe you can do “…/MyPackageName/icon” and it’ll load “icon.png” from your package.
0 Likes

#3

View.line_endings()

0 Likes

#4

quarnster: Thanks for the trick! I will try it out.

agibsonsw: I tried the View.line_endings(). But in a windows system is gets me \r\n. Even if my whole file use \n …

0 Likes

#5

@erinata

I believe you will need to account for \r being present on some systems (Windows) and not others. You can use Python .strip(’\r\n’) to remove it/them where necessary.

When writing to a view you can (I believe) ignore ‘\r’, but you need to account for it when reading.

0 Likes