How do I add my configuration to Sublime Text 2's menu? - configuration

I've written a plugin for Sublime Text 2, which talks to a binary that I wrote. I expose the flags to the binary through as settings file, but I cannot figure out how to get the settings file placed into the menu bar.
Here is my best attempt so far.
Here are the docs on settings (not sure where the ones on menus are).

From what I can tell, in order to add your own items to a menu, its original declaration must have a pre-existing id value, which must then be included in any package-specific menu expansions. For example, consider the default definition for Preferences:
{
"caption": "Preferences",
"mnemonic": "n",
"id": "preferences",
"children": [ ... ]
},
Notably, the Settings – More object in Packages/Default/Main.sublime-menu does not have an id.
{
"caption": "Settings – More",
"children": [ ... ]
},
You can prove this requirement yourself by adding an id value to Settings – More in the default Main.sublime-menu and including that id in your package's Main.sublime-menu, similarly to how Preferences' id is referenced. Your custom menu will then show up under Settings – More.
Based upon the exclusion of an id for Settings – More, I would assume that the creators of Sublime Text 2 did not intend for third party packages to be able to edit the menu in question. Also, note that the – in Settings – More is not a hyphen (-); that's not the cause of your problem, but I initially suspected that it might have been.
The standard practice for adding one's own package settings to Preferences appears to be inserting a new item into Preferences -> Package Settings, which can be accomplished with a Main.sublime-menu file like this:
[
{
"caption": "Preferences",
"mnemonic": "n", // The mnemonics are for quick keyboard access
"id": "preferences",
"children": [
{
"caption": "Package Settings",
"mnemonic": "P", // On windows, Alt+N (above) followed by Alt+P would open this menu
"id": "package-settings",
"children": [
{
"caption": "Seeing Is Believing",
"children": [
{
"command": "open_file",
"args": {"file": "${packages}/Seeing Is Believing/Seeing Is Believing.sublime-settings"},
"caption": "Settings – Default"
}
]
}
]
}
]
}
]
I would highly recommend referencing a menu-rich plugin's Main.sublime-menu to figure out what else you should include and how you should do it. For my research I examined both Sublime Text 2's Main.sublime-menu and AdvancedNewFile's.

Related

vscode-icons extension: Cannot use custom icon

So I saw that vscode-icons has no icon for assembly files (that end in .asm). So I wanted to make one. I looked at the documentation and stuff and got something. The icons for asm files (which are just a paper sheet normally) disappeared! I think it's because it can't find the image but I put the image at this file path : C:\Users<USER HERE>\AppData\Roaming\Code\User\vsicons-custom-icons and still nothing.
Here is my settings.json:
{
"vsicons.associations.files": [
{
"icon": "file_type_asm.png",
"extensions": [
"asm"
],
"format": "png",
}
],
}
Here is the tutorial I used:
https://medium.com/#chih.hsi.chen/how-to-add-your-custom-icons-to-vscode-icons-9ab8c3f9abc1
What is up with this?
according to the extension's wiki in GitHub, and the source you provided,
the naming convention tells us to only use the full name in the name of the file on the local machine,
but when editing setting.json, in the icon part, just use the name you've given to the icon:
{
"vsicons.associations.files": [
{
"icon": "asm",
"extensions": [
"asm"
],
"format": "png",
}
],
}
just pay attention that for folders, you have to make two icons, but add only one object to the array; one with folder_type_ and one with folder_type_***_opened
one more thing to keep in mind for folders is that the array for folders is vsicons.associations.folders

Static Tab with placeholder values not displayed

I am currently getting into Microsoft Team Apps and am trying to create a very simple tool.
All it should be is a static tab, that when visited embeds a certain website, that's given the groupId as a parameter. This is the format, that I have in mind for the contentUrl: https://foo.bar?groupId=\{groupId\}
The app consists only of two images, that are PNGs in 20x20px (transparent) and 96x96px (with background color) and the manifest (version 1.2).
The manifest contains all required fields:
$schema, manifestVersion, version, id, packageName, developer {name, websiteUrl, privacyUrl, termsOfUseUrl}, icons {color, outline}, description {short, full}, accentColor, permissions, validDomains, staticTabs [{entityId, name, contentUrl, scopes}]
An Id for the app has been generated at apps.dev.microsoft.com.
The upload of the custom app as zip file causes no error and I can see the app in the list of the installed applications. If I switch to a channel I can't see the tab which should be there without being explicitly added because it's a static tab. Adding it manually isn't possible because it's not shown in the list of "addable apps".
I tried some of the example apps from GitHub, but they seem outdated and at least partly can't be even read (Error while reading manifest.json).
Is this sufficient information to help me?
Edit: (anonymized manifest.json)
{
"$schema":
"https://statics.teams.microsoft.com/sdk/v1.2/manifest/MicrosoftTeams.schema.json",
"manifestVersion": "1.2",
"version": "1.0.0",
"id": "12345678-abcd-efgh-1234-123456789012",
"packageName": "com.microsoft.teams.bar",
"developer": {
"name": "Foo Corp",
"websiteUrl": "https://foo.com",
"privacyUrl": "https://foo.com/privacy",
"termsOfUseUrl": "https://foo.com/termsofuse"
},
"icons": {
"color": "src/images/waldo-96x96.png",
"outline": "src/images/waldo-20x20.png"
},
"name": {
"short": "bar",
"full": "bar"
},
"description": {
"short": "Opens baz and does qux.",
"full": "Opens baz and does qux."
},
"accentColor": "#FFFFFF",
"permissions": ["identity", "messageTeamMembers"],
"validDomains": ["*.baz.com", "*.foo.com"],
"staticTabs": [
{
"entityId": "tabId",
"name": "example tab",
"contentUrl":
"https://foo.com/?teamId={teamId}&teamName={teamName}&channelId={channelId}&channelName={channelName}&locale={locale}&theme={theme}&entityId={entityId}&subEntityId={subEntityId}&upn={upn}&tid={tid}&groupId={groupId}&theme={theme}&isFullScreen={isFullScreen}",
"scopes": ["personal"]
}
]
}
I could see two issues in your manifest code:
Invalid GUID: 12345678-abcd-efgh-1234-123456789012 is not valid GUID.
Icons must be included in the package and referenced via relative paths in the manifest.
ex. waldo-96x96.png - Please place them inside zip file.
Please feel free to use Teams App Studio to create the manifest file. You can also use the existing form the sample code.

How to designate Article Directory when publishing to Apple News using Terminal?

I have an article.json file (named as such) below that I want to connect to Apple News and test:
{
"version": "1.4",
"identifier": "TestArticle",
"title": "My First Article",
"language": "en",
"layout": { "columns": 1},
"components": [
{
"role": "title",
"text": "My First Article"
},
{
"role": "body",
"text": "This is just over the minimum amount of JSON required to create a valid article in Apple News Format. If you were to delete the dictionary enclosing this text, you'd be there."
}
],
"componentTextStyles": {
"fontName": "Lato",
"textColor": "#000",
"linkStyle": {
"highlight": {
"color": "#358fd4"
}
}
}
I downloaded XCode and the necessary Ruby gems, to enter relevant command lines. As specified in the documentation, my .papi file is formatted correctly as it fetched my channel information successfully. According to Apple's ReadMe, this is the command I have to enter to publish an article:
papi-client article publish <Article Directory>
The problem is, I'm not sure exactly what this article directory is, or how to locate it. As far as I knew, I would create something like the above "article.json" file and potentially use that as the directory. I've even tried using the file path for said file, with no success. What could be my next steps to get this off the ground?
Place the article along with any locally linked, i.e. bundle://, content in a folder then use this folder as the article directory.

Is it possible to add root level menu of SublimeText?

I know we can configure SublimeText menu via sublime-menu files.
Is it possible to add a root level menu of SublimeText instead of subtree of the root menu?
The reason I ask is SublimeText is all about customize and configuration; and since I access to Sublime Text > Preferences so frequently, that I want the Preferences at not the subtree but the root level, where menu bar shows.
I use SublimeText3.
In ST2/3, configurations are JSON. Create a Main.sublime-menu file in your user directory. This contains a list of object entries. As an example,
[
{
"caption": "Custom",
"mnemonic": "m",
"id": "custom"
}
]
This will create a "Custom" menu (at the top level). Of course, there aren't any sub menu entries so it's a little less useful. Below is a portion of the Menu file from one of my plugins (just to show how to specify a command). I listed under the "Custom" menu as an example.
[
{
"caption": "Custom",
"mnemonic": "m",
"id": "custom",
"children":
[
{
"caption": "Package Settings",
"mnemonic": "P",
"id": "package-settings",
"children":
[
{
"caption": "AdvancedNewFile",
"children":
[
{
"command": "open_file",
"args": {"file": "${packages}/AdvancedNewFile/README.md"},
"caption": "README"
}
]
}
]
}
]
}
]
I did this in ST3 on W7. I'm unsure how it will behave in other OS's, but I assume it would work.

Adding Custom Menus in Sublime Text

How to add a custom Menu item in SublimeText 2 .
Any Ideas ??
I see there is a Main.sublime-menu file but dont know how to edit it.
Thanks!
The *.sublime-menu file is simply JSON. You can create a Main.sublime-menu in your user directory and it will be merged with other menu entries. It may be beneficial to look through the Main.sublime-menu files third party plugins have. These are generally much shorter, so may be easier to understand some of the things you need to define in each entry.
edit
You can use the following as a plugin to open notepad with an arbitrary file.
import sublime
import sublime_plugin
import subprocess
import threading
class OpenNotepadCommand(sublime_plugin.TextCommand):
def run(self, edit, filename=None):
th = NotepadThread(filename)
th.start()
class NotepadThread(threading.Thread):
def __init__(self, filename=None):
self.filename = filename
threading.Thread.__init__(self)
def run(self):
if self.filename is not None:
subprocess.call("notepad.exe %s" % self.filename)
else:
subprocess.call("notepad.exe")
When you are creating a menu item use something like the following for the command and arguments.
{
"command": "open_notepad",
"args": { "filename": "<the absolute path here>"}
}
Easier option if what you want is just run a command. Create a file Context.sublime-menu inside your Packages/User directory, and add the following:
[
{ "caption": "<Your caption here>", "command": "exec", "args": {"cmd": ["<your cmd name>", "<arg1>", "<arg2>", <...>]} }
]
Exemple: Adding a menu item to the context menu that just run dir:
[
{ "caption": "List files in current dir", "command": "exec", "args": {"cmd": ["dir"]} }
]
I know this way too late to join the party and add my 2 cents. Anyway, Main.sublime-menu is a file that allows you to add menu items to the top menu i.e [File, Edit, Selection, Find, View, Goto, etc.]
I recently added a new section "Dev" just to figure it out. I also wanted a way to trigger browser previews for a specific browser. Check it out.
[
{
"caption": "Dev",
"mnemonic": "Z",
"id": "dev",
"children": [
{
"caption" : "Previews",
"children": [
{ "caption": "Markdown Live Preview", "command": "new_markdown_live_preview", "id": "markdown_live_preview" },
{ "caption": "Preview in Default Browser", "command": "view_in_browser", "id": "markdown_live_preview" },
{ "caption": "Preview in Firefox", "command": "view_in_browser", "args": { "browser": "firefox" }, "id": "markdown_live_preview" },
{ "caption": "Preview in Chrome","command": "view_in_browser", "args": { "browser": "chrome" }, "id": "markdown_live_preview" },
{ "caption": "Preview in Safari", "command": "view_in_browser", "args": { "browser": "safari" }, "id": "markdown_live_preview" },
]
},
]
}
]
Anyway, this still works in ST3. Just in case anyone stumbles around here.