Is there a way to get the Atom editor to insert a custom Unicode character when you press a shortcut key? I'm trying to make Cmd-\ insert a lambda (λ).
You can create a custom command and then map that command to the desired key. To add the custom command you can add this to your init.coffee:
atom.commands.add 'atom-text-editor',
'custom:insert-lambda': (event) ->
editor = #getModel()
editor.insertText('λ')
Then you can add the key mapping in your keymap.cson:
'atom-text-editor':
'cmd-\\': 'custom:insert-lambda'
After restarting or reloading the window to load the new init.coffee, things should work for you.
Related
I prefer the convenience and speed of the keyboard over using the trackpad/mouse whenever possible. Is there a means to access the Jupyter menu bar with the keyboard. For example the Edit menu:
On Linux we could access a top-level item as Alt-E | D for Edit | Delete cells . On macos it is a headache but still possible: <Access Menubar shortcut>| E | D.
Is there any way to achieve that on Jupyter?
So you want to bind custom keyboard shortcuts...
The documentation tell you to use the JavaScript API, where the documentation is in the source code.
So you end up with something like this in custom.js (it's convenient that the first characters of all the menus are distinct)
for(let id of ["filelink", "editlink", "viewlink", "insertlink", "celllink", "kernellink"]) {
const element=document.getElementById(id)
const actionName=Jupyter.notebook.keyboard_manager.actions.register(function (env) { element.click() },
`open-menu-${id[0]}`, "custom")
const shortcut='alt-'+id[0]
Jupyter.keyboard_manager.command_shortcuts.add_shortcut(shortcut, actionName)
Jupyter.keyboard_manager.edit_shortcuts.add_shortcut(shortcut, actionName)
}
This code binds Alt+E to clicking edit menu.
It's rather version-dependent (as it depends on the ID of the links on the menu) -- this is tested on Jupyter notebook version 6.1.6.
If you use a for loop to generate the shortcuts (like in the code above), it's very important that you register actions manually (and have different names for them) instead of add_shortcut(shortcut, handler) because otherwise the handler would generate the action name from the string representation of the handler, and that would be all the same. No JavaScript closure can help you.
If you also want to use Enter key to select a menu, you have to do a little more -- because by default it's bound to enter edit mode:
{
Jupyter.keyboard_manager.command_shortcuts.add_shortcut("enter", function(env){
const element=document.activeElement
if(element.getAttribute("role")==="menuitem")
element.click()
else{
env.notebook.edit_mode();
// alternatively:
//env.notebook.keyboard_manager.actions.call("jupyter-notebook:enter-edit-mode")
}
})
}
Modify it a little more if you want to add shortcut for the 2 other menus, as they don't conveniently have an ID.
I'm using the following code to return handle for a open file dialog box shown from Notepad.
Global $Result = DllCall("User32.dll", "HWND", "FindWindowExA", "HWND", WinGetHandle("[CLASS:Notepad]"), "HWND", Null, "STR", "#32770", "STR", "Open")
ConsoleWrite("FindWindowEx Return Value: " & String($Result[0]) & #CRLF)
This always returns 0x00000000, but given parameters seems correct.
Why does this function return nothing here?
UPDATE
The following syntax worked, but I still can't specify the parent window:
Global $Result = DllCall('User32.dll', 'HWND', 'FindWindowExW', 'HWND', Null, 'HWND', Null, 'WSTR', '#32770', 'WSTR', 'Open')
This finds every dialog box (Paint, WordPad etc.) , but I only want to get the handle to dialog box with parent as Notepad.
There is no single API to restrict the search to just Notepad. You will have to enumerate all available #32770 windows, looking for ones that belong to a Notepad process, until you find the one you are looking for.
To enumerate the windows, you can use either:
EnumWindows(), filtering in the callback function using GetClassName() and GetWindowText().
FindWindowEx() in a loop, initially setting hwndParent=0 and hwndChildAfter=0, and then setting hwndChildAfter to the last found window on each subsequent call.
To test if a given window belongs to Notepad, you can:
use GetWindowThreadProcessId() to get the window's owning process ID.
then use OpenProcess() to open a handle to the process.
then use GetModuleFileNameEx(), GetProcessImageFileName(), or QueryFullProcessImageName() to retrieve the path and filename of the EXE that created the process.
check if the filename is notepad.exe and the path is the Windows system folder.
What's wrong here?
Open notepad.exe first, type some text without saving, attempt to close notepad but leave resulting dialog (CLASS:#32770, asking so save) opened. Example, as per documentation (untested, no error-checking):
Global Const $g_sWnd = '[TITLE:Notepad; CLASS:#32770; INSTANCE:1]'
Global Const $g_hWnd = WinGetHandle($g_sWnd)
ConsoleWrite($g_hWnd & #CRLF)
Change TITLE:Notepad as required (to notepad's file-open dialog-box title).
In my notebook, I print some data from scraped web pages. Some of these are hyperlinks without tags e.g. https://stackoverflow.com. Unfortunately, Notebook prints these out as an actual hyperlink (i.e. wraps it in tags) on the output page and shortens it. (So the final result in HTML looks like this: https://stacko....) The field is set to code, but this still happens. Is there a way to disable this behaviour?
Solution:
Enter the following text in the empty cell of your Jupyter notebook:
%%javascript
Jupyter.utils.autoLinkUrls = function (txt) {
return txt;
}
Explanation:
The ability to locate URLs in text output and convert them to hyperlinks appeared in IPython notebook (a Jupyter's predecessor) as a result of a merge request in Oct' 2012. Since then every piece of output is scanned for URLs and each found URL is replaced with an anchor <a href=.../>. There's no easy way to alter this behavior because function autoLinkUrls(...) doesn't provide any configuration parameters.
So, the only way to disable URL "autolinking" is to simply replace JavaScript function autoLinkUrls, which is exposed through global Jupyter object, and %%javascript magic command makes the job done.
I am trying to use autocomplete in Juno. Is there a key to use the suggestion or do I always have to use the mouse?
Does anyone have an idea?
Note that what we talked about here is the former light-table-based Juno, not the Atom-based one.
the default setting of "auto-complete" in your default.keymap file should be:
[:editor.keys.normal "tab" :auto-complete]
you can checkout it by
Step1: open juno's commands window or pressing Ctrl+space
Step2: search settings and you will find a list:
Settings: User script
Settings: User keymap
...
Settings: Default keymap
...
Step3: click Settings: Default keymap and search for 'auto-complete'
if you want to map another key for 'auto-complete', you can customize it in user.keymap.
Using Aptana Studio 3 and when using the shortcut ctrl+shift+enter to insert a line above the current line, Aptana will ask offer a drop-down with the following options:
and Insert Terminator + LF
Insert Line Above Current Line
I want Insert Line Above Current only but have been unable to find where to change this key code.
That top option appears to be coming from a key binding in Commands > Source > Move to EOL > "Insert Terminator + LF". Due to a Eclipse peculiarity, those key bindings are not listed in the default key binding preference.
To remove, you have to edit the bundle. It's pretty simple:
Commands > Source > Edit this Bundle. It will create a project in your workspace
Look in the commands folder of that project for the proper command (it should be pretty obvious)
Comment out or change the keybinding. You might have to restart.
For more info, see: http://wiki.appcelerator.org/display/tis/Modifying+your+shortcut+keys#Modifyingyourshortcutkeys-ModifyingtheBuiltInBundles