Community
    • 登入

    Compare plugin developement

    已排程 已置頂 已鎖定 已移動 Notepad++ & Plugin Development
    13 貼文 6 Posters 6.2k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • Mehreen CM
      Mehreen C
      最後由 Mehreen C 編輯

      I have recently added the compare plugin (version 1.5.6.2) to my Notepad++ but was somewhat disappointed with its features. I was really hoping it would have comparison features similar to [https://text-compare.com/](link url) where the actual changes are highlighted instead of just saying which line has changed.

      I downloaded the source code for the compare plugin but am completely loss as where/what to modify/code in to get these features in.

      Are there plans to addin this feature. OR I could do with some guidance with modifying the code! :)

      Scott SumnerS 1 條回覆 最後回覆 回覆 引用 1
      • Scott SumnerS
        Scott Sumner @Mehreen C
        最後由 編輯

        @Mehreen-C

        Suggestion: Try the 2.0 version of the Compare plugin. Not sure if it will meet all your needs, but I think it is definitely worth taking a look at before doing anything else.

        1 條回覆 最後回覆 回覆 引用 1
        • YaronY
          Yaron
          最後由 編輯

          @Mehreen-C,

          Pavel Nedev has done the hard work.
          https://github.com/pnedev/compare-plugin/releases

          @Scott-Sumner,

          Not sure if it will meet all your needs

          It sure will. :)

          1 條回覆 最後回覆 回覆 引用 1
          • Mehreen CM
            Mehreen C
            最後由 編輯

            version2 compares in the same manner. it works files for actual text documents with spaces. but does not highlight the any change in a string (got pictures to illustrate but donno how to post then!).

            I’m trying to compare tow .hex files. the link I posted compares the files and highlights WHERE the changes occurred. using the plugin all i get as output is what a line as added/removed… not very useful if you have a long string of numbers to look at!

            Scott SumnerS 1 條回覆 最後回覆 回覆 引用 1
            • Scott SumnerS
              Scott Sumner @Mehreen C
              最後由 編輯

              @Mehreen-C

              got pictures to illustrate but donno how to post then!

              To post images here, use your favorite image hosting site (mine is imgur) but YMMV, and post your image files to it. It will give you a link, that looks like this one:

              http://i.imgur.com/QTHZysa.png

              Wrap that with some sugar so that it appears like this in the “COMPOSE” pane on this site:

              ![ ](http://i.imgur.com/QTHZysa.png)
              

              In the “PREVIEW” pane you should see your image rendered–if you don’t you did something wrong. Here’s how the link above renders when the posting is submitted (see! it’s an embedded image!):

              Mikhail VM 1 條回覆 最後回覆 回覆 引用 0
              • Mikhail VM
                Mikhail V @Scott Sumner
                最後由 編輯

                @Scott-Sumner said:

                @Mehreen-C

                got pictures to illustrate but donno how to post then!

                To post images here, use your favorite image hosting site (mine is imgur) but YMMV, and post your image files to it. It will give you a link, that looks like this one:

                http://i.imgur.com/QTHZysa.png

                Wrap that with some sugar so that it appears like this in the “COMPOSE” pane on this site:

                ![ ](http://i.imgur.com/QTHZysa.png)
                

                OT: Scott, (I ask here as I did not want to start a new topic).
                Can we have a FAQ section about how to e.g.:

                • post images
                • how to make a code block so as to avoid it appear with a horrible black background (I could not yet but I see you can do it somehow)
                Scott SumnerS 1 條回覆 最後回覆 回覆 引用 1
                • Scott SumnerS
                  Scott Sumner
                  最後由 Scott Sumner 編輯

                  @Mikhail-V

                  Can we have a FAQ section…

                  @PeterJones explains this at the bottom of this FAQ but “markdown” probably deserves its own FAQ Desk entry, perhaps a cleaned-up and enhanced version of this old posting…hey, there’s that woman’s picture again!

                  1 條回覆 最後回覆 回覆 引用 1
                  • Scott SumnerS
                    Scott Sumner @Mikhail V
                    最後由 編輯

                    @Mikhail-V

                    And by the way, here’s my code-block secret for the short term (composed in Notepad++ and screen-captured) until a better FAQ Desk entry is made:

                    Imgur

                    Those are backticks or grave accent (U+0060) characters on the first and last lines, in case that is not clear–probably isn’t clear as they look kind of lame in the Consolas font…

                    The above will render as:

                    parents, babies = (1, 1)
                    while babies < 100:
                        print 'This generation has {0} babies'.format(babies)
                        parents, babies = (babies, parents + babies)
                    
                    1 條回覆 最後回覆 回覆 引用 1
                    • PeterJonesP
                      PeterJones
                      最後由 PeterJones 編輯

                      @Mehreen-C ,

                      Back to the topic: as others have said, a screenshot can be quite helpful – and while cleaning out my temporary screenshot directory, I saw I had this animated screenshot (apparently from some other Compare-plugin question, though the pic hadn’t been previously posted to imgur) – it reminded me of your post, and once I confirmed you didn’t have a solution here yet, I uploaded the pic and started thinking more about your problem:

                      Source files:

                      #!/usr/bin/perl
                      if(a) {
                          print "something\n";
                      } else {
                          print "something else a\n";
                      }
                      

                      and

                      #!/usr/bin/perl
                      if(b) {
                          print "something\n";
                      } else {
                          print "something else b\n";
                      }
                      

                      (embedded text by indenting four spaces. You can also use Scott’s " ```z " … trick (above))

                      As you can see, when I turn on the Compare feature, it highlights that the “a” vs “b” is different on lines 2 and 5. You can use my example text to prove whether your setup works under any conditions: it should look similar to my screenshot.

                      So v2.0 Compare Plugin can show specifically what’s different on two lines.

                      And when I give it a list of numbers in the two windows,

                      3.1415926 2.718281828 
                      
                      3.2830926 2.718281828 
                      

                      … it highlights that I mistyped π in the second file:

                      So, the plugin can show the difference between numbers as well.

                      If you are having problems with specific data, please include that data: embed the text, so we can easily copy/paste; and embed an image, so that we can see that it doesn’t highlight properly on your setup. (A full screenshot of the window can give us extra clues, too: for example, my screenshot shows “Normal text file”, so we know it’s just using the default/plain lexer, and not some other lexer or UDL.)

                      In fact, if you do have a Language or UDL selection, that’s something important to let us know, because it can influence things – maybe the Compare Plugin and Lexer/UDL highlighting are fighting each other… If a Lexer or UDL are active, you might want to temporarily manually choose Language > Normal Text on both panes, before doing the compare. If that solves your problem, then it probably is a fight between the two.

                      1 條回覆 最後回覆 回覆 引用 3
                      • YaronY
                        Yaron
                        最後由 編輯

                        @PeterJones,

                        An excellent detailed reply.

                        In fact, if you do have a Language or UDL selection, that’s something important to let us know, because it can influence things – maybe the Compare Plugin and Lexer/UDL highlighting are fighting each other…

                        I haven’t encountered such a problem. :)

                        1 條回覆 最後回覆 回覆 引用 0
                        • pnedevP
                          pnedev
                          最後由 編輯

                          Hello all,

                          I suppose what @Mehreen-C is saying is that if you compare text files that are sequences of hex number lines (without any delimiters between the numbers) the Compare plugin won’t show you the exact mismatching hex digits between the lines.

                          Here are two files illustrating the issue:

                          file1
                          0123456789ABCDEF
                          FEDCBA9876543210

                          file2
                          A123456789ABCDEF
                          1EDCBA9876543210

                          Unfortunately that’s how CP is working at the moment - it compares the words between the lines (instead of the characters) and since hex digit sequences are not ‘words’ (they are considered as a single word) the whole lines are marked as different. If there were some delimiters between the digits (so that there were several groups of digits (words) ) we would have gotten a mark exactly in which group the diff is.

                          For instance:

                          file1
                          01 23 45 67 89 AB CD EF
                          FE DC BA 98 76 54 32 10

                          file2
                          A1 23 45 67 89 AB CD EF
                          1E DC BA 98 76 54 32 10

                          I’ll consider changing that behavior so the lines diffs are marked character-wise but can’t promise anything.

                          BR

                          1 條回覆 最後回覆 回覆 引用 3
                          • pnedevP
                            pnedev
                            最後由 編輯

                            Hello @Mehreen-C ,

                            Here is a VERY crude and sub-optimal quick fix (patched v2 plugin, x86 DLL).
                            Note however that CP v2 has some issues with hex text comparing (sometimes falsely reports lines as matching). For further info about this problem please check this topic.

                            BR

                            1 條回覆 最後回覆 回覆 引用 2
                            • YaronY
                              Yaron
                              最後由 編輯

                              Hello Pavel,

                              :+1: for understanding the OP. :)
                              And thank you for the quick fix.

                              BR

                              1 條回覆 最後回覆 回覆 引用 1
                              • 第一個貼文
                                最後的貼文
                              The Community of users of the Notepad++ text editor.
                              Powered by NodeBB | Contributors