Move cursor to a new line after "Send Selection to Terminal" action in Geany - ide

I set in geany a key shortcut to Send Selection to Terminal action which send the current line (or selection) to the build-in terminal (according to: shortcut to send selection to terminal in geany).
Then I change send_selection_unsafe=false to send_selection_unsafe=true in the geany.conf file (according to: Geany: execute line in Terminal)
Everything works well, I can send a line to terminal which is automatically executed. My problem is that at this point the cursor remains on the line after sending it to terminal.
Maybe I miss something, but is it possible to set or configure behaviour that cursor is automatically move to next line after using Send Selection to Terminal so than I can sending lines to terminal one after another (without hitting down arrow) ?
like this:
print("hello world!")
#I want cursor on this line after sending previous line to terminal, so this can be send to terminal immediately

Related

Run word macro on keypress in document

What I am trying to create is a writing assistant for MS word that gives me advice during writing. In order for that, I need to check whether the letter or number keys on a keyboard are pressed and if so, run a macro that shows the assistant popup and do the background work.
The problem is that I can't get the keypress detection to work. I tried multiple things like the two examples below but they don't give me the desired effect.
Private Sub document_KeyPress(KeyAscii As Integer)
If KeyAscii > -1 Then
MsgBox ("You Pressed a key")
End If
End Sub
Private Sub document_open()
'This line may differ depending on whether you are running this from a document template or an add-in.
Application.CustomizationContext = ThisDocument.AttachedTemplate
' Create the keybinding.
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeySpacebar), KeyCategory:=wdKeyCategoryMacro, Command:="MyMacro"
End Sub
The first one is not working at all and the seconds overwrites the keybinding which makes the spacebar in this example useless. With the second example, I also have to assign a binding for each character.
Any advice would be appreciated.
Since your question implies that you are doing this for yourself and not trying to deploy this macro to others, you can simply assign a keyboard shortcut to the macro from Word Options and you don't have to write custom keyboard trapping VBA to do this.
From Word's File tab select Options
Click Customize Ribbon
Click Keyboard shortcuts: Customize...
Select Macros from the All Commands Categories list
Locate your custom Macro and Assign a custom keyboard sequence
Via links that were shared in the post, I came across a program called AutoHotKey. After some research, I set up a system where AutoHotkey does the detecting part and then calls the macro in word. I use the following hotkey script:
Keybinding for a-x before this
y::
send y
StartLabel("a")
return
z::
send z
StartLabel("a")
return
Space::
send {Space}
StartLabel("a")
return
Backspace::
send {Backspace}
StartLabel("a")
return
^Backspace::
send ^{Backspace}
StartLabel("a")
return
StartLabel(x)
{
word:=ComObjActive("word.application")
word.run( "Writeass" ) <-- macro name. No need to define the module first
}
This script calls the macro every time one of de defined keys is pressed.
With a simple bat file I can start and close the script (to make sure it does not run in the background when wordt is not open).
Bat code to start the script:
start C:\path to Autohotkey script\WriteAssistant.ahk
Bat code to end the script (killing the autoHotKey process)
taskkill /im AutoHotkey.exe
I use the following vba script to start and close the hotkeyscript from a word macro (in my case I made a button in the ribbonbar to start the macro and the first thing it does is start the autoHotKey script):
Path = "C:\path\start.bat"
Shell Path
And best of all, I didn't notice any speed loss.

intellijidea code completion not new variables

I'm using Android Studio and I have code completion enabled as in picture.
I have enabled "Autopopup code completion" and "Insert selected variant by typing dot, space, etc..".
I want to write:
Drawable d = new BitmapDrawable(....);
I write "Dr", appears the popup, I click the space bar, and it writes "Drawable". It's all ok.
Then I write "d", appears the popup with "drawable" suggested, I click the space bar, and it writes "drawable".
But I want to write "d".
Is it possible to change this option applying only to classes and methods and not to new variables?
There is not a way to have code complete only apply to classes and methods and not to new variables. You have three options:
Turn off the Insert selected variant by typing dot, space, etc." options. You will then need to use Enter (to insert) or Tab (To overwrite) when you want to select an item from auto complete. The . (period/dot) key will still work when completing classes if you want to invoke a static member. (This is likely the best of the three choices and is the default behavior.)
After you type d for the variable name, hit Esc to close the auto complete popup before you hit the Space.
Turn off "Autopopup code completion" so that you have to manually activate it each time via Ctrl+Space

Go to the Beginning of String in "System.Windows.Forms.TextBox" - VB.Net

I have an application written in VB.Net where I call a dialog window that lets a user select a file or folder to copy. In that window I have text pre-populated in the file name field as an informational type of message to the user. However the text is so long that it only shows the last bit of it, so I need a way to reset the cursor position to the first character in the string. I also have the text highlighted by default so that the user can just begin typing to overwrite it. Here's what I have so far-
pushLocationBox1.SelectAll()
cursorPosition = pushLocationBox1.SelectionStart
I think the "cursorPosition = pushLocationBox1.SelectionStart" is a good start at getting the location I need to point the cursor to, but I'm not sure where to go from there.
Thanks in advance.

Send HTML Mail from Cocoa with Mail.app

I'm trying to send html email from Cocoa app, through Mail.app. I want to open new message in Mail.app, include subject, recipient and add HTML Body with links and other content. But can't find the way to do this.
I already tried Scripting Bridge, but MailOutgoingMessage class doesn't have content type i can add content in plaintext.
tried AppleScript, something like this:
set htmlContent to read "/Path/index.html"
set recipientList to {"mail#mail.com"}
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:"qwerty", visible:true}
tell newMessage
make new to recipient at end of to recipients with properties {address:"mail#s.com"}
set html content to htmlContent
--send
end tell
end tell
this code send email with html, only if I'm changing --send to send. But i need to send letter later, after user made some changes.
To recap the problem: Using AppleScript to create a message with HTML content for interactive editing does not work (as of OS X 10.9.2): the new-message form comes up with an empty body.
This should be considered a bug and I encourage everyone to let Apple know at http://bugreport.apple.com - caveat: the html content message class property is not defined in Mail.sdef, Mail.app's AppleScript dictionary, so assigning HTML may not be officially supported.
There is a workaround, but it ain't pretty:
Create the message invisibly.
Save it as a draft.
Open the draft message, at which point the HTML content will appear.
Implementing this robustly is challenging, because several workarounds are required. The following code tries its hardest, though:
Note: Since the code uses GUI scripting, Access for Assistive Devices must be enabled (via System Preferences > Security & Privacy > Accessibility) for the application running this code (e.g., AppleScript Editor or, if run via osascript, Terminal.app).
# Example values; use `read someFile` to read HTML from a file.
set htmlContent to "<html><body><h1>Hello,</h1><p>world.</p></body></html>"
set recipientList to {"person1#example.com", "person2#example.com"}
set msgSubject to "qwerty"
tell application "Mail"
# Create the message *invisibly*, and assign subject text
# as well as the HTML content.
set newMessage to make new outgoing message with properties ¬
{visible:false, subject:msgSubject, html content:htmlContent}
# Add recipients.
# !! Given the workaround below, this is currently pointless.
tell newMessage
repeat with toRcpt in recipientList
make new to recipient at end of to recipients with properties {address:toRcpt}
end repeat
end tell
# Save the current number of drafts messages.
set draftCountBefore to count messages of drafts mailbox
# !! Save the new message as a *draft* - this is necessary
# for the HTML content to actually appear in the message
# body when we open the message interactively later.
save newMessage
# !! Sadly, it takes a little while for the new message
# !! to appear in the drafts mailbox, so we must WAIT.
set newMessageAsDraft to missing value
repeat with i from 1 to 30 # give up after n * 0.1 secs.
set draftCountNow to (count messages of drafts mailbox)
if draftCountNow > draftCountBefore then
set newMessageAsDraft to message 1 of drafts mailbox
exit repeat
end if
delay 0.1 # sleep a little
end repeat
# Abort, if the draft never appeared.
if newMessageAsDraft is missing value then error "New message failed to appear in the drafts mailbox within the timeout period."
# Open the new message as a *draft* message - this ensures that
# the HTML content is displayed and editable in the message body.
# !! The ONLY solution I found is to use `redirect`, which, unfortunately,
# !! *wipes out the recipients*.
# !! It does, however, ensure that the draft is deleted once the message is sent.
redirect newMessageAsDraft with opening window
# Activate Mail.app and thus the draft message's window.
activate
# !! Since the recipients have been wiped out, we need to
# !! add them again - unfortunately, the only way we can do that is to
# !! *GUI scripting* - simulating invocation of a menu command or
# !! sending keystrokes.
tell application "System Events"
# We must make sure that the target window is active before
# we can perform GUI scripting on it.
set newMessageWindow to missing value
repeat with i from 1 to 30 # give up after n * 0.1 secs.
tell (first window of (first process whose frontmost is true) whose subrole is not "AXFloatingWindow")
if name is msgSubject then
set newMessageWindow to it
exit repeat
end if
end tell
delay 0.1 # sleep a little
end repeat
if newMessageWindow is missing value then error "New message failed to become the active window within the timeout period."
# Turn the list of recipients into comma-delimited *string* for pasting into the To field.
set {orgTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {","}}
set recipientListString to (recipientList as text)
set AppleScript's text item delimiters to orgTIDs
# Save the current clipboard content.
set prevClipboardContents to the clipboard
# Cursor is in the "To:" field, so use GUI scripting to send the Edit > Paste command now.
# NOTE: Access for assistive devices must be enabled via System Preferences > Security & Privacy > Accessibility.
set the clipboard to recipientListString
my pasteFromClipboard("")
# Restore the previous clipboard content.
# !! We mustn't do this instantly, as our temporary content may not have
# !! finished pasting yet. It would be non-trivial to determine
# !! when pasting has finished (examining `count of to recipients` doesn't work),
# !! so we take our chances with a fixed, small delay.
delay 0.1
set the clipboard to prevClipboardContents
# Place the cursor in the message *body*.
# !! This works as of Mail.app on OS X 10.9.2, but may break in the future.
try
tell newMessageWindow
tell UI element 1 of scroll area 1
set value of attribute "AXFocused" to true
end tell
end tell
end try
end tell
end tell
(*
Pastes form the clipboard into the active window of the specified application (process) using GUI scripting
rather than keyboard shortcuts so as to avoid conflicts with keyboard shortcuts used to invoke this handler.
Specify "" or `missing value` to paste into the currently active (frontmost) application.
The target process may be specified by either name or as a process object.
CAVEAT: While this subroutine IS portable across *UI languages*, it does make an assumption that will hopefully hold for
all applications: that the "Edit" menu is the *4th* menu from the left (Apple menu, app menu, File, Edit).
Examples:
my pasteFromClipboard("") # paste into frontmost app
my pasteFromClipboard("TextEdit")
*)
on pasteFromClipboard(targetProcess)
tell application "System Events"
if targetProcess is missing value or targetProcess = "" then
set targetProcess to first process whose frontmost is true
else
if class of targetProcess is text then
set targetProcess to process targetProcess
end if
-- Activate the application (make it frontmost), otherwise pasting will not work.
set frontmost of targetProcess to true
end if
tell menu 1 of menu bar item 4 of menu bar 1 of targetProcess
-- Find the menu item whose keyboard shortcut is Cmd-V
set miPaste to first menu item whose value of attribute "AXMenuItemCmdChar" is "V" and value of attribute "AXMenuItemCmdModifiers" is 0
click miPaste
end tell
end tell
end pasteFromClipboard
It isn't clear what your are looking for, but I'll do my best to offer some help.
If you leave send commented, then the message should already be open in Mail.app, waiting for further editing and sending.
By adding the line save newMessage, it will be saved to the drafts folder. The user can open it and continue editing whenever they please. If you want to actually send the draft from your application, use:
set sendMessage to first message of drafts mailbox
send sendMessage
Good luck!
I didn't see that you needed to edit the message before sending, so my previous answer was wrong. This time it should be correct.
It basically
takes a preformatted RTF file,
renders it & puts it into the clipboard,
creates a new message,
fills in the fields,
moves the focus to the message body,
pastes the formatted clipboard
Here is the code:
set textSubject to "HTML Test"
set toAddress to "john.doe#gmail.com"
set toName to "John Doe"
tell application "Mail"
do shell script "cat ~/Documents/RTF\\ File.rtf | textutil -stdin -stdout -convert rtf | pbcopy"
set refMessage to make new outgoing message with properties {name:toName, address:toAddress, subject:textSubject, visible:true}
tell refMessage
make new to recipient at end of to recipients with properties {name:toName, address:toAddress}
end tell
end tell
tell application "System Events"
tell application process "Mail"
set frontmost to true
set value of attribute "AXFocused" of scroll area 4 of window textSubject to true
end tell
keystroke "v" using {command down}
end tell
Again, this worked fine on Snow Leopard
Hope that helped.

Repeating a navigation command in vi

How do I repeat a navigation command in vi?
For example, I execute the command 20j which moves the cursor down 20 lines, and I tried hitting . to repeat that command, but it says "No command to repeat".
P.S. Also, what command goes to the next page in a document?
There isn't a shortcut to repeat the last navigation command - you have to retype it, or set up some sort of shortcut of your own (:map or similar).
Page up (back) is Control-B; page down (forward) is Control-F. Half-pages are Control-U (up) and Control-D (down).