Giter Club home page Giter Club logo

sketchup-console-plus's Introduction

logo

Ruby Console+

This is a powerful Ruby Console with IDE features like code highlighting, autocompletion and a code editor.
It lets you open multiple independent instances of the console and remembers the command history over sessions.

logo

Requirements

  • SketchUp 2017+
    This extension (originating from 2012 & 2014) has been completely rebuilt to take advantage of modern technologies (the new HtmlDialog with modern JavaScript support, Ruby 2.0).

Installation

  • Go to the releases page (↑) and download the latest .rbz file. Open in SketchUp Window → Extension Manager and select the .rbz file.

  • Alternatively, you can install the contents of the src directory into your plugins folder.

Usage

(Menu) Window → Ruby Console+

There are two modes (Ctrl-Tab ↹):

  • Console The console is a command line interface to try out codes and inspect return values.
    With the Enter ↵ key, code will be evaluated (use ⇧ Shift-Enter ↵ for line breaks, or configure it in the settings menu).

  • Editor The editor is a full-featured text editor. Here you turn code into a script and save it as a file.

Features

  • Tutorials: You don't know any programming? No problem, because SketchUp is the coolest opportunity to get started and it's super easy with the famous "Try Ruby" interactive tutorial that is included with this extension.

  • Autocompletion and doc tooltips: Intelligent live autocompletion tells you not only which methods you can call next on a reference but provides you also with detailed info on how to correctly use them. Use Tab ↹ to accept a suggestion.

  • Entity inspection: Hover an entity or point in the console output and you will see it highlighted in the model.

  • Select Get a reference to an entity in the model by picking it with the pointer.
    No more selecting and doing Sketchup.active_model.selection[0]. By holding the Ctrl key when the main window is focused, you can select points instead of entities and by holding the ⇧ Shift key you can turn on inferencing.

  • Remembers which scripts you reload and reloads scripts automatically whenever they are changed.

  • Clear Clear the console (Ctrl- L )

  • Help Open online documentation for the currently focused word (beta) (Ctrl- Q )

  • Menu Menu with preferences

  • Binding: An advanced feature that allows to step into an object or class and call methods or access instance variables as if you were locally inside of the class source definition. Try to set binding to Math and you can directly call math functions like sqrt without NameError.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Aerilius/sketchup-console-plus/issues.

Development

You can find documentation in the docs folder.

First, run bundle install to install requirements.

Run bundle exec rake test to run the tests.

To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version and push git commits and tags.

To build a new installation package , run bundle exec rake build_rbz.

License

This extension is available as open source under the terms of the MIT License.

sketchup-console-plus's People

Contributors

aerilius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sketchup-console-plus's Issues

Feature highlight array shows two blue frames when hovering array elements

When hovering an element (or array of elements) that can be visualized (SketchUp entity, point, vector), it is highlighted in the console by a blue frame (using css hover rule).
Hovering an element inside an array should only show the blue frame only around the element, not anymore around the array.
issue15
In CSS, if a child element receives the "hover" state, all of its parents also have the "hover" state. It does not deactivate on the parent.

Text in some console window is white on pale grey - almost ureadable

I've just installed the latest version from Extension Warehouse - 3.1.4 (which is now a later version than on SketchUcation - 3.0.2).

I'm using SU 2019 Pro on Mac Mojave.

When I click on the three-bar menu top right in the RubyConsole+ window, the pop up dialogue is white text on a pale grey background, and I can't read any of it until I hover the mouse over a part of it.

Looks like this when no mouse-over:
image

or like this with the mouse over the top line - revealing 'New' in black. Same for other input boxes.
image
Is there any way I can patch this, or do I need to wait for an update?

Some stdlib documentation is missing.

Some stdlib docs are missing from apis in DocProvider. Find out whether yardoc was not able to find or extract them from Ruby C source code or whether our generate_ruby_apis.rb excludes them from the generated apis.

Test case:

AE::ConsolePlugin.DocProvider.get_infos_for_doc_path('FileUtils')
>> []

This should include doc info for FileUtils.cp

Error when transfering strings with non-UTF-8 compatible bytes

When a string with non-UTF compatible characters (e.g. binary string) is output, a JSON::GeneratorError is raised.

Example:

s = "\xFF"; nil # First byte of an image read with Sketchup::ImageRep
> nil
s.encoding
> #<Encoding:UTF-8>
s
>  Uncaught promise rejection with reason [JSON::GeneratorError]: "partial character in source, but hit end"
s.valid_encoding?
> false

In SketchUp's native console, the string is output without error (although characters are not necessarily displayed).

Ruby Console+ should behave at least as good as the native console.

ReferenceError: ace is not defined

Unexpected Behavior

Editor

  • No Syntax highlighting
  • No auto-indenting or other formatting nicities
  • Autocomplete and tooltips are inconsistent--they seem not to appear on any attributes or methods after the first value. (ie, both will appear for Sketchup but not Sketchup.active_model)
  • No entity inspection

Other

  • When you click the ?, the Documentation window is blank

Error Message

After opening the Ruby Console+ window, the following error message appears:

(JavaScript) ReferenceError: ace is not defined
    at ~/Library/Application%20Support/SketchUp%202022/SketchUp/Plugins/ae_console/external/ace/mode-ruby_sketchup.js:1:1
(JavaScript) Error: Script error for "ace/mode/ruby_sketchup"
http://requirejs.org/docs/errors.html#scripterror
http://requirejs.org/docs/errors.html#scripterror
    at makeError (~/Library/Application%20Support/SketchUp%202022/SketchUp/Plugins/ae_console/external/requirejs/require.js:5:1067)
    at HTMLScriptElement.onScriptError (~/Library/Application%20Support/SketchUp%202022/SketchUp/Plugins/ae_console/external/requirejs/require.js:5:13218)

Environment Information

  • Machine: MacBook Pro 2021 (arm64, Apple M1 Max)
  • OS: macOS Ventura 13.2.1
  • SketchUp: SketchUp Pro 2022 Version 22.0.353, SketchUp Pro 2023 Version 23.0.418
  • Ruby Console+: 3.14, 3.17
  • RUBY_VERSION: 2.7.7

Some core/stdlib documentation has bad formatting

The autocompleter doc tooltip displays poorly formatted text for RDoc extracted from C source code.
For example there are no line breaks and formating syntax like + _ * is visible. Parameters seem not to be extracted into parameter tags.

Are these cases where the doc is written too much human-style that yardoc cannot extract parameters?
Is there a yardoc method that returns html-formatted description? Should we otherwise try to convert RDoc formatting into html (RDoc stdlib, markdown javascript)?
Do we need to convert \n into <br/>?

Test case:

Type in the console or editor Kernel.block_given?

Mark erronous input lines in the output if code evaluation raises an error

When input code is evaluated with an error, the user sees line numbers in the backtrace (with eval as filepath) and looks them up above in the code that was previously input.

  • Check whether an error was caused by console input.
  • In the output module, find the input entryElement and mark the gutter at the correct line number.

How to handle failed documentation lookup?

Currently, clicking ? always opens the documentation browser (if not yet open) and navigates to an error page. Especially in the editor, type inference is very likely unsuccessful and the appropriate documentation cannot be looked up (not to speak of tokens in custom scripts).

  • Provide a hint in advance on which tokens documentation is available? (unfeasible, would require checking type on every token in the text)
  • Don't show documentation browser, but a notification about the failure?
  • Add to the error page a searchbox or link to a search engine? Which search engine?
  • Add to the error page links to the overview pages of Ruby Core and SketchUp documentation

Extension using `.singleton_class`?

There is a bug in SketchUp:

model = Sketchup.active_model
#> #<Sketchup::Model:0x0001f5157b03e8>

model.title

model.singleton_class
#> #<Class:#<Sketchup::Model:0x0001f5157b03e8>>

model.title
Error: #<TypeError: wrong argument type (expected Sketchup::Model)>
#> <main>:in `title'
#> <main>:in `<main>'
#> SketchUp:1:in `eval'

I've identified it and found a fix. (Logged as SU-38280) But, this affects all existing versions of SketchUp.
And I see the same behaviour if I simply call model = Sketchup.active_model from this console. so I was wondering if there are somewhere in this extension that it calls .superclass in model objects? (This bug happen only on Sketchup::Model.

And if so - is there a way we can work around that until we got a fix released in SketchUp? (And a workaround for older versions?) When this happens the model object becomes useless.

Documentation search not working?

I'm not sure if I'm using this correctly or not. The readme says:

Open online documentation for the currently focused word

Does focused here mean "selected"? Or where the cursor is placed in the text editor?

I tried to step through the code and it appear that getCurrentTokens return and empty array. That in itself returns early after the first call to getCorrectedCurrentToken. position yields 0,0 regardless of where the text caret is located in the editor.

Intro to Sketchup tutorial fails on first step?

Hello, I really like your console

I am trying to use the tutorial 'Introduction: Finding your way through SketchUp, Step 1

It says: "Type Sketchup.active_model'
When I do so, it presents an error
wrong argument type (expected Sketchup::Model)

If I type
Sketchup::Model
wrong argument type (Expected Sketchup::Model)

it says the same thing...

I am using Sketchup Make 2017 on Mac OS

If I type either of these into the actual ruby console, I get the expected object reference
#Sketchup::Model:0x007f85588eaa28

thank you for any clues

Draw 3d normals using view.draw?

I find it a challenge to properly see the direction of normals when they use draw2d and appear on top of geometry.

I have in some extensions drawn 3D first in solid strokes, then used draw2d on top with a stippled stroke so that you get a "ghosted" appearance when the 3D stroke is obscured. I guess a transparent fill in 2d would also work...

Clicking ace editor removes focus in WebDialog/MSIE

When running the plugin with a WebDialog (e.g. ≤ SU 2016) instead of HtmlDialog, a click into the ace editor removes focus from it so that the characters that you type don't appear. It feels like an invisible layer would occlude the ace editor and catch mouse clicks.

However focusing itself works (through script, after menu actions, after switching console/editor).

Display file paths in error trace as a links

It would be useful if the console would render file paths in output as links. This will allow developers to click on line in error trace and open the exact location where the error was raised.

Not starting in Sketchup 2024

Extension Errors Report
SketchUp: 24.0.484
OS: Windows 10 
Ruby: 3.2.2

Extension: Ruby Console+ (3.1.7)
Error: TypeError (allocator undefined for #<Class:0x0000018f595f9f80>)
C:/Users/hannes/AppData/Roaming/SketchUp/SketchUp 2024/SketchUp/Plugins/ae_console/core.rb:125:in `new'
C:/Users/hannes/AppData/Roaming/SketchUp/SketchUp 2024/SketchUp/Plugins/ae_console/core.rb:125:in `initialize_plugin'
C:/Users/hannes/AppData/Roaming/SketchUp/SketchUp 2024/SketchUp/Plugins/ae_console/core.rb:213:in `<module:ConsolePlugin>'
C:/Users/hannes/AppData/Roaming/SketchUp/SketchUp 2024/SketchUp/Plugins/ae_console/core.rb:3:in `<module:AE>'
C:/Users/hannes/AppData/Roaming/SketchUp/SketchUp 2024/SketchUp/Plugins/ae_console/core.rb:1:in `<top (required)>'
C:/Program Files/SketchUp/SketchUp 2024/Tools/extensions.rb:197:in `require'
C:/Program Files/SketchUp/SketchUp 2024/Tools/extensions.rb:197:in `load'
C:/Users/hannes/AppData/Roaming/SketchUp/SketchUp 2024/SketchUp/Plugins/ae_console.rb:26:in `register_extension'
C:/Users/hannes/AppData/Roaming/SketchUp/SketchUp 2024/SketchUp/Plugins/ae_console.rb:26:in `<module:ConsolePlugin>'
C:/Users/hannes/AppData/Roaming/SketchUp/SketchUp 2024/SketchUp/Plugins/ae_console.rb:7:in `<module:AE>'
C:/Users/hannes/AppData/Roaming/SketchUp/SketchUp 2024/SketchUp/Plugins/ae_console.rb:5:in `<top (required)>'

Make file paths in error messages links to open the file in editor

When an error occurs, the backtrace in the output contains file paths. If these source files are found/exist, a user could click a link that opens in the editor at the correct line number.

  • Whether files in backtraces exist must be checked on the Ruby side.
  • The output module does not know about the editor. How should it make links that call the open on the editor without introducing a dependency?
  • Check whether this can be realized as a feature instead of core functionality. Do we need to emit new events?

Use yard directly in SketchUp?

Currently we rely for type inference on return types extracted from yardoc documentation. These extracts (in the apis directory) also contain description and parameter information to generate documentation tooltips.

  • We would not have to generate the extracts using yard2hash.rb and could directly load any custom .yardoc.
  • DocProvider.get_info_for_doc_path(doc_path) could be replaced by YARD::Registry.at(doc_path)
  • Yard supports inheritance in its lookups, which our type inference by documentation does not have yet.
  • Ease of installation? We would depend on a gem that needs to be installed first.
  • Memory consumption? It would load much more code into SketchUp and add more complexity.

Trace information not displayed on error (Win)

In SketchUp 2016, Windows, in case of an error no trace information is displayed in the console - this makes error tracking impossible without reverting to the native console.

For comparison:

Output of native SketchUp console (filename, linenumber being displayed):

errortest()
Error: #<NameError: undefined local variable or method `oops' for main:Object>
Filepath/Filename.rb:LineNo:in `errortest'
<main>:in `<main>'
SketchUp:1:in `eval'

Output of Console+:

errortest()
NameError: undefined local variable or method `oops' for main:Object

Repeated output no longer displayed after console clear

Instead of displaying consecutive identical output lines multiple times (in a new line each), RubyConsole+ diplays a count number on the righthand side, saving space.
If the console is cleared, repeated output is not displayed anymore.

Demonstration-tool outputting text on mousemove:

class RepeatedOutput
  def onMouseMove(flags, x, y, view)
    puts "repeating myself..."
  end
end

activate the tool with:
Sketchup.active_model.select_tool(RepeatedOutput.new)

Now, with the mouse cursor over the SketchUp window, the output counter for "repeating myself..." in the console goes up with each movement.
After pressing the clear button in the console window, nothing is displayed anymore - even though the tool is still active.

Without looking into the sources, i guess the last output is cached internally. If the next output line happens to be exactly the same, it's not displayed but the counter is increased instead.
Clearing the cache and counter together with the console should then fix the issue.

Multiple warnings when on a Portuguese version

If Sketchup is translated to Portuguese, multiple warnings are shown every time I type in the console, like this one:

warning: key "Return value" not found for locale pt-BR (AE::ConsolePlugin::Translate)
C:/Users/[...]/AppData/Roaming/SketchUp/SketchUp 2017/SketchUp/Plugins/ae_console/features/docprovider.rb:91:in `get_documentation_html'

Backward compatibility

Having developer tools support older SketchUp versions helps extension developers to debug when they want to support users of older SketchUp versions.

  • Which versions of Internet Explorer do we want to support?
    This means avoiding modern JavaScript features and eventually debugging and patching ace…
  • Bridge works significantly different for HtmlDialog (mostly the Bridge API) and WebDialog (message pipe and asynchronous dispatch, hidden text element). Most changes are in the Request Handler. Probably we need to load specific files depending on which dialog we use.
  • Which versions of Ruby do we want to support?
    Check for used Ruby 2.2.4 / 2.0.0 features, e.g. changes to Binding.
  • If not adding backwards compatibility, we could use require_relative instead of composing absolute paths.

super laggy some times

in some ocassions , there is seconds of delay to type a letter.
the reason is unknown.
when this happens, typing at the start of the code is normal. but super laggy typing in the end

Load error, ruby 3

SketchUp Alpha 94 throws a load error:

Error Loading File /Users/marioch/Dropbox/Y plugins/ae_console/core.rb
Error: #<TypeError: allocator undefined for #<Class:0x000000013436e888>>
/Users/marioch/Dropbox/Y plugins/ae_console/core.rb:125:in `new'
.........

Highligher for array of points?

Often you have arrays of points, representing polygons.

Do you think it'd be possible to detect such arrays in the output buffer and create a highlighter for that? Hover over each point is nice to pick out individual points, but maybe if you hovered over the array brackets it displayed everything?

Challenge is that some points you want to just display a point set, some times segments. Maybe simple toggle modes in the visualizer?

Tutorials

Hi
Will you bring out step by step tutorials to go with your very great app I find thr console + great.. with tutorials it will be even greater!!!

undefined local variable or method `cp'

Error: #<NameError: undefined local variable or method `cp' for #<AE::ConsolePlugin::EntityHighlightTool:0x0000028c31d83618>>
C:/Users/Thomas/AppData/Roaming/SketchUp/SketchUp 2020/SketchUp/Plugins/ae_console/features/entity_highlight_tool.rb:309:in `block in draw'
C:/Users/Thomas/AppData/Roaming/SketchUp/SketchUp 2020/SketchUp/Plugins/ae_console/features/entity_highlight_tool.rb:252:in `each'
C:/Users/Thomas/AppData/Roaming/SketchUp/SketchUp 2020/SketchUp/Plugins/ae_console/features/entity_highlight_tool.rb:252:in `draw'
C:/Users/Thomas/AppData/Roaming/SketchUp/SketchUp 2020/SketchUp/Plugins/ae_console/features/feature_select_entity.rb:220:in `draw'

I only glanced at the code, but I think cp should be center:

center = entity.bounds.center
# Diameter; consider a minimum for Drawingelements that have no diameter
diameter = [entity.bounds.diagonal/2.0, view.pixels_to_model(5, cp)].max

Minor rendering issue in output gutter

The output gutter (left gray bar) imitates ace's gutter. When inserting long text into the ace input field, a section of the output gutter turns white.

Idea: In-console visualizations

I was doing some improvements to my Transformation Inspector and I got an idea for Console Plus I wanted to run by you:

Allowing return value lines to have visualization widgets in-line in the console. This wouldn't be far off from the visualization already done for vectors etc in the viewport.

Some things like Transformations can't be visualized in the viewport, but it would be nice to bring up a better view of it in the console. For example:

image

This could also be extended to other things, for instance:
An array of points. The console widget could be expanded to some options:

  • Points
  • GL_LINES. GL_LINE_LOOP, ...
  • draw3d, draw2

Would be very useful for visually debugging and experimenting.

Is this something you'd be interested to feature in this extension? Would you accept PR for this?

Warning upon launching Console+ 3.1.3

After updating Console+ to 3.1.3 I see this warning in the Ruby Console upon start of SketchUp:

warning: key "An alternative Ruby C"... not found for locale en-US (AE::ConsolePlugin::Translate)
C:/Users/tthomas2/AppData/Roaming/SketchUp/SketchUp 2018/SketchUp/Plugins/ae_console.rb:23:in `<module:ConsolePlugin>'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.