• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

[plugin] Ruby Code Editor - UPDATED to v3.0 3/4/2013

Scheduled Pinned Locked Moved Plugins
37 Posts 5 Posters 30.7k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    chrisjk
    last edited by 26 Feb 2010, 18:19

    @alexschreyer said:

    @alz said:

    Have you thought about adding syntax highlighting?

    I actually had it in there at the beginning. Unfortunately (since it uses Javascript), I found that it would get very slow with moderately sized files. But I agree it would be nice.

    Cheers,
    Alex

    I am way out of my depth here not knowing any ruby or javascript but could you not use the same functionality provided by the browser that is used to highlight words in say a google search?

    Chris

    1 Reply Last reply Reply Quote 0
    • A Offline
      alexschreyer Extension Creator
      last edited by 26 Feb 2010, 19:28

      @chrisjk said:

      could you not use the same functionality provided by the browser that is used to highlight words in say a google search?

      Although I can find words easily in a textarea (the editor field), I can't highlight it unless I use a custom html-formatted component. In any case, there needs to be some code that runs on every keypress that scans the entire document and formats words. For longer documents that becomes quite slow.

      I looked at this editor:
      http://ajaxian.com/archives/editarea-rich-sourcecode-editor

      It is pretty neat but I figured, considering the performance issues, that once someone wants highlighting, they'll switch to Notepad++ or other external editors anyways.

      Cheers,
      Alex

      Author of "Architectural Design with SketchUp":
      http://sketchupfordesign.com/

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by 26 Feb 2010, 19:51

        Hi Alex,

        you are more than likely aware of dCode, it does seem to be abandoned, I have posed questions about it before without response, but it does seem to have some useful features the are already tuned to SU. http://www.errorinitus.de./sketchup/dcode/help/1.0_RC1/index_en.html

        I was looking at doing something with it myself but it's all way out of my league... and maybe it's crap...

        happy to test and comment though

        the latest RCE is working quite nicely on both my Mac's, thank you

        john

        learn from the mistakes of others, you may not live long enough to make them all yourself...

        1 Reply Last reply Reply Quote 0
        • A Offline
          alexschreyer Extension Creator
          last edited by 13 Apr 2011, 03:31

          Just updated to version 2.0. Download in the same location as before.

          Cheers,
          Alex

          Author of "Architectural Design with SketchUp":
          http://sketchupfordesign.com/

          1 Reply Last reply Reply Quote 0
          • D Offline
            driven
            last edited by 13 Apr 2011, 12:36

            hi Alex,

            looking good, but there's a parsing issue with complex saved files.

            this may just be a mac thing, but, I could always do it with previous versions.

            if you edit as_rubyeditor.rb in 'itself' and then 'save' on SU restart it fails to load 'it' due to this happening.

            Encode backward slashes and single quotes in Ruby

            234          text.gsub!('\\', "<84JSed>")
            235          text.gsub!('\'', "<25SKxw>")   
            

            becomes

            234         text.gsub!('\\', "\")
            235         text.gsub!('\'', "'")
            

            and also

            245          dlg.execute_script("tmp = tmp.replace(/<84JSed>/g,'\\\\')")
            246          dlg.execute_script("tmp = tmp.replace(/<25SKxw>/g,'\\'')")
            

            becomes

            245         dlg.execute_script("tmp = tmp.replace(/\/g,'\\\\')")
            246         dlg.execute_script("tmp = tmp.replace(/'/g,'\\'')")
            

            The 'new' file then fails on restart with SU error messages

            it also adds a return after 'end' at 403, but I don't think that will cause problems.

            All I was doing, was changing to show_modal, which works fine when done in external editor.

            362         show_modal do
            

            I'll see if there are any other Mac issues (or solutions) over the next few days and let you know.

            john

            learn from the mistakes of others, you may not live long enough to make them all yourself...

            1 Reply Last reply Reply Quote 0
            • A Offline
              alexschreyer Extension Creator
              last edited by 13 Apr 2011, 13:09

              @driven said:

              there's a parsing issue with complex saved files.

              Hi John,

              It should just be the plugin file. I needed to put the "encoding dance" in there so that those symbols load correctly. That's why I chose something like "<84JSed>" - the chance that another file uses these letters is pretty slim (except for the plugin file, of course).

              Edit the plugin file itself in another editor and it should work fine. Use my editor for any other files.

              Cheers,
              Alex

              Author of "Architectural Design with SketchUp":
              http://sketchupfordesign.com/

              1 Reply Last reply Reply Quote 0
              • D Offline
                driven
                last edited by 13 Apr 2011, 21:51

                hi Alex,

                I had sorted out the editor, edit, and later realised the parsing only effected 'itself'.

                I've been digging out all my Mac code editor 'theme' tweeks and some may interest you, I think there's an IE9 versions of these for example

                .CodeMirror{   background;transparent; color;inherit; border;none; cursor;text;}
                .CodeMirror-gutter{ background-color;transparent; opacity;.5;}
                .CodeMirror-cursor{z-index;10;  position;absolute;  visibility;hidden;  border-left;2px solid #lime !important;  color;transparent;  background-color;transparent;}
                .CodeMirror-lines pre;nth-child(odd){background; rgba(255,255,255,0.1); }
                .CodeMirror-lines pre;nth-child(N);hover{background; rgba(255,0,0,0.2); }
                
                

                these are in addition or overwrite what you've already got.
                I'm also porting a version of my ace theme 'blendin' but I'll need to enable a few more codeMirror functions as I go...

                couple of jquery-ui things don't work and it through me trying to get the line scrolling to work because you use pt instead of px for fonts [px=pt/.75] and it frond upon a bit to use for screen media... The scrolling line were working with pt, but I've swopped pt's to px's or em's for personal convenience.
                the hover and scroller highlight didn't show up in the grab...

                oh, the line only appear if there's code.
                john

                learn from the mistakes of others, you may not live long enough to make them all yourself...

                1 Reply Last reply Reply Quote 0
                • A Offline
                  alexschreyer Extension Creator
                  last edited by 14 Apr 2011, 02:03

                  John, thanks for looking at this so closely. I wanted to put line highlighting in there but didn't get to finishing it. I'll check it out later. Thanks for the CSS suggestions.

                  In the past I found that text could be defined in pt as long as line-height is defined in px (to make line coloring work). I might switch to px at some point - I usually like that better for my web pages.

                  I was thinking about putting the code on Github - I am very happy if others can help out here (or create their own fork). Should I pursue this? I actually haven't used GIT before.

                  Cheers,
                  Alex

                  Author of "Architectural Design with SketchUp":
                  http://sketchupfordesign.com/

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    driven
                    last edited by 14 Apr 2011, 02:22

                    Yes, git seems relatively straight forward, although I've only started using it recently for ace and cloud9 cloning.

                    For a slow start you then get a free cloud9 account, upload a trunk from git, and maybe we could do some interactive editing?

                    I really liked codeMirror, but couldn't sort out the ruby bits for SU and was thinking of asking for your help with either it or ace, when you anounced this.

                    I'll happily jump back to CM as it's so much simpler (after cloud and ace) although I've been running those off my localhost, rather than from inside 'plugin folder' and there's lots of plusses in that.

                    I'm really a Mac man, and most my tweaking is html5 and css3 and a little js, so IE input would be limited.

                    john

                    learn from the mistakes of others, you may not live long enough to make them all yourself...

                    1 Reply Last reply Reply Quote 0
                    • A Offline
                      alexschreyer Extension Creator
                      last edited by 14 Apr 2011, 02:30

                      Great! Would be perfect to have you help work on this because I am mainly developing in Windows and the Mac side is the last thing I look at.

                      I am away at a conference for a week but we can get this started after Easter.

                      Cheers,
                      Alex

                      Author of "Architectural Design with SketchUp":
                      http://sketchupfordesign.com/

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        driven
                        last edited by 22 Apr 2011, 01:51

                        Hi Alex,

                        are you back from your conference?

                        I did a bit of re-jigging of the file folders so that you can have the standard css (CM lang) with the light themes and yours with the dark.

                        I've been trying to add long comments, but my js is even worse than my ruby...
                        shoot me a line when your around and I'll send the files that I tweaked.

                        john
                        I've got all the themes back...

                        I just noticed the moved the theme switcher, but that's just for faster testing....

                        learn from the mistakes of others, you may not live long enough to make them all yourself...

                        1 Reply Last reply Reply Quote 0
                        • A Offline
                          alexschreyer Extension Creator
                          last edited by 29 Apr 2011, 14:29

                          John, those changes look great! And yes, I am back now...

                          I am trying to wrap my head around GIT and it's wrapping very slowly. If I did everything right, then there should be a repository on GITHUB now at the following address that has all of the files in the correct locations. Can someone who knows more about this than I do test this out?

                          Link Preview Image
                          GitHub - alexschreyer/Ruby-Code-Editor-for-SketchUp: A nice-looking code editor for SketchUp. Supports Ruby and various other languages.

                          A nice-looking code editor for SketchUp. Supports Ruby and various other languages. - alexschreyer/Ruby-Code-Editor-for-SketchUp

                          favicon

                          GitHub (github.com)

                          Feel free to use the repository for collaborating on this project once we establish that the files are actually correctly up there.

                          Cheers,
                          Alex

                          Author of "Architectural Design with SketchUp":
                          http://sketchupfordesign.com/

                          1 Reply Last reply Reply Quote 0
                          • D Offline
                            driven
                            last edited by 29 Apr 2011, 14:51

                            hi Alex,

                            yes it's there, almost...

                            you can't actually test or modify without the ui.html and it's support files.

                            do you want to put those in as well, so it's the full monty.

                            when you do I'll see if I can update (what I just downloaded) directly from terminal.

                            adding and 'experiments' folder uploading to would be good as well.

                            john

                            learn from the mistakes of others, you may not live long enough to make them all yourself...

                            1 Reply Last reply Reply Quote 0
                            • A Offline
                              alexschreyer Extension Creator
                              last edited by 29 Apr 2011, 17:03

                              @driven said:

                              ...without the ui.html and it's support files...

                              It should all be there.. ui.html is in there. As far as I understand GIT, you just create a "fork" and start modifying.

                              I just added a v.2.0 tag so that the uploaded snapshot is the same as the last download from my site.

                              Cheers,
                              Alex

                              Author of "Architectural Design with SketchUp":
                              http://sketchupfordesign.com/

                              1 Reply Last reply Reply Quote 0
                              • D Offline
                                driven
                                last edited by 29 Apr 2011, 17:17

                                the tarball doesn't have all the files, I'll have another look

                                john

                                EDIT... but the zip file does, my experience is that the tar should have everything as well...

                                learn from the mistakes of others, you may not live long enough to make them all yourself...

                                1 Reply Last reply Reply Quote 0
                                • A Offline
                                  alexschreyer Extension Creator
                                  last edited by 29 Apr 2011, 17:56

                                  Yep, I am on Windows, so ZIP was my download of choice...

                                  Cheers,
                                  Alex

                                  Author of "Architectural Design with SketchUp":
                                  http://sketchupfordesign.com/

                                  1 Reply Last reply Reply Quote 0
                                  • D Offline
                                    driven
                                    last edited by 29 Apr 2011, 18:03

                                    I made a fork and did an edit on the read-me

                                    a test as much as anything...

                                    john

                                    learn from the mistakes of others, you may not live long enough to make them all yourself...

                                    1 Reply Last reply Reply Quote 0
                                    • 1
                                    • 2
                                    • 2 / 2
                                    • First post
                                      Last post
                                    Buy SketchPlus
                                    Buy SUbD
                                    Buy WrapR
                                    Buy eBook
                                    Buy Modelur
                                    Buy Vertex Tools
                                    Buy SketchCuisine
                                    Buy FormFonts

                                    Advertisement