[plugin] Ruby Code Editor - UPDATED to v3.0 3/4/2013
37 posts
• Page 1 of 2 • 1, 2
[plugin] Ruby Code Editor - UPDATED to v3.0 3/4/2013Hi All,
Please see my other forum post for details and all updates: http://sketchucation.com/forums/viewtopic.php?f=323&t=25800 Cheers, Alex Last edited by alexschreyer on Tue Mar 05, 2013 4:38 pm, edited 2 times in total.
Author of "Architectural Design with SketchUp":
http://sketchupfordesign.com/
Re: [plugin] Ruby Code Editor - 1.1 UPDATEtried to leave this at your site,but not sure it worked??
Hi Alex, I've been using v1 quite a lot , teaching myself ruby on a Mac and I put together a list of slight oddities to post, however I'll now check them against the new version before bothering you, keep up the good work, every bit helps, even the oddities... john learn from the mistakes of others, you may not live long enough to make them all yourself...
Re: [plugin] Ruby Code Editor - 1.1 UPDATEHi Alex,
possibly a quick fix required, I always get the open link format on restart even after setting options WebConsole show's _modal on the Mac, this doesn't ... (or whatever I should call not vanishing behind SU) I may have modified WC, can't remember, I'll reload a clean one and check... I can't see where I might modify this or the last version john learn from the mistakes of others, you may not live long enough to make them all yourself...
Re: [plugin] Ruby Code Editor - 1.1 UPDATE
Not sure what you mean by this. I have to admit that I haven't tried either version on a mac yet. I'll do that soon but in the meantime keep any bugs coming my way... Cheers, Alex Author of "Architectural Design with SketchUp":
http://sketchupfordesign.com/
Re: [plugin] Ruby Code Editor - 1.1 UPDATEI have to right click to get to the drop down box, then click load link
I always get this page on when selecting RCE learn from the mistakes of others, you may not live long enough to make them all yourself...
Re: [plugin] Ruby Code Editor - 1.1 UPDATE
Yuck! That is indeed a glitch. It is only happening in Safari/Chrome. So for now that's a problem only for mac users. I'll fix that later today. Thanks for letting me know. Cheers, Alex Author of "Architectural Design with SketchUp":
http://sketchupfordesign.com/
Re: [plugin] Ruby Code Editor - 1.1 UPDATEDang... Alex we are supposed to use the same original thread, and post the plugin in the first message. Then when updated, you replace the file attachment there in the first message.
(But in your case, you'd update the link to the download.. same difference.) As the thread 'starter' you can can change the Topic to reflect '[UPDATE]' and release version. etc. That way.. (1) there is not a separate thread for each new release. (2) Since I posted in the original thread, I expected (when an update came,) to see the thread pop to the top of the 'Your Posts' page (which is kind of my 'homepage' at SCF, how I enter the site.) {Maybe ThomThom can stitch the 2 threads together if you agree.]
Re: [plugin] Ruby Code Editor - 1.1 UPDATE@Dan: I can do that the next time. I did put a note on the last thread mentioning that there is an update available at the same address. And the last thread went a little off-topic after a while, so I thought this would keep things clean.
The main download location is still my website, so at least there are no old versions floating around. Cheers, Alex P.S. WebKit doesn't seem to want to save cookies from a local page somehow, so I might have to do a local preference storage (as suggested before) after all... Author of "Architectural Design with SketchUp":
http://sketchupfordesign.com/
Re: [plugin] Ruby Code Editor - 1.1 UPDATE
OK. no problem... I've posted here so this thread popped to the top, when you posted.
Well I've already done the work.. let me have a look at as_rubyeditor.rb, and I'll get back to ya' today or tomarrow.
Re: [plugin] Ruby Code Editor - 1.1 UPDATEas ruby code editor ver 1.1
MSIE ver 7.0.5730.11 Errors: (1) ui.html - Line 113 - invalid argument <a class="button" onClick="u();" ... > removed ";" and error went away <a class="button" onClick="u()" ... > .. but then (after reloading page,) (2) ui.js - Line 165 - Char 3 - Object doesn't support this property or method [seems that line wants to load stylesheet(s)] ... the page looks exactly like driven posted for the Mac. (but with MS fonts)
Re: [plugin] Ruby Code Editor - 1.1 UPDATEJust a quick update:
- I fixed the cookie issue. Apparently I needed a path to save the cookies. Although Chrome won't save local file cookies, Safari will do that. So we're okay with all preferences and saving them locally. - I fixed the reference browser back button issue. Now in Safari only the iframe gets navigated. I'll upload a new version with those fixes later today. The remaining issue is that the function that inserts text at the cursor (tab key and snippets) works fine in IE but not in FF/Safari. I'll look into that. Then I'll also finally try this out on a mac. Cheers, Alex Author of "Architectural Design with SketchUp":
http://sketchupfordesign.com/
Re: [plugin] Ruby Code Editor - 1.1 UPDATEExcellent ....
learn from the mistakes of others, you may not live long enough to make them all yourself...
Re: [plugin] Ruby Code Editor - 1.1 UPDATE
Actually I see a few (in as_rubyeditor.rb) (1) You removed the module wrapper around the dialog class !!! This is a no-no. ONLY Ruby Baseclasses (like Integer, String, Module, Class .. etc.,) should be defined at the TOP_LEVEL, in the Objectspace. The lightweight version I'm working on (update to Jim's) will be double wrapped, something like: SUutil::Ruby::WebConsole (2) down ~line 181 # Callback to undo the last code execution add_action_callback("undo") do |d, p| (a) Just want to stress (seeing your code comment,) that Undo is a Sketchup function, not a Ruby function. It only undoes changes to the model. It does not undo ruby statements. For instance, if you define a method, run it, and click undo; The method is still defined in Ruby (whether right or wrong.) The same holds true for variables, constants, object instances, etc. (b) I consider using 'p' as a varname dangerous because of method Object.p (and try to avoid single char varnames; usually put a number like t1, t2 for time vars, or x1,y1 for coords, etc. Jim had a weird bug in a previous version that had to do with the use of 'd' as a varname, see:Sketchup Developer's Google Group post: "What is so special about d?" * For WebDialog callbacks I've settled on a personal standard |dlg,arg| (3) Instancing. (a) The way it's written now (ie the way Jim had it,) the object constructor is within the menu item block, and creates a new instance each time the menu (or toolbar button,) is clicked. When the .close method is called, it's only the OS window object (and it's instances of the webpage, CSS and Js that are destroyed,) along with any text in the HTML controls. But the Ruby UI::WebDialog instance object still exists, and can be reshown. When this happens, Sketchup Ruby reloads the webpage assigned to it. Anyway think about that for a future revision. (b) I think I will limit my version to two (2) instances and greyout the "new" menu item after that. (A user can only 'cut & paste' between two windows at a time.) I'm also going to dynamically add links to the menu as the instances are created, so those instances can be reused, rather than waste memory. (c) This brings up the problem of Preference control. Which window will be (or should be,) allowed to update the settings? It takes a bit of thought, as I wish to have each instance save it's own size and position, and likely for the Mac, whether individually they will be 'always on top' or can go behind other windows, including SU. _
Re: [plugin] Ruby Code Editor - 1.1 UPDATEHi Dan, Thanks for those points. My comments:
1) I believe I kept that as it was but I'll add that. 2) I see this code editor more for people that use it for geometry creation in SU rather than for the Ruby programmer (although they should find it useful, too). So the undo option is meant for undoing the SU action. Also, if you compare my code to Jim's, you see that I like verbose and commented code - I find it helpful for myself and for whoever uses it next. So I also prefer longer variable names. 3) Until there is a multi-file version of the editor, the multi-instance option is actually useful. Question: On close, can I destroy an instance like "UI::WebDialog = nil". Good point about the instance preferences. Haven't thought about that yet. I am still fighting with Browser issues. I thought using jQuery would eliminate those. So cookies that save in Safari don't do so in IE. Cheers, Alex Author of "Architectural Design with SketchUp":
http://sketchupfordesign.com/
Re: [plugin] Ruby Code Editor - 1.1 UPDATEI just uploaded a newer version (1.1.1) that should fix some of the Safari issues. Now the page should at least load without complaint and the editor is usable. Some of the quirks I found:
- It doesn't seem to be possible to access an iframe's browser history in Safari. Therefore I had to remove the Back/Forward buttons when the editor gets used on a mac. - Cookies are handled differently in all browsers. So preference storing works fine in Windows, but may not work on the mac. Next step is to use a local storage for that. - I couldn't get caret positioning working 100% in Safari. Text and tab insertion works fine but the caret jumps around afterwards. Everything should work as expected in Windows, though. I can't believe that this time IE works fine and Safari is acting up. Cheers, Alex Author of "Architectural Design with SketchUp":
http://sketchupfordesign.com/
Re: [plugin] Ruby Code Editor - 1.1 UPDATEOK just so you know, and hopefully the users will also. I thought of a scenario: What if a user wishes to actually experient themselves with the undo API feature, writing the .start_operation, .commit_operation calls into the snippet editor? What would happen in ruby with double nested operations? Perhaps a checkbox next to the UNDO button to turn on|off the editor's Undo calls, ie(as_rubyeditor.rb): line 74: Sketchup.active_model.start_operation "RubyEditor" if @undo_is_on line 82: Sketchup.active_model.abort_operation if @undo_is_on line 84: Sketchup.active_model.commit_operation if @undo_is_on Agreed, and actually even with a multi-file version (if you don't have a split screen feature,) then allowing two instances can satisfy those who'd want a split screen feature, (ie: 'cut & pasting' between two windows.) But we need to control instancing, and limit it (with a default limit, which might be overridden by the user.) I'm using a class variable: @@max_num Garbage Collection. You would not set the class to nil. You are suppossed to be able to set the instance to nil and then call GC.start, but I've never witnessed GC disposing of the instance variable. It just sits around with a nil value (at least it's not taking up much space.) So .. dlg=Namespace::RubyEditor.new( arglist ) #.. set it up.. show it .. use it .. close it dlg=nil GC.start Anyway... in this case: we first must use a symbol to hold a reference to each instance. In editor code (line 205) in the add menu item command block you have (as Jim did,): "RubyEditor.new" which is not storing a reference to the instance, even though the object.new method always returns a reference to the newly created instance of the object class (which is the third main task of the new method in ruby.) I'm using an Array class variable: @@instances=[] and when I construct the instance, I push it's reference into the array: if @@instances.size < @@max_num __num = @@instances.size+1 __if dlgi = WebConsole.new(num) # non-nil if success ____@@instances.push( dlgi ) ____# add menu link for instance __end end The num var is used both to insert into instance menu text (similar to an editor's untitled(1), untitled(2) captions,) and is passed to new, so the instance itself can know which one it is (it's position in the class array var @@instances,) and to append as text onto the instance's Preferences Key suffix. All that if block, above is wrapped within a UI::Command class instance @@cmd __
Re: [plugin] Ruby Code Editor - 1.1.1 UPDATEBY the way... you announced a ver 1.1.1, but...
The Revision block at the top of as_rubyeditor.rb says version: 1.2 (The extension registration/loader script says version: 1.1.1) The thread topic (title of the first post,) still says version 1.1
Re: [plugin] Ruby Code Editor - 1.1 UPDATE
I keep missing those little details... Thanks!
Great idea. I'll put this into the preferences section, though.
Thanks for the detailed explanation. I'll look at it. But zooming out a little: It seems to me that we could maybe work more effectively on this if it were a collaborative project. I haven't worked with Github or similar systems before, but from what I understand it is made for stuff like this. Would you (and anyone else interested, of course) want to move this to a collaborative project? Cheers, Alex Author of "Architectural Design with SketchUp":
http://sketchupfordesign.com/
Re: [plugin] Ruby Code Editor - 1.1 UPDATEWow -- very nice and helpful plugin! I almost wish I could run it outside of SketchUp
![]() Have you thought about adding syntax highlighting? Something to pop out basic Ruby keywords and SketchUp-specific keywords?
Re: [plugin] Ruby Code Editor - 1.1 UPDATE
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 Author of "Architectural Design with SketchUp":
http://sketchupfordesign.com/
Re: [plugin] Ruby Code Editor - 1.1 UPDATE
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
Re: [plugin] Ruby Code Editor - 1.1 UPDATE
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-ri ... ode-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/
Re: [plugin] Ruby Code Editor - 1.1 UPDATEHi 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...
Re: [plugin] Ruby Code Editor - 1.2 UPDATEJust updated to version 2.0. Download in the same location as before.
Cheers, Alex Author of "Architectural Design with SketchUp":
http://sketchupfordesign.com/
Re: [plugin] Ruby Code Editor - 1.2 UPDATEhi 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
becomes
and also
becomes
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.
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...
Re: [plugin] Ruby Code Editor - 1.2 UPDATE
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/
Re: [plugin] Ruby Code Editor - 1.2 UPDATEhi 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
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. 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...
Re: [plugin] Ruby Code Editor - 1.2 UPDATEJohn, 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/
Re: [plugin] Ruby Code Editor - 1.2 UPDATEYes, 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...
Re: [plugin] Ruby Code Editor - 1.2 UPDATEGreat! 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/
37 posts
• Page 1 of 2 • 1, 2
|
Who is online
Users browsing this forum: alvaroramiro, Dave R, fredo6, jhonfcastro96, studiokodok, WPALACIN, xping2020 and 15 guests