How can i cancel this shortcut key? option+shift+r : ' ‰ ' - macos

option+shift+r, this is shortcut key rename file in my IntelliJ
. But show '‰' sign, how can I cancel it?

Related

Use CMD-mappings in console Vim

Is there a way to use Cmd key for Vim in terminal? Something MacVim does.
I have remapped Cmd+S in iTerm2 to send Esc:w!<CR> to save files in Vim, but this sounds a bit weak.
With all the power of iTerm and Vim there should be some way to do this right?
It is possible, but it takes some doing and has some downsides.
The first set of issues is that:
although iTerm2 can accept the Command keys and pass them on to terminal programs, it can only do so by remapping them as something else, e.g. the Left Option or Control keys.
it can only remap each modifier key everywhere in iTerm2; you can't do it just for certain windows, panes, or profiles.
in order to remap a modifier within the terminal, you need to allow iTerm2 to control the computer in the Security & Privacy preference pane; when you configure iTerm2 to do remapping, it will direct you there automatically.
once you've remapped Left Command, things like Left Command+N to open a new window no longer work. Luckily, though, you can remap e.g. Left Option to Left Command and still have your Right Command key available for Mac shortcuts; or you can switch around your Command and Option keys.
The remaining issue is that Vim isn't configured out of the box with Mac-like key bindings. Luckily, MacVim includes most of its Mac-style GUI bindings in /Applications/MacVim.app/Contents/Resources/vim/runtime/macmap.vim rather than coding them in Interface Builder or Objective-C source; so I was able to copy those and adapt them for the terminal. Here is a config that works pretty closely to MacVim (and other Mac apps):
" Keybindings for terminal vim; mostly to emulate MacVim (somewhat)
" See /Applications/MacVim.app/Contents/Resources/vim/runtime/macmap.vim (from
" which many of the following are taken); and menu.vim in the same directory.
" Since these all have native (Cmd-modified) versions in MacVim, don't bother
" defining them there.
" A utility function to help cover our bases when mapping.
"
" Example of use:
" call NvicoMapMeta('n', ':new<CR>', 1)
" is equivalent to:
" exec "set <M-n>=\<Esc>n"
" nnoremap <special> <Esc>n :new<CR>
" vnoremap <special> <Esc>n <Esc><Esc>ngv
" inoremap <special> <Esc>n <C-o><Esc>n
" cnoremap <special> <Esc>n <C-c><Esc>n
" onoremap <special> <Esc>n <Esc><Esc>n
function! NvicoMapMeta(key, cmd, add_gv)
" TODO: Make this detect whether key is something that has a Meta
" equivalent.
let l:keycode = "<M-" . a:key . ">"
let l:set_line = "set " . l:keycode . "=\<Esc>" . a:key
let l:nmap_line = 'nmap <silent> <special> ' . l:keycode . ' ' . a:cmd
let l:vnoremap_line = 'vnoremap <silent> <special> ' . l:keycode . ' <Esc>' . l:keycode
if(a:add_gv)
let l:vnoremap_line.='gv'
endif
let l:inoremap_line = 'inoremap <silent> <special> ' . l:keycode . ' <C-o>' . l:keycode
let l:cnoremap_line = 'cnoremap <special> ' . l:keycode . ' <C-c>' . l:keycode
let l:onoremap_line = 'onoremap <silent> <special> ' . l:keycode . ' <Esc>' . l:keycode
exec l:set_line
exec l:nmap_line
exec l:vnoremap_line
exec l:inoremap_line
exec l:cnoremap_line
exec l:onoremap_line
endfunction
" I can't think of a good function to assign to Meta+n, since in MacVim Cmd+N
" opens a whole new editing session.
" Meta+Shift+N
" No equivalent to this in standard MacVim. Here " it just opens a window on a
" new buffer.
call NvicoMapMeta('N', ':new<CR>', 1)
" Meta+o
" Open netrw file browser
call NvicoMapMeta('o', ':split %:p:h<CR>', 1)
" Meta+w
" Close window
call NvicoMapMeta('w', ':confirm close<CR>', 1)
" Meta+s
" Save buffer
call NvicoMapMeta('s', ':confirm w<CR>', 1)
" Meta+Shift+S
" Save as
" TODO: This is silent, so you can't tell it's waiting for input. If anyone can
" fix this, please do!
call NvicoMapMeta('S', ':confirm saveas ', 1)
" Meta+z
" Undo
call NvicoMapMeta('z', 'u', 1)
" Meta+Shift+Z
" Redo
call NvicoMapMeta('Z', '<C-r>', 1)
" Meta+x
" Cut to system clipboard (requires register +")
exec "set <M-x>=\<Esc>x"
vnoremap <special> <M-x> "+x
" Meta+c
" Copy to system clipboard (requires register +")
exec "set <M-c>=\<Esc>c"
vnoremap <special> <M-c> "+y
" Meta+v
" Paste from system clipboard (requires register +")
exec "set <M-v>=\<Esc>v"
nnoremap <silent> <special> <M-v> "+gP
cnoremap <special> <M-v> <C-r>+
execute 'vnoremap <silent> <script> <special> <M-v>' paste#paste_cmd['v']
execute 'inoremap <silent> <script> <special> <M-v>' paste#paste_cmd['i']
" Meta+a
" Select all
call NvicoMapMeta('a', ':if &slm != ""<Bar>exe ":norm gggH<C-o>G"<Bar> else<Bar>exe ":norm ggVG"<Bar>endif<CR>', 0)
" Meta+f
" Find regexp. NOTE: MacVim's Cmd+f does a non-regexp search.
call NvicoMapMeta('f', '/', 0)
" Meta+g
" Find again
call NvicoMapMeta('g', 'n', 0)
" Meta+Shift+G
" Find again, reverse direction
call NvicoMapMeta('G', 'N', 0)
" Meta+q
" Quit Vim
" Not quite identical to MacVim default (which is actually coded in the app
" itself rather than in macmap.vim)
call NvicoMapMeta('q', ':confirm qa<CR>', 0)
" Meta+Shift+{
" Switch tab left
call NvicoMapMeta('{', ':tabN<CR>', 0)
" Meta+Shift+}
" Switch tab right
call NvicoMapMeta('}', ':tabn<CR>', 0)
" Meta+t
" Create new tab
call NvicoMapMeta('t', ':tabnew<CR>', 0)
" Meta+Shift+T
" Open netrw file browser in new tab
call NvicoMapMeta('T', ':tab split %:p:h<CR>', 0)
" Meta+b
" Call :make
call NvicoMapMeta('b', ':make<CR>', 1)
" Meta+l
" Open error list
call NvicoMapMeta('l', ':cl<CR>', 1)
" TODO: We need to configure iTerm2 to be able to send Cmd+Ctrl+arrow keys, so
" we can duplicate the :cnext/:cprevious/:colder/:cnewer bindings to those keys
" in MacVim.
" There may be a few others I've missed, too.
The NvicoMakeMeta function maps a meta-key-modified version of the key passed into it to the specified action; "meta-key" here is just a generic term for Command- or Option-modified. The "Nvico" in its name represents the fact that it maps in normal, visual, insert, command, and operator pending modes.
Due to the way way Vim works when interpreting the ESC character (which is the beginning of all meta key sequences as well as arrow keys, etc.), if we simply mapped sequences of ESC plus another character, we would end up with Vim waiting a noticeable amount of time after receiving the actual Esc keypress (e.g. to signal a desire to return to normal mode). The way my function avoids this is by using :set to set a key code (see :help :set-termcap).
To summarize, here's what you need to do:
Put the above code in your .vimrc.
Go to the general iTerm2 preferences (iTerm menu > Preferences…); go to the Keys tab; remap your whatever key you'd like to use as a modifier so that it sends Left Option or Right Option. Follow the advice to allow iTerm2 to control the computer; it should open up the right preference pane for you to do that. You'll have to click the lock and type in your password before you can check the box next to iTerm.
Open the preferences for the terminal profile you'd like to use (e.g. by opening it in the app-wide Preferences dialog in the Profiles tab) and ensure that +Esc is checked next to Left option key acts as (and/or Right option key acts as, depending on whether you've made your meta key send Right Option).

Not able to read property at runtime

When I tried to read the "Left property" of a control, it is giving me the error,
"Left cannot be read at run time"
Here is my code,
for each ctrl in me.controls
if ctrl.left > 2490 then
'app logic
end if
next
what is wrong in this code. It worked without error in another computer.
Can anyone tell me what is wrong
You may have a design-time only placeable control on your form like a timer for example, that does not have a run-time left property. You could check the type of control to ensure only TextBox, Label, Button, etc. get checked, or just use an on error resume next:
Check for object type using TypeOf:
Dim ctrl As Control
For Each ctrl In Me.Controls
If TypeOf ctrl Is Timer Then
Else
If ctrl.Left > 2490 Then
'app logic
End If
End If
Next
Check for object type using TypeName:
Dim ctrl As Control
For Each ctrl In Me.Controls
If TypeName(ctrl) = "Timer" Then
Else
If ctrl.Left > 2490 Then
'app logic
End If
End If
Next
Using On Error Resume Next:
Dim ctrl As Control
On Error Resume Next
for each ctrl in me.controls
if ctrl.left > 2490 then
'app logic
end if
Next
If you use the last method, it's important to handle errors inline reraising any unexpected error. Otherwise if you get any different error than the one you're expecting you could have a very tough time finding it. So:
Dim ctrl As Control
On Error Resume Next
for each ctrl in me.controls
if ctrl.left > 2490 then
Select Case Err.Number
Case 0 'No Error, ignore
Case 393 'The error you want to ignore
Err.Clear 'Reset for next iteration
Case Else
On Error Goto 0
Err.Raise Err.Number 'Reraise any unexpected errors
End Select
'app logic
end if
Next
On Error Goto 0

Typing a keyboard shortcut using rb-appscript

I'm trying to convert the following script to Ruby using rb-appscript:
-- Runs the keyboard shortcut for the provided application name.
-- applicationName - The name of the application to run the keyboard shortcut on.
-- key - The key to press. For example, this could be "n" or "q".
-- modifiersList - A list of modifiers for the keyboard shortcut. This could be something like
-- { command down } or { command down, shift down, option down }.
on runKeyboardShortcut(applicationName, key, modifiersList)
tell application applicationName to activate
tell application "System Events"
keystroke key using modifiersList
end tell
end runKeyboardShortcut
Here's what I have so far:
def run_keyboard_shortcut(application_name, key, modifiers_list)
Appscript.app.by_name(application_name).activate
Appscript.app.by_name("System Events").keystroke(key)
end
How do I add the modifiers to the keystroke command?
The solution is to do this:
def run_keyboard_shortcut(application_name, key, modifiers)
Appscript.app.by_name(application_name).activate
Appscript.app.by_name("System Events").keystroke(key, :using => modifiers)
end
run_keyboard_shortcut("Finder", "n", [ :command_down ])

Saving Tab names and ConqueShells along with Vim sessions

Is there any way to get vim to save the tab names (assigned via the Tab Name script) and/or a terminal emulator (set up via the Conque Shell script) upon issuing the :mksession [fileName] command?
Observe below (zoom in), I have a working session on the left, and the same session loaded via the vim -S fileName command, on the right. The assigned tab labels revert to absolute paths, ConqueShell terminal is interpreted as a file.
After learning some basic VimScript I just gave up and used Python instead (to cite one example, you can't save global information to a session if it is a list). Here is a solution I found for saving tab names (will post a solution for ConqueShell if I find one)
Put the following in your .vimrc file and use whatever mapping you want to quickly save and load your sessions
"Tokenize it so it has the following form (without spaces)
"Label1 JJ Label2 JJ Label3 JJ Label4
"Or if you prefer use something other than 'JJ' but DO NOT
"use symbols as they could interfere with the shell command
"line
function RecordTabNames()
"Start at the first tab with no tab names assigned
let g:TabNames = ''
tabfirst
"Iterate over all the tabs and determine whether g:TabNames
"needs to be updated
for i in range(1, tabpagenr('$'))
"If tabnames.vim created the variable 't:tab_name', append it
"to g:TabNames, otherwise, append nothing, but the delimiter
if exists('t:tab_name')
let g:TabNames = g:TabNames . t:tab_name . 'JJ'
else
let g:TabNames = g:TabNames . 'JJ'
endif
"iterate to next tab
tabnext
endfor
endfunction
func! MakeFullSession()
call RecordTabNames()
mksession! ~/.vim/sessions/Session.vim
"Call the Pythin script, passing to it as an argument, all the
"tab names. Make sure to put g:TabNames in double quotes, o.w.
"a tab label with spaces will be passed as two separate arguments
execute "!mksession.py '" . g:TabNames . "'"
endfunc
func! LoadFullSession()
source ~/.vim/sessions/Session.vim
endfunc
nnoremap <leader>mks :call MakeFullSession()<CR>
nnoremap <leader>lks :call LoadFullSession()<CR>
Now create the following text file and put it somewhere in your PATH variable (echo $PATH to get it, mine is at /home/user/bin/mksession.py) and make sure to make it executable (chmod 0700 /home/user/bin/mksession.py)
#!/usr/bin/env python
"""This script attempts to fix the Session.vim file by saving the
tab names. The tab names must be passed at the command line,
delimitted by a unique string (in this case 'JJ'). Also, although
spaces are handled, symbols such as '!' can lead to problems.
Steer clear of symbols and file names with 'JJ' in them (Sorry JJ
Abrams, that's what you get for making the worst TV show in history,
you jerk)
"""
import sys
import copy
if __name__ == "__main__":
labels = sys.argv[1].split('JJ')
labels = labels[:len(labels)-1]
"""read the session file to add commands after tabedit
" "(replace 'USER' with your username)
"
f = open('/home/USER/.vim/sessions/Session.vim', 'r')
text = f.read()
f.close()
"""If the text file does not contain the word "tabedit" that means there
" "are no tabs. Therefore, do not continue
"""
if text.find('tabedit') >=0:
text = text.split('\n')
"""Must start at index 1 as the first "tab" is technically not a tab
" "until the second tab is added
"""
labelIndex = 1
newText = ''
for i, line in enumerate(text):
newText +=line + '\n'
"""Remember that vim is not very smart with tabs. It does not understand
" "the concept of a single tab. Therefore, the first "tab" is opened
" "as a buffer. In other words, first look for the keyword 'edit', then
" "subsequently look for 'tabedit'. However, when being sourced, the
" "first tab opened is still a buffer, therefore, at the end we will
" "have to return and take care of the first "tab"
"""
if line.startswith('tabedit'):
"""If the labelIndex is empty that means it was never set,
" "therefore, do nothing
"""
if labels[labelIndex] != '':
newText += 'TName "%s"\n'%(labels[labelIndex])
labelIndex += 1
"""Now that the tabbed windowing environment has been established,
" "we can return to the first "tab" and set its name. This serves
" "the double purpose of selecting the first tab (if it has not
" "already been selected)
"""
newText += "tabfirst\n"
newText += 'TName "%s"\n'%(labels[0])
#(replace 'USER' with your username)
f = open('/home/USER/.vim/sessions/Session.vim', 'w')
f.write(newText)
f.close()

Is there is a way to change a Windows folder icon using a Perl script?

Is there is a way to change a Windows folder icon using a Perl script?
My intention is to change the ordinary icon of the "xxx_documents" folder to some other icon. I have to run the script in such a way that it takes care for the whole drive.
The drive contains many folders. I have to search for each folder named "documents" (e.g. "xxx_documents" or simply "documents") and change its icon to one from the "%SystemRoot%\system32\SHELL32.dll" library.
Is that possible in Perl? Thanks to all who help me with this.
You sure can do it with Perl. Windows controls directory icons by use of a hidden systemDekstop.ini file in each folder. The contents looks something like this:
[.ShellClassInfo]
IconFile=%SystemRoot%\system32\SHELL32.dll
IconIndex=41
On Windows XP (and I assume on other systems), icon 41 is a tree. Windows requires this file be explicitly set as a system file for it to work, this means we'll need to dig down into Win32API::File to create it:
#!/usr/bin/perl
use strict;
use warnings;
use Win32API::File qw(createFile WriteFile fileLastError CloseHandle);
my $file = createFile(
'Desktop.ini',
{
Access => 'w', # Write access
Attributes => 'hs', # Hidden system file
Create => 'tc', # Truncate/create
}
) or die "Can't create Desktop.ini - " . fileLastError();
WriteFile(
$file,
"[.ShellClassInfo]\r\n" .
"IconFile=%SystemRoot%\\system32\\SHELL32.dll\r\n" .
"IconIndex=41\r\n",
0, [], []
) or die "Can't write Desktop.ini - " . fileLastError();
CloseHandle($file) or die "Can't close Desktop.ini - " . fileLastError();
If you run the code above, it should set the icon for the current directory to a tree. You may need to refresh your directory listing before explorer picks up the change.
Now that we have a way to change icons, we can now just walk through a whole drive and change every folder that matches our pattern. We can do this pretty easily with File::Find, or one of its alternatives (eg, File::Find::Rule, or File::Next):
#!/usr/bin/perl
use strict;
use warnings;
use File::Find qw(find);
use Win32API::File qw(createFile WriteFile fileLastError CloseHandle);
my $topdir = $ARGV[0] or die "Usage: $0 path\n";
find( \&changeIcon, $topdir);
sub changeIcon {
return if not /documents$/i; # Skip non-documents folders
return if not -d; # Skip non-directories.
my $file = createFile(
"$_\\Desktop.ini",
{
Access => 'w', # Write access
Attributes => 'hs', # Hidden system file
Create => 'tc', # Truncate/create
}
) or die "Can't create Desktop.ini - " . fileLastError();
WriteFile(
$file,
"[.ShellClassInfo]\r\n" .
"IconFile=%SystemRoot%\\system32\\SHELL32.dll\r\n" .
"IconIndex=41\r\n",
0, [], []
) or die "Can't write Desktop.ini - " . fileLastError();
CloseHandle($file) or die "Can't close Desktop.ini - " . fileLastError();
}
Unfortunately, I've just discovered that the icon only gets changed if the directory currently has, or once had, an icon... There's clearly an attribute that's being set on the directory itself that causes Windows to look for a Desktop.ini file, but I can't for the life of me figure out what it is. As such, the above solution is incomplete; we also need to find and fix the attributes on the directory where we're adding the icon.
Paul
1.
[.ShellClassInfo]
LocalizedResourceName=#%SystemRoot%\system32\shell32.dll,-21790
InfoTip=#%SystemRoot%\system32\shell32.dll,-12689
IconResource=%SystemRoot%\system32\imageres.dll,-108
IconFile=%SystemRoot%\system32\shell32.dll
IconIndex=-237
2.
[.ShellClassInfo]
LocalizedResourceName=#%SystemRoot%\system32\shell32.dll,-21803
InfoTip=#%SystemRoot%\system32\shell32.dll,-12689
IconResource=%SystemRoot%\system32\imageres.dll,-3
To get the icon to refresh, you will have to invoke some SHChangeNotify voodoo (C++ example, but you get the idea):
int imageIndex = Shell_GetCachedImageIndexW(wPath, GetSyncFolderIconIndex(), 0);
if (imageIndex != -1)
{
// If we don't do this, and we EVER change our icon, Explorer will likely keep
// using the old one that it's already got in the system cache.
SHChangeNotify(SHCNE_UPDATEIMAGE, SHCNF_DWORD | SHCNF_FLUSHNOWAIT, &imageIndex, NULL);
}
SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATHW | SHCNF_FLUSHNOWAIT, wPath, NULL);

Resources