Sublime 3 key binding for "Views -> Groups -> Max Columns: 2" - editor

In Sublime text editor, there no key binding for group by columns.
What will be the key binding JSON for "Views -> Groups -> Max Columns: 2"?

The easiest way to determine the command and arguments needed to bind a key to a menu item is to open the console with View > Show Console, then enter the command sublime.log_commands(True) and pick the menu item that you want to bind to and see what the console says.
In this case, the result is the following:
>>> sublime.log_commands(True)
command: set_max_columns {"columns": 2}
With that information, you can create a binding something like this (replace the key as appropriate):
{
"keys": ["ctrl+alt+t"],
"command": "set_max_columns",
"args": {"columns": 2}
},
Once you make the change, you'll see the menu item showing you the keyboard shortcut that you selected as a reminder.
The command logging will remain in effect until you run the same command again with False as a parameter or restart Sublime.

Related

Custom wireshark disector shows value but fieldname is not visible using lua

I am testing some network packets of my Organisation's product. We already have custom plugins. I am trying to add some some more fields into those existing plugins (like conversion of 2 byte code to a string and assign it to a field)
Thankyou in advance for reading my query.
--edit
Wireshark version : 2.4.5 (organization's plugins dont work on latest wireshark application)
--edit
Problem statement:
I am able to add field and show value, but fieldname is not displayed as defined.
I cannot share the entire .lua file but i will try to explain What i did:
Below is the image where I have a field aprint.type. this is a two byte field. In .lua file, for display purpose it is appended with corresponding description using a custom function int_to_enum.
I want to add one more proto field aprint.typetext which will show the text.
What I did:
Added a protofield f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text") (Tried f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text",FT_STRING) also)
Below the code where subtree aprint.type is shown, added my required field as subtree:add(f_apr_msg_type_txt, msg_type_string) (Below is image of code extract)
I am able to see the text but field Name is shown as Wireshark Lua text (_ws.lua.text)
Normally displaying strings based on numeric values is accomplished by a value string lookup, so you'd have something like so:
local aprint_type_vals = {
[1] = "Foo",
[2] = "Bar",
[9] = "State alarm"
}
f_apr_msg_type = ProtoField.uint16("aprint.type", "Type", base.DEC, aprint_type_vals)
f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text", base.ASCII)
... then
local msg_type = tvb(offset, 2):le_uint()
subtree:add_le(f_apr_msg_type, tvb(offset, 2))
subtree:add(f_apr_msg_type_txt, tvb(offset, 2), (aprint_type_vals[msg_type] or "Unknown"))
--[[
Alternatively:
subtree:add(f_apr_msg_type_txt, tvb(offset, 2)):set_text("aprint_type_text: " .. (aprint_type_vals[msg_type] or "Unknown"))
--]]
I'm also not sure why you need the extra field with only the text when the text is already displayed with the existing field, but that's basically how you'd do it.

Make cascading list mandatory on JIRA based on another cascading list

I think this can be achieved with behaviors but I am struggling with the code.
I am trying to make "Cascading list 2" mandatory when an option is picked from "Cascading list 1"
Eg:
On "Cascading list 1" if a user picks option "A" then they have to also fill out "Cascading list 2"
If they pick option "B" on "Cascading list 1" then "Cascading list 2" is not required.
This is some of the code I was playing around with:
def fieldA = getFieldByName('BI Reporting & Analytics Request Categories') //this is cascading list 1
def fieldC = getFieldByName('Reporting') //this is the cascading list 2
def fieldAValuesThatTriggerFieldCRequired = ['Reporting'] //this is the option choosen in cascading list 1
def valueA = fieldA.value
def fieldCIsRequired = valueA in fieldAValuesThatTriggerFieldCRequired
fieldC.setRequired(fieldCIsRequired)
Any assistance is appreciated.
Image on JIRA
Thanks.
If my understanding is correct, they are not cascading field.
The request here is that when field A has particular value saying 'aaa', then field B becomes required (mandatory).
This is a typical use case for Jira plugin Adaptavist ScriptRunner behaviours.
But Behaviours is only available for Jira server or data center version. It is not for Jira cloud.
If your Jira is server version, you can refer to below steps and scripts:
go to behaviours settings, if you don't have a behaviour item for
your workflow, please create it. If behaviour has been created,
click into action/edit.
choose the field A and add it.
click Add server-side script, you will see the black inline edit section.
add below code.
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
#BaseScript FieldBehaviours fieldBehaviours
FormField field1 = getFieldById(getFieldChanged()) // we need to capture the change in field 1.
FormField pmAuthor = getFieldByName("field2")
if (field1.getValue()) { // to check if field1 has value as the action on field could be a deleting value operation.
if (field2.getValue()=="A") {
field2.setRequired(true)
} else {
field2.setRequired(false)
}
} else { // if the value was deleted, then remove the requirement.
field2.setRequired(false)
}

How to examine and change actions on commercetools updateCart query?

My question is this:
Is there a feature or method within graphql that allows editing of incoming queries EASILY so that I can prevent an action from being performed? I would like to examine my query in a web proxy, edit the actions, and then send it on to its destination.
Context:
I have a mutation running in a proxy service for commercetools that looks like this:
mutation AddLineItem(
$id: String
$version: Long!
$sku: String
$quantity: Long
$currencyCode: Currency!
$centAmount: Long!
$custom: String!
) {
updateCart(
version: $version
id: $id
actions: [
{
addLineItem: {
sku: $sku
quantity: $quantity
externalPrice: { centPrecision: { currencyCode: $currencyCode, centAmount: $centAmount } }
custom: { typeKey: "custom-type", fields: [{ name: "field", value: $custom }] }
}
}
]
) {
id
version
lineItems {
...LineItemFieldsCart
}
}
}
According to the commercetools documentation, when the external price field is set, duplicate items will be added as separate line items to the cart instead of increasing the quantity, as is the default behavior. The thing is, I want the default behavior instead of the duplicate line items. The normal way to mitigate this is to add an update extension to delete the duplicates, but I am working on an already mature system that has multiple update extensions that all operate on the line items, making a delete apparatus a heavy lift in the update extension. I want to edit the query in the proxy so the duplicate item never happens in the first place. Is there an easy way to do this?
for the add line item update action the current behaviour is to create a separate line item when external prices are used and not add the additional quantity to the already existing line item as you described.
If you want to make sure that the quantity is added to the already existing line item when using external prices, you could do a check prior to adding a new line item and use the update action change line item quantity in case the product variants match with the line items that already exist in the cart. This will let you set the external price there and will not add any additional like items. https://docs.commercetools.com/api/projects/carts#change-lineitem-quantity

Setting returned text to open an app in applescript

I have a apple script program that I am programming and I want the text the user sends to open an application, But I keep getting error messages saying "Can't get application {"name_of_app"} of <>. The code I very simple and I cant figure out the problem
set deReturnedItems to (display dialog "How many spam messages?" with icon stop default answer "" buttons {"Quit", "OK"} default button 2)
set xpp to text returned of deReturnedItems
set theReturnedItems to (display dialog "How many spam messages?" with icon stop default answer "" buttons {"Quit", "OK"} default button 2)
set amt to the text returned of theReturnedItems
set daReturnedItems to (display dialog "Last thing, what should the spam message say?" default answer "" buttons {"Quit", "OK"} default button 2)
set msg to the text returned of daReturnedItems
repeat [amt] times
tell application [xpp]
activate
tell application "System Events"
keystroke [msg]
keystroke return
end tell
end tell
end repeat
Get rid of those square brackets. Don't use them for variables. Use underscores before and after if you must, like:
repeat _amt_ times
…
end
Also, you need to check to make sure your variable is an integer before you use it in the repeat block.
Incidentally, when you set a variable and then include it in brackets, that's applescript syntax for set the string to a list. For example:
set [x, y, z] to "123"
return x
-- returns "1", and y is set to "2", and z is set to "3"

Sublime Text 2 - key binding to change syntax

I want to make a new key binding to change syntax to, let's say, HTML or CSS. I searched the official and unofficial documentation to see if there are any answers to my problem.
Use the following key combination to pull up the command palette:
Ctrl+Shift+P
then type:
sshtml (for example, to set the syntax to HTML)
This is how i roll, if that's what you meant exaclty:
// Syntax Change
{"keys": ["alt+shift+h"], "command": "set_file_type",
"args": {"syntax": "Packages/HTML/HTML.tmLanguage"}
},
{"keys": ["alt+shift+m"], "command": "set_file_type",
"args": {"syntax": "Packages/Markdown/Markdown.tmLanguage"}
},
{"keys": ["alt+shift+p"], "command": "set_file_type",
"args": {"syntax": "Packages/PHP/PHP.tmLanguage"}
},
{"keys": ["alt+shift+j"], "command": "set_file_type",
"args": {"syntax": "Packages/Javascript/JSON.tmLanguage"}
},
There is an easy way to do that.
On the right bottom, there is a button, click on that button you will get all the available syntax.
You can use the Command Pallet (ctrl + shift + p) to change the Syntax, but sometimes using "ss" or "sshtml" brings up other commands that are un-related to the "Set Syntax" options.
You can also add a new Key Binding User Preference that brings up the Command Pallet with the text "Set Syntax: " already in it. Then you just have to type the language you want to set it to.
To setup this key-binding shortcut:
Open the Command Pallet (ctrl + shift + p)
Find and select the "Preferences: Key Bindings" option
Update your User ".sublime-keymap" file to have the "keys" json-object listed in the array:
[
"// additonal/exsiting key comands go here...",
{ "keys": ["ctrl+alt+l"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": "Set Syntax: "} }
]
Now you can use ctrl+alt+l to bring up the command prompt. Then just type HTML, CSS, or whatever language you're looking to switch too.
Feel free to change the "keys" combination from ctrl+alt+l to anything else you want the shortcut to be too.
dzhi's answer doesnt work anymore for JSON in Sublime 4.
The correct path is
Packages/JSON/JSON.tmLanguage

Resources