Sticky Scroll with custom language - vscode-extensions

In vscode, the new Sticky scroll doesn't seem to work out of the box with my custom language extension. Is there some interface my language needs to implement in order to support it?

The new Sticky Scroll feature seems to be based on the language elements (class/interface/namespace/function/method/constructor) being recognized, and available in the Outline view. This means your custom language must have a Language Server or any other tooling that provides such elements to the editor.
If your language does provide that, but is not being properly supported in the new Sticky Scroll feature, I suggest you to open an issue in VS Code repo. As you can see (https://github.com/microsoft/vscode/labels/editor-sticky-scroll), there are a few issues reported.
Hope this helps

That could change with VSCode 1.72 and issue 157165 "Add option to base Sticky Scroll on indent, not Document Symbols"
Basing Sticky Scroll on class/function/namespace etc. makes a lot of sense, but only as long as there is an active language server or language extension that provides good Document Symbols (Outline).
For all languages that either have no LSP (so, so many), whose LSP provides no Outline, whose LSP provide invalid Outline or which simply have no concept of functions/classes etc., Sticky Scroll can not be leveraged :-(
I'd argue that in many cases the respective context could be inferred from the indentation instead.
I realize this may not be desirable by default, so perhaps it should be either hidden behind a flag or configurable per language. For example, in a large JSON file, you might then get this context:
1 {
51 "a": {
52 "b": [
-----------------------------------------------
74 "current_line",
75 "..."
Personally, I'd like to have SS in CoffeeScript, Crystal, AutoHotkey, Markdown, JSON, and pretty much everywhere else except maybe plain text files.
This implemented with PR 159198;
When no document symbol provider use the folding model for the sticky scroll:
This is available in VSCode insiders today.

Related

cytoscape show traffic between nodes along an animated path

I need to show things moving between nodes along their connection paths similar to this project. I haven't been able to find any examples of it in cytoscape, but I have used cytoscape in the past and prefer to keep using it for this as well. I would appreciate recommendations on how to approach this problem.
You've got a few options...
The easiest is the Marquee visual style. It produces a "marching ants" illusion in the direction of directed edges. Simply to the Styles tab in the Control Panel and select the "Marquee" style. In the EDGE tab, you can choose from 3 different Marquee Line Types. You could imagine mapping these 3 line types to 3 categories (or bins) of traffic density, for example. Or you could use color, thickness and/or transparency in combination with a marquee style to represent traffic density. You can see an example here:
https://youtu.be/MF0zsxEPoPc?t=44
There's also an app for animation! This takes the approach of interpolating any visual style (including position and existence) between any set of key frames you provide. So, for example, you would have a start and finish frame and then CyAnimator would make a movie file for you:
http://apps.cytoscape.org/apps/cyanimator
And yet another completely different approach: with the scripting capabilities of Cytoscape, you can pretty much do whatever you want. The Unit tests for the RCy3 package, for example, ends up being an almost psychedelic display of data vis potential (and the unit tests aren't even at full coverage, shame). So you could direct your own animations in real time with a bit of scripting in R or Python. Here's the RCy3 unit test demo and links to the scripting libs:
https://www.youtube.com/watch?v=IXqbdlUnzUE&t=1s (caution: flashing graphics)
https://bioconductor.org/packages/release/bioc/html/RCy3.html
https://py2cytoscape.readthedocs.io/en/latest/
I'm using cytoscape.js with meteor.js. My elements, stylesheet and vehicles (shown as red dots) are stored in mongo, and can be updated via an external process or edited on-screen. The graph can be restructured or reshaped on the fly, and the vehicles will discover the new least-cost route to reach their target. Moves are queued with eles.animate() Routing is handled by eles.floydWarshall().path(). This might be similar to what you had in mind.

switching between languages in same file

I recently attended a user group meeting where the IntelliJ representative was demonstrating version 13.
He demonstrated how to switch the code completion view of a file. I do not exactly remember what the file extension of this particular file was, probably java.
The concept was that if the file is html with embedded javascript he could then switch the code completion between html and javascript with a shortcut. If he says treat the file as html then all code in file was treated for code completion purposes as html, and vice versa for javascript.
Does anybody know what shortcut he might have been using to enable the language switch?
Sounds like you may be referring to the IntelliLang feature. IntelliJ IDEA can be aware of other languages embedded within a file.
A simple example is in an HTML file that has CSS and JavaScript.
Notice when I am inside the HTML markup:
or inside an HTML element:
The code complete shows HTML completion options. However, when I am inside the style attribute, I get CSS code completion:
I also get CSS code completion if I am inside a <style> element. So even though I am in an HTML file, I see CSS code completion because of my location.
Same case with JavaScript. When I invoke code completion inside a <script> element, I get JavaScript completion, even though I am in an HTML file.
Anytime IntelliJ IDEA can determine that another embedded language is present, it provides, via IntelliLang, the appropriate syntax highlighting, error highlighting, and code completion. The same holds true for Java. Notice here that IDEA knows the method I am competing takes an SQL statement and therefore highlights the String value using SQL highlighting, and provides SQL code completion:
So even though I am in a .java file, I get SQL code completion. The reason is that IntelliLang comes pre-configured knowing the embedded language of some methods. You modify them, or add more, in File > Settings > [Project Settings] > Language Injections.
In addition, you can use an annotation to tell IntelliJ IDEA (as well as developers looking at the code) that a String must be valid in a particular language. For example, I can annotate a String field, variable, or parameter, to indicate it must be valid HTML:
Notice I get HTML syntax highlighting, HTML code completions, and the CSS color shows in the left gutter. If I annotate a method parameter, then any time I call the method, I get the appropriate syntax highlighting, code completion, and error/warning highlighting:
The #Language annotation is inside the annotations.jar that is contained in the redist directory inside the IntelliJ IDEA installation directory. It is also available in maven central, or IDEA will offer to attach it as a Library if you use the annotation without it being attached.
IntelliLang and the #Language annotation supports a large number of languages. Just use code Completion inside the quotes after typing #Language("") to see a list. (Inline search works in the list as well.) One of the most useful is Regexp. For example, if you have a method that expects the string passed in to be a valid Regular Expression, annotating it as such will give anyone that calls it Regex code completion and error highlighting if they are passing in an invalid Regex pattern. Even for developers using other IDEs it is useful as a form of documentation.
As for a shortcut to change the the language on the fly for code completion, the only thing I can think that you might be referring to is the "Inject Language" intention. If I am entering a String value, and I bring up the quick-fix/intention menu via Alt+Enter, I am given an option to inject a language:
If I select that, IntelliJ IDEA will ask me what language I want to use:
After making my selection, IntelliJ IDEA will give me temporary language injection (including code completion) for the selected language.
It also gives me an option to add the #Language annotation for permanent injection.
To the best of my knowledge (as a 10 year IntelliJ IDEA user) that is the only way to switch code completion language types. So hopefully that is what you are looking for. To me, IntelliLang is one of the coolest features in IntelliJ. (It actually started as a third party plug-in and JetBrains then absorbed it into the product.)

pygtk spinbox style: gimp-like

In GIMP the spinboxes they use for brush sizes allow for
manual typing
up-down spinning
They also provide a bar that can be dragged which provides a nice indication of the range that spinbox can take.
Is this possible with pygtk?
You probably want to use Gtk.SpimButton and Gtk.Scale:
https://developer.gnome.org/gtk3/stable/GtkSpinButton.html
https://developer.gnome.org/gtk3/stable/GtkScale.html
These are the GTK+3 version but you can also find them in GTK+2 but I strongly suggest not to use PyGTK2 since it's not maintained anymore, use the introspection bindings instead through PyGobject:
https://wiki.gnome.org/action/show/Projects/PyGObject
You also have a tutorial:
https://python-gtk-3-tutorial.readthedocs.org/en/latest/index.html
and the API reference:
http://lazka.github.io/pgi-docs/
http://lazka.github.io/pgi-docs/api/Gtk_3.0/classes/SpinButton.html
http://lazka.github.io/pgi-docs/api/Gtk_3.0/classes/Scale.html

How do I control polymorph sizes using UITheme builder

I am trying to create a Dominion game in Smalltalk, and I can't get the layout of the GUI the way I want.
Currently, I have this as code to build the GUI:
open: game
| builder content |
builder := UITheme builder.
content := builder
newColumn:
{(builder
newListFor: game
list: #supplyStrings
selected: nil
changeSelected: nil
getEnabled: nil
help: 'Supply') .
(builder newRow: (game players collect: [ :p | self morphForPlayer: p usingBuilder: builder ]))}.
gui := (content openInWindowLabeled: 'DominionGame') extent: 1024 # 768
(forgive the poor Smalltalk style, I've been using Smalltalk for a week).
I am getting the basic idea of what I want: a window with the top portion common to all players, and a bottom portion divided into sections for each player.
The trouble I have is that the top portion is too big, taking up about half the window, and I don't know how to fix that.
I've tried adding "vsizing: #shrinkWrap" to the builder for the #supplyStrings list, but that made it too small, forcing the contents to use a scrollbar; I've tried adding "extent: 1024#200" to that morph, and saw no effect.
So I have two questions:
1) How do I get finer layout control over the objects built with UITheme builder?
2) Where can I find documentation on how to do UI design using Pharo? I'd love to RTFM, if I know where TFM was to R!
You can build an UI at different abstraction levels in Pharo. There is Glamour, where you describe the UI in terms of presentations, panes & ports. It is most useful for building specialized model browsers. For building a game it doesn't seem the most suitable. Then there is Spec, aiming at reuse of composable widgets. That could be a good fit. This summer there has been a GSoC project to build an Spec UIPainter, so you can get a good feel for how to layout the UI. PolyMorph is basically an abstraction layer over Morphic providing different skins (UIThemes). Below that is Morphic. An advantage of building directly in Morphic is that there is an excellent game building example: Laser Game (needing slight changes for use in Pharo).

titanium how do i add a view to the single context

So i have a titanium app, and i just read about single contexts. (Incidentally, somebody here should write a book about programming in titanium... the only one out there doesn't really mention single contexts or any of that new-fangled stuff. Heck, make it an eBook. I'd buy it)
The titanium documentation stresses their use (http://docs.appcelerator.com/titanium/latest/#!/guide/Coding_Strategies-section-29004891_CodingStrategies-Executioncontexts) and then politely forgets how to implement a single context!!
So, question:
Let's say i have the awesomeWidget page - this just shows a button, and when you click on a button a new screen appears.
The aswesomeWidget page is accessed through another page - it is not from the root of the titanium app.
Keeping to single contexts, how do i add the view that the button creates to the current window?
Do I:
keep a global pointer to the current (and only) window?
pass the variable holding the current window down to all the following pages that use it
something else?
First off, Titanium keeps a reference to your current window anyway for you, so this use case is easy. For example:
awesomeWidgetButton.addEventListener('click' function(e) {
var yourView = Ti.UI.createView({...});
Titanium.UI.currentWindow.add(yourView);
});
If you want to dig further, the concept of a single context is closely tied to the use of CommonJS modules and the require keyword. It is very simple to keep a single context, just never open a window with the url component filled out, and liberally use the require() keyword. Other than that, its up to your imagination to keep track of who points to what and vice versa, there are standard patterns and best practices that apply here (MVC, Singletons, just keep it simple) just as in coding in any other language.