how to access the text of vscode breadcrumb from extension - visual-studio-code

I am trying to write an extension to copy the text / path shown in vscode breadcrumb (marked in blue in picture). But I am unable to find any vscode api to read that. Any help with that?

I am guessing that you have problem getting the JSON property key path from root to your desired property key, I have recently run into this problem as well with my translations JSON files.
I wrote my own extension for vs code to get the path from root the child. Please give it a try and let me know if it solved your problem.
Click here! check it out and download.
P.S: I didn't publish this in market place yet, since I have test runs to do. But this is a completely functional version.

Related

How to change the default URL of thunderclient

Whenever we make a New Request, the default URL in the URL box is
"https://www.thunderclient.com/welcome"
How can we change this with our own URL?
If you want to have a base url. It's super easy in Thunder Client-vs-code.
Firstly, got to Collections
You should have Folder for your project API. And click on ... icon and got to Settings will move to Collection Settings
Secondly, Change the Base Url and save it.
You have done.
This feature is already requested in their Github issues but has still not been added yet.
So, the workaround I find is this:
Go to %USERPROFILE%\.vscode\extensions\rangav.vscode-thunder-client-1.18.7\dist for Windows.
Or go to $HOME/.vscode/extensions/rangav.vscode-thunder-client-1.18.7/dist for Mac or Linux.
Open extension.js file with Notepad or any text editor.
Find and replace this https://www.thunderclient.com/welcome with your desired URL.
Save the file and restart VS Code.

What is the vscode command to open a file in preview

I wrote an extension for vscode. After installation the extension folder contains documentation in a markdown file. I want to provide a command that loads this file into the preview pane so it displays rendered with images and hyperlinks etc.
You can do this sort of thing interactively:
and I have the full path to the markdown file, so now all I need is details of the command that implements this context menu item.
Web search does not produce complete or usable results.
After cloning the VS Code repo and trawling through the source I discovered the markdown.showPreview and associated commands.
To give credit where due, Lex Li reported the corresponding package.json entry in a comment while I was looking.
Without parameters this previews the content of the active editor, but as I said in a comment, it supports an optional Uri parameter and the code looks like this:
let pathToManual = path.join(context.extensionPath, "manual.md");
let uriManual: vscode.Uri = vscode.Uri.file(pathToManual);
vscode.commands.executeCommand('markdown.showPreview', uriManual);
For information on constructing workspace relative paths see the answer from Mark. The joinPath method he uses requires a base path as a Uri which is conveniently available for the workspace but not for the extension path.
If you need information on things like showing preview to one side then given the dearth of documentation I recommend cloning the repo and searching it for "markdown.showPreview", then exploring nearby code. If you fold the methods it gets easier to survey your options.
Try:
vscode.commands.executeCommand("markdown.showPreview", vscode.Uri.joinPath(vscode.workspace.workspaceFolders[0].uri,'test.md'));
Your fileName there at the end of course. And that assumed you are in the first or only root of a workspace. You might be able to simplify it using:
vscode.Uri.path(<path to file)
instead of the joinPath that I used.

VS Code Extension for Loading Source Code

I am interested in extending VS Code to load/edit/save project code, files, etc from a place other than the file system. For example, let's say I wanted to store my project in a database. I have looked at the extension API docs but didn't see anything obvious. Is there an API for extending VS Code in this way?
After some looking around it seems like you need to look at the "Workspace" section of the official API docs:
https://code.visualstudio.com/docs/extensionAPI/vscode-api#_workspace
The rootPath variable takes a string argument, but there's nothing saying that it needs to be a file path so perhaps there's some wiggle room there.
That being said the createFileSystemWatcher() method appears to be set up to work with an actual file system. So even if you can get VSC to find files from somewhere like a database - you probably can't use any of the events that update the UI on changing a file.

How to create project templates in Xcode 4

Its really hard to find a tutorial to do this as most information relates to Xcode 3. Answer below may help some people.
I sourced most of my information for the answer below from the following sites:
http://meandmark.com/blog/2011/12/creating-custom-xcode-4-project-templates/
http://www.bobmccune.com/2012/03/04/creating-custom-xcode-4-file-templates/
I spent hours searching the web to find information about doing this. Its not actually that hard to set up project templates for Xcode4.5 but its hard to find information on the web that puts it all together! Hopefully the steps below will help you to create your own.
Setting Up
Lets start by getting a copy of an existing Xcode project template to use as a base. Open finder, go to Applications and right click on Xcode to show package contents. Navigate to Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/Application/
[EDIT]
In Xcode 5 the PATH is as follows: ~/Library/Developer/Xcode/Templates/Application/Project Templates. If Templates/Application/Project Templates not exists you should create it too. Credit to seufagner in the comments below for the update although I have not tried this myself.
[/EDIT]
Copy (do not cut/paste!) one of the listed templates.
Open another finder window and navigate to the following directory (to unhide your Library folder type this cmd in terminal: chflags nohidden ~/Library/ or select press the alt/option key when clicking on Finder/Go) /Library/Developer/Xcode/Templates (you may need to create this folder if not already present) /Project Templates/
Create a folder in here. Call it whatever you wish, a suggestion is your company name. This name appears in the left hand menu of the new project dialogue in Xcode. e.g. in the attached image I've called mine Appscore, there's another one there for cocoas2d.
Paste the project template in here and change its folder name to whatever you wish e.g. MySuperProjectTemplate.xctemplate. We are not done yet though as we need to change the template's identifier. Otherwise it will not appear in the Xcode new project dialogue window.
Open the TemplateInfo.plist file in TextEdit. Search for the Identifier key. You should see a string value something similar to "com.apple.dt.unit.XXXXXX". Replace this with whatever you wish as long as its unique. I again suggest adding your company name and a name that describes the template.
If you now open Xcode you should see the project template appearing under your company name in the new project dialogue.
Customising
At the moment you have a copy of an existing project template which is not very useful. I'm guessing you have a number of classes that get reused in nearly all your projects? How about we include them into this template?
Copy the files you wish, and paste them into your new project template i.e. navigate to /Library/Developer/Xcode/Templates/Project Templates//MySuperProjectTemplate.xctemplate/
Open the TemplateInfo.plist file in TextEdit again. First thing we have to do is tell the project template to include the new files so search for a key called "Nodes" that has an array of values. Add the two following lines:
<string>_VARIABLE_classPrefix:identifier_.h</string>
<string>_VARIABLE_classPrefix:identifier_.m</string>
For example if your controller was called BaseViewController the lines would look like:
<string>___VARIABLE_classPrefix:identifier___BaseViewController.h</string> <string>___VARIABLE_classPrefix:identifier___BaseViewController.m</string>
Next find the Definitions key and you should see a dictionary as its value. In here we have to add a reference to the included files. Create a new key and call it ___VARIABLE_classPrefix:identifier___BaseViewController.h (again taking the BaseViewController as an example).
The value of this key is again a dictionary. It contains a key called Path and a string value which is the name of the file e.g. BaseViewController.h
I've attached the following images to show what I mean as I think my description is falling short. You may notice that there is a key in there called "Group", this as you can guess allows you to create groups and input files directly :D
Hope this is actually useful to someone :) Any questions comment below and I'l do my best to answer. I did this a few weeks ago so my memory is a little hazy.
You can also learn a lot from inspecting the existing project templates, which you can find in:
/Xcode.app/Contents/Developer/Library/Xcode/Templates/Project Templates/
for Mac and
/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/
for iOS.
There are few sample templates also on GitHub by Reid Main and another one by Acani. There are also AFNetworking templates, created by Mattt Thompson. See all the examples, including ones built by Apple and then you can start creating your own.
A good overview of all of the variables used in the plist file can be found here: https://gist.github.com/shazron/943736
#bennythemink
Your answer is really very much help full but I want to add some more things in your answer.
When we copy xcode predefine template than this key contains
<key>Ancestors</key>
<array>
<string>com.apple.dt.unit.storyboardApplication</string>
</array>
this value. When we use this key value in Custom template of xcode it will create AppDelegate class by default. Which we can not move to folder only we can shift it into group.
So i suggest to add this:
<key>Ancestors</key>
<array>
<string>com.apple.dt.unit.objectiveCApplication</string>
<string>com.apple.dt.unit.iPhoneBase</string>
<string>com.apple.dt.unit.prefixable</string>
</array>
value in Custom template so that we will have fully empty template in which we can do any custom stuff.

iPhone MoveMe Example - trouble with DisplayStrings

I'm starting to play a bit with iPhone applications and I downloaded the MoveMe example from the apple web page.
I managed to run the app, however I do not get the strings displayed. I noticed that the DisplayStrings.strings file, although it exists in the app folder, does not appear as one of the resources.
I tried adding it as a resource, but then after compiling I get an error saying "copystrings failed with exit code 1". I cannot find anything online regarding what the origin of this problem is...
The file itself is in utf16 (big endian), and contains simply a list of strings separated by new lines.
Any ideas?
Thanks.
I was having the same problem and as a workaround I renamed DisplayStrings.strings to DisplayStrings.data and added it as a resource. I then modified init in PlacardView.m to use the new filename. This made Xcode happy.
I fixed this by adding the DisplayStrings.strings file as a resource. However, when you do this it defaults the type to 'text.plist.strings' which is incorrect, since the file is just text. So, right click on the DisplayStrings.strings file in resources and change the type to 'text'. This solved the problem for me.