Old 01-02-2017, 08:31 AM   #1
Lawrence
Human being with feelings
 
Join Date: Mar 2007
Posts: 21,551
Default Visual Studio Code

I just started using this, figuring for some Javascript stuff I do it would be a better choice than using the full VS. Questions for anyone using it. (And yeah, I've been Googling with not much help)

1. Brackets: Is there a way like in VS to configure where the opening bracket goes? I sometimes prefer it on the next line but it seems to default to the C-Style same line. Can I change that?

2. If anyone knows, can that thing sync to VSOnline? I don't use GitHub and I can't find a way (or an extension) to make it sync to VSOnline.

Thanks in advance.
Lawrence is offline   Reply With Quote
Old 01-02-2017, 09:11 AM   #2
karbomusic
Human being with feelings
 
karbomusic's Avatar
 
Join Date: May 2009
Posts: 29,260
Default

Quote:
Originally Posted by Lawrence View Post

1. Brackets: Is there a way like in VS to configure where the opening bracket goes? I sometimes prefer it on the next line but it seems to default to the C-Style same line. Can I change that?
I'm not sure. Unrelated... If VS Code has a "Command Window" you can type "Edit.FormatDocument" but that typically only auto formats indentation.

Quote:
2. If anyone knows, can that thing sync to VSOnline? I don't use GitHub and I can't find a way (or an extension) to make it sync to VSOnline.
This extension might work but didn't check very far... Reading closer maybe it is only GitHub? I need more coffee lol.

https://marketplace.visualstudio.com...e=ms-vsts.team

Even MS is leaning towards GitHub, it's a little confusing at first coming from TFS but not that bad.
__________________
Music is what feelings sound like.

Last edited by karbomusic; 01-02-2017 at 09:42 AM.
karbomusic is offline   Reply With Quote
Old 01-02-2017, 10:10 AM   #3
Lawrence
Human being with feelings
 
Join Date: Mar 2007
Posts: 21,551
Default

Thanks Karbo.

I'm actually liking it so far, for a lightweight code editor. I don't think I'll be using Notepad++ anymore.

I'll probably just source my JS code from DropBox so I'll always have an offline backup, instead of keep searching for a VSOnline plugin.
Lawrence is offline   Reply With Quote
Old 01-03-2017, 12:41 PM   #4
Lawrence
Human being with feelings
 
Join Date: Mar 2007
Posts: 21,551
Default

Ah... I found the first one. I'm not a fan of the JSON thing, as opposed to an ordinary preference dialog.

Quote:
// Defines whether an open brace is put onto a new line for control blocks or not.
"javascript.format.placeOpenBraceOnNewLineForContr olBlocks": false,"
I didn't find it before because I was searching for 'bracket', not 'brace'.
Lawrence is offline   Reply With Quote
Old 01-03-2017, 12:53 PM   #5
karbomusic
Human being with feelings
 
karbomusic's Avatar
 
Join Date: May 2009
Posts: 29,260
Default

Quote:
Originally Posted by Lawrence View Post
Ah... I found the first one. I'm not a fan of the JSON thing, as opposed to an ordinary preference dialog.

I didn't find it before because I was searching for 'bracket', not 'brace'.
Yea, no one has taken the time to write the GUI yet. Due to all the platform agnostic stuff as of late, I'd expect to find more and more stuff like this.

On a side note, JSON the format rocks FYI, it has replaced all my previous XML stuff; it weighs less, easier to parse across multiple platforms, works well over the wire etc.
__________________
Music is what feelings sound like.
karbomusic is offline   Reply With Quote
Old 01-03-2017, 03:13 PM   #6
Lawrence
Human being with feelings
 
Join Date: Mar 2007
Posts: 21,551
Default

Really? Now you've piqued my interest.

Can you show me some examples of using that instead of xml? Thanks K.

Btw, here what I was working on... http://theaudiocave.com/le ... a logical editor for my other daw. There's a link to the JS source on that page.
Lawrence is offline   Reply With Quote
Old 01-03-2017, 05:43 PM   #7
karbomusic
Human being with feelings
 
karbomusic's Avatar
 
Join Date: May 2009
Posts: 29,260
Default

Quote:
Originally Posted by Lawrence View Post
Really? Now you've piqued my interest.

Can you show me some examples of using that instead of xml? Thanks K.

Btw, here what I was working on... http://theaudiocave.com/le ... a logical editor for my other daw. There's a link to the JS source on that page.
It's really simple actually. If you had Name and Address properties it would be as JSON like this:

Code:
{"Name":"Joe", "Address":"123 Elm"}
If you wanted an array of those you just continue the pattern with commas and the square brackets are what makes it an array:

Code:
[
  {"Name":"Joe", "Address","123 Elm"},
  {"Name":"Jane", "Address","123 Oak"},
  {"Name":"John", "Address","123 Maple"}
]
The nice part is you don't need to worry about ^that syntax, you just create a class in code, maybe make a List<> of your items. Lets call the class User so it would be List<User> which contains that array of users. To get that into JSON you can use a component called JSON.net (with a single line of code) and just tell it to serialize into the above syntax, or deserialize the syntax into class objects, which can now to to a file, or be sent in a web request or whathehellever.

One of the great things is it doesn't care if the json is a perfect match, if the json contained Name, Address, Zip but you told it to deserialize into a class that only had Name, Address, it would happily do so and just ignore the missing field so you aren't tied to the strictness of XML nor all the extra syntax that XML carries. I'll grab some code sample later and post it so you can see.

I'll also check your site in a few.
__________________
Music is what feelings sound like.
karbomusic is offline   Reply With Quote
Old 01-03-2017, 06:05 PM   #8
karbomusic
Human being with feelings
 
karbomusic's Avatar
 
Join Date: May 2009
Posts: 29,260
Default

Since lists/arrays of objects are what we almost always work with from an object oriented paradigm. Here is a loose examle from a project I'm finishing up... Should make plenty sense but if not feel free to ask.

Code:
   
   // our user class
   public class IotUser
    {
        public string UserID { get; set; }
        public string Name { get; set; }
        public string Password { get; set; }
        public string EmailAddress { get; set; }
        public string TextAddress { get; set; }
        public bool IsEmailAlertEnabled { get; set; }
        public bool IsTextAlertEnabled { get; set; }
        public bool IsAdmin { get; set; }
        public NotificationType AlertType { get; set; }
    }
	
	// the list of type "user" that we add users to
	private List<IotUser> iotUsers = new List<IotUser>();
	
	// creating a user
	IotUser user = new IotUser();
	user.Name = "bob";
	user.Email = "bob@bob.com";
	
	// adding him to the list
	iotUsers.Add(user);
	
	// save our list to disk as json
	private void SaveIotUsers()
	{
		string filepath = "IotUsers.json";
		string jsonData = Newtonsoft.Json.JsonConvert.SerializeObject(IotUsers);
		System.IO.File.WriteAllText(filepath, jsonData);
	}
	
	//load that list from disk back into our "users list"
	private List<IotUser> LoadIotUsers()
	{
		string iotUserPath =  "iotUsers.json");
		return Newtonsoft.Json.JsonConvert.DeserializeObject<List<IotUser>>(System.IO.File.ReadAllText(iotUserPath));
	}
To install the JSON component with ease (per project) in VS...

Tools > Nuget Package Manager > Package Manager Console

Then run this command....

Install-Package Json.Net

Ref: https://www.nuget.org/packages/Newtonsoft.Json

Being cross platform, you could take that exact same file/json string and parse it via javascript like this and you'd end up with that same object with the same fields making it really easy to reuse work you did in VS and now use that data in a web page:

var iotUsers = JSON.Parse(stringofjson);


Side note: I'm a big fan of strongly typed lists because they are so easy to manage. If you wanted to pull a single user out of that list you can do it in a single line, so lets pull bobs object based on his email...

IotUser bob = iotUsers.Find(x => x.EmailAddress.ToLower() == "bob@bob.com");

or maybe I just want his name directly instead of the entire object...

string bobsname = iotUsers.Find(x => x.EmailAddress.ToLower() == "bob@bob.com").Name;

or maybe you wanted to create a sublist of everyone in that list that had an email address ending in .com:

List<IotUser> dotComUsers = iotUsers.FindAll(x => x.EmailAddress.ToLower().Contains(".com");

You probably know much of this but added just in case.
__________________
Music is what feelings sound like.

Last edited by karbomusic; 01-03-2017 at 06:20 PM.
karbomusic is offline   Reply With Quote
Old 01-03-2017, 06:22 PM   #9
karbomusic
Human being with feelings
 
karbomusic's Avatar
 
Join Date: May 2009
Posts: 29,260
Default

Checked out the webpage for the app. I think I remember you asking something about it before. I think it's fantastic, you always do great work in that arena.
__________________
Music is what feelings sound like.
karbomusic is offline   Reply With Quote
Old 01-03-2017, 07:43 PM   #10
Lawrence
Human being with feelings
 
Join Date: Mar 2007
Posts: 21,551
Default

Thanks for the example K. Good stuff.

The way those properties are created looks a lot like VB's auto-implemented properties.
Lawrence is offline   Reply With Quote
Old 01-03-2017, 09:06 PM   #11
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Someone should convert the Reaper Lua API to be accessible in VS Code... (I would do it myself but I totally suck at parsing text because I don't know what would be the best language and library to use for that. C++ definitely ain't the language for that, though.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 01-03-2017, 10:05 PM   #12
karbomusic
Human being with feelings
 
karbomusic's Avatar
 
Join Date: May 2009
Posts: 29,260
Default

There is an open source extension for the .lua part...

https://github.com/Microsoft/VSLua

Might be possible to enhance that to be aware of the Reaper library?
__________________
Music is what feelings sound like.
karbomusic is offline   Reply With Quote
Old 01-03-2017, 10:59 PM   #13
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by karbomusic View Post
There is an open source extension for the .lua part...

https://github.com/Microsoft/VSLua

Might be possible to enhance that to be aware of the Reaper library?
Yeah, I already looked into some VS Code Lua extension, but just adding one Reaper API function manually took so much time, it would need to be automated to be make it feasible to add all the functions. (Also I am not really that much into using the full Visual Studio for writing Lua, but the VS Code environment seemed like a nice potential option...) edit : On the other hand, maybe the Reaper built-in IDE lately got some improvements that make using an external editor not so necessary. I haven't looked into that much lately since I've been coding mostly C++ stuff.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 01-04-2017, 04:23 AM   #14
Lawrence
Human being with feelings
 
Join Date: Mar 2007
Posts: 21,551
Default

I'm falling in love with it, VS code. It's a nice middle grond between things like Notepad++ which are less functional than Visual Studio and the full Visual Studio which feels like bloat to launch for general scripting.

I just need to learn the keyboard shortcuts. I love the JavaScript intellisense.

On another front, someone used reflection or something and discovered the object model in Studio One. It apparently has a full internal API exposed to JS, they just didn't ever publish it. The things I'm doing in that script nobody knew was even possible before. The cat's out of the bag now. The API is dead simple as in ...

functions.renameEvent(clip, name);

.. to rename a clip... or

functions.modifyVelocity(event,value);

to edit a midi note, etc, etc.

Last edited by Lawrence; 01-04-2017 at 04:28 AM.
Lawrence is offline   Reply With Quote
Old 01-04-2017, 04:34 AM   #15
Lawrence
Human being with feelings
 
Join Date: Mar 2007
Posts: 21,551
Default

Quote:
Originally Posted by Xenakios View Post
Someone should convert the Reaper Lua API to be accessible in VS Code... (I would do it myself but I totally suck at parsing text because I don't know what would be the best language and library to use for that. C++ definitely ain't the language for that, though.)
Yeah. Looking at my source code linked from that page you can see how easy GUI design is with JavaScript and XML. Of all the languages Reaper uses to script it's puzzling why they excluded that one. Creating XML forms is an order of magnitude easier than anything Reaper does for script GUI's.
Lawrence is offline   Reply With Quote
Old 01-04-2017, 08:35 AM   #16
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Lawrence View Post
Creating XML forms is an order of magnitude easier than anything Reaper does for script GUI's.
Right, but that's a separate issue that I think the Reaper developers are not that willing to address...
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 01-04-2017, 09:18 AM   #17
snooks
Banned
 
Join Date: Sep 2015
Posts: 1,650
Default

Quote:
Originally Posted by Lawrence View Post
2. If anyone knows, can that thing sync to VSOnline? I don't use GitHub and I can't find a way (or an extension) to make it sync to VSOnline.
You can create a Git repo in VS Team Services, then use the integrated Git functionality in VS Code. The only thing it looks like you can't do in VS Code is set the 'origin' (remotely hosted repo). But there are copy/paste Git commands given to you by VSTS after you create a repo there which you run on the command line in the directory your local repo is in.

Maybe the Git icon on the left of the screen in VS Code only appears when you have Git ( https://git-scm.com/download/win ) installed?
snooks is offline   Reply With Quote
Old 01-04-2017, 09:43 AM   #18
karbomusic
Human being with feelings
 
karbomusic's Avatar
 
Join Date: May 2009
Posts: 29,260
Default

https://visualstudio.github.com/

Here's the integrated link. That's fully functional and should allow committing to the local repository and to TFS and GitHub in the cloud (assuming you have the accounts to begin with). It's all integrated with TFS in VS giving you both the classic TFS stuff + GitHub functionality.
__________________
Music is what feelings sound like.
karbomusic is offline   Reply With Quote
Old 01-04-2017, 10:35 AM   #19
Lawrence
Human being with feelings
 
Join Date: Mar 2007
Posts: 21,551
Default

I think I'm mostly being lazy. When I saw GitHub, all the command line stuff and all that, then I looked at VSOnline, which doesn't use any of that stuff, I chose the lastter

I've never done anything much with GitHub other than upload some files to the free server.
Lawrence is offline   Reply With Quote
Old 01-04-2017, 10:39 AM   #20
Lawrence
Human being with feelings
 
Join Date: Mar 2007
Posts: 21,551
Default

Quote:
Originally Posted by Xenakios View Post
Right, but that's a separate issue that I think the Reaper developers are not that willing to address...
Can (or could) Lua use XML forms? I suppose there'd need to be an underlying framework of some kind to attach it all, an interface?
Lawrence is offline   Reply With Quote
Old 01-04-2017, 10:41 AM   #21
karbomusic
Human being with feelings
 
karbomusic's Avatar
 
Join Date: May 2009
Posts: 29,260
Default

Quote:
Originally Posted by Lawrence View Post
I think I'm mostly being lazy. When I saw GitHub, all the command line stuff and all that, then I looked at VSOnline, which doesn't use any of that stuff, I chose the lastter

I've never done anything much with GitHub other than upload some files to the free server.
All my buddies are digging GitHub but I have 100s of apps in TFS already so I've been a little slow to adopt other than a handful of work related tools I've written that I used GIT for so others could access the code. Regardless, all the code I care about is synced to a TFS or GIT repository - it's just too worthwhile to not do.
__________________
Music is what feelings sound like.
karbomusic is offline   Reply With Quote
Old 01-04-2017, 10:43 AM   #22
Lawrence
Human being with feelings
 
Join Date: Mar 2007
Posts: 21,551
Default

It's just so damn easy, TFS, and everything (merging, branching, whatever) is painless.

GIT seems a good bit ... geekier. And above, that's what I meant "GIT", not GitHub.
Lawrence is offline   Reply With Quote
Old 01-04-2017, 10:46 AM   #23
karbomusic
Human being with feelings
 
karbomusic's Avatar
 
Join Date: May 2009
Posts: 29,260
Default

Quote:
Originally Posted by Lawrence View Post
It's just so damn easy, TFS, and everything (merging, branching, whatever) is painless.

GIT seems a good bit ... geekier. And above, that's what I meant "GIT", not GitHub.
Yep, I agree.
__________________
Music is what feelings sound like.
karbomusic is offline   Reply With Quote
Old 01-04-2017, 10:52 AM   #24
Lawrence
Human being with feelings
 
Join Date: Mar 2007
Posts: 21,551
Default

Anyway, I have you to thank for overcoming my aversion to the C-Style brakcets. You pushed me into it.

I now get along rather well with JavaScript, C# and others, while still enjoying VB and Ruby and similar which don't use those conventions. It grew on me, those fucking brackets.

I actually really love Ruby though, even though I've only used it in Flowstone. Beautiful language.
Lawrence is offline   Reply With Quote
Old 01-04-2017, 10:57 AM   #25
karbomusic
Human being with feelings
 
karbomusic's Avatar
 
Join Date: May 2009
Posts: 29,260
Default

Quote:
Originally Posted by Lawrence View Post
Anyway, I have you to thank for overcoming my aversion to the C-Style brakcets. You pushed me into it.

I now get along rather well with JavaScript, C# and others, while still enjoying VB and Ruby and similar which don't use those conventions. It grew on me, those fucking brackets.

I actually really love Ruby though, even though I've only used it in Flowstone. Beautiful language.
hehe, I only did that because when I saw you not liking them, it so much reminded me of how I felt when I started using them. Then later on it suddenly grew on me so I thought it was worth a shot to get you over the hump.
__________________
Music is what feelings sound like.
karbomusic is offline   Reply With Quote
Old 01-04-2017, 11:37 AM   #26
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Lawrence View Post
Can (or could) Lua use XML forms? I suppose there'd need to be an underlying framework of some kind to attach it all, an interface?
I am sure Lua itself can do/be made to use anything, but it's a bit different matter when it is already embedded into something like Reaper, which has its own conventions and limitations. (That is, if you did your own C++/C#/etc application from scratch, you could more or less easily implement anything to be scripted from Lua.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 01-04-2017, 04:02 PM   #27
Lawrence
Human being with feelings
 
Join Date: Mar 2007
Posts: 21,551
Default

Ah... gotcha.

It seems my view of it is (was) lacking a good understanding of embedded script languages, how they work.

Thanks X.
Lawrence is offline   Reply With Quote
Old 01-04-2017, 04:03 PM   #28
Lawrence
Human being with feelings
 
Join Date: Mar 2007
Posts: 21,551
Default

Quote:
Originally Posted by karbomusic View Post
hehe, I only did that because when I saw you not liking them, it so much reminded me of how I felt when I started using them. Then later on it suddenly grew on me so I thought it was worth a shot to get you over the hump.
Yeah, you fukker.

Anyway, I'm ok with it now. I suppose it's just a matter of doing it or seeing it enough to get comfy with it. I still love VB though, and it's still my first choice for Win only desktop stuff.
Lawrence is offline   Reply With Quote
Old 01-04-2017, 04:57 PM   #29
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Lawrence View Post
Ah... gotcha.

It seems my view of it is (was) lacking a good understanding of embedded script languages, how they work.

Thanks X.
Obviously even something like Reaper's ReaScript could still implement anything, but the amount of "friction" to do certain things can get too high to make it worthwhile. Comprehensive clean scripting support with GUI facilities etc is something that should ideally be baked into an app from the beginning. Reaper got its scripting facilities quite late.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 01-06-2017, 08:33 AM   #30
Lawrence
Human being with feelings
 
Join Date: Mar 2007
Posts: 21,551
Default

Oh crap. This may be a deal breaker for me, no code outlining / hiding, which has driven me back to VS Community for now.

Maybe VS Code has an extension for that. I'll search. I gotta have code outlining and folding, especially for the bracketed language formats.

Ah, never mind, I found it. It's not on any menus (afaict) only key commands CTL+SHIFT+[ (or ]) to fold / unfold. No idea why they didn't just build it that way, to auto show the fold / unfold icons for each function.

Last edited by Lawrence; 01-06-2017 at 08:40 AM.
Lawrence is offline   Reply With Quote
Old 01-06-2017, 08:56 AM   #31
karbomusic
Human being with feelings
 
karbomusic's Avatar
 
Join Date: May 2009
Posts: 29,260
Default

Sheer curiosity, how come you didn't just use community anyway? Never mind, looks like the lightweight javascript/html editor type thing. I agree though, I've grown fairly depending on the outlining feature.

You might also enjoy LinQPad it allows testing of managed code like C#/VB minus a project. In other words you can just toss a block of code in and debug it without the need for a VS project and so on.

On a side note it appears if you just put the mouse between the line number and the code, the +/- icons appear without the need for the keyboard shortcut.
__________________
Music is what feelings sound like.
karbomusic is offline   Reply With Quote
Old 01-06-2017, 09:07 AM   #32
Lawrence
Human being with feelings
 
Join Date: Mar 2007
Posts: 21,551
Default

Quote:
Originally Posted by karbomusic View Post
Sheer curiosity, how come you didn't just use community anyway?
I had been. VS Code is just much more lightweight, faster to launch and has a good bit less system overhead on my development laptop, which is not exactly speedy Gonzales.

The good part is that because I'm editing the files from my local Visual Studio folders, when I do open the VS project later it's all synced up anyway. But yeah, typically for quick editing in JS I'd use Notepad++, avoid launching the full VS, but VS Code is a much better option... at least visually and otherwise, for me.

Quote:
You might also enjoy LinQPad it allows testing of managed code like C#/VB minus a project. In other words you can just toss a block of code in and debug it without the need for a VS project and so on.
Ack. I'd never heard of that. Thanks K.
Lawrence is offline   Reply With Quote
Old 01-18-2018, 05:22 AM   #33
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

How to properly import ReaSyntax highlighting and auto-completion into VS Code, so that VSCode would look like this:

Sublime Text now: https://i.imgur.com/WiMl5jV.png
VS Code now: https://i.imgur.com/LmmksXa.png

Sublime Text with this package: https://github.com/Breeder/ReaSyntax
fundorin is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:21 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.