KDevelop: transform selected text? - kdevelop

I was wondering whether there was a function in KDevelop similar to the one that we used to have in Quanta (miss you, Quanta, btw).
I would like to set a keyboard shortcut, and apply a text transformation upon hitting it. Example:
I select my text to be translated, and I get back: <?=_('my text to be translated'?>
As you can see, this saves me a lot of awkward keystrokes...
I only found this feature in PHPStorm (where it is called "Live Templates"). I defined it like this: <?=t('$SELECTION$')?> and I can call it by hitting CTRL+ALT+J, and select it from the dropdown that appears.

You should be able to do that using a snippet with the following text: <?=_('%{selection}'?>
And you can bind a Shortcut to a snippet.
However my tests showed that this doesn't work correctly - there seems to be a bug somewhere.
As alternative you can write a script that does insert the text. See the documentation.

Related

ReactSearchAutocomplete DO NOT select the first option when writing

I use this code https://codesandbox.io/s/intelligent-sun-f73pn9?file=/src/App.js
in my project and it becomes different from what appears.
When I write in the search box the first option is not selected.
where when I use it in my project the first option is always selected.
Same here: https://codesandbox.io/s/sleepy-kate-7k3xo7?file=/src/serviceWorker.js
Please if u know the reason help me with that.
How I can do not select the first option always like the first code?

QuillJS - remove formatting when pasting into the editor

I previously used https://github.com/quilljs/quill/issues/1184#issuecomment-403657128 to make sure that no one can paste formatted text in the QuillJS editor, because I would like people to only use the few editing buttons that I enabled from QuillJs. Since then, it stopped working for me. My question is:
is this working for everyone else?
if no, do you know of an alternative?
One thing about https://github.com/quilljs/quill/issues/1184#issuecomment-403657128 that may behave different than you may have expected could be the 'silent'.
"APIs causing text to change may also be called with a "silent" source, in which case text-change will not be emitted. This is not recommended as it will likely break the undo stack and other functions that rely on a full record of text changes." [ https://quilljs.com/docs/api/#events ]
So if you expected to get the text-change event get emitted but do not get it, then change these two lines
this.quill.updateContents(delta, 'silent')
this.quill.setSelection(index, length, 'silent')
like this:
this.quill.updateContents(delta, 'user')
this.quill.setSelection(index, length, 'user')
Then the text-change event will get fired.

How to save codes on VS Code Mac?

I am using VS Code on a Mac to write ReactJS, however I find that I could not save my code. If I use command and s to save, then the JSX will be a mess, just like shown in the picture:
enter image description here
So how could I solve it? Thank you
I think your code is being saved, but that your code formatting is messing-up your code.
Hit the following combination : Shift+Command+P
This will open a menu on top. Inside that menu type Format Document With..., and select it. It will allow you to format your code with a different auto-format tool. Choose the one that is appropriate for your code i.e. Prettier.

Dynamic Hyperlink in Livecycle Form

I am trying to figure out how to make a hyperlink in a Livecycle Form which points to a URL which will change on different days that the form is rendered. For example on one day I might want the hyperlink to point to:
mywebsite/mypage?option=XXX
and on another day I want it to point to:
mywebsite/mypage?option=YYY
The XXX and YYY can be passed into the form's data pretty easily as XML, but I just don't know how to make it so that the hyperlink is changed to correspond to this.
Any suggestions?
This can be accomplished with JavaScript in LiveCycle Designer. The following script, placed on the Form's docReady event will let you dynamically change the URL of a text object.
form1::docReady - (JavaScript, client)
// If this code is running on the server, you don't want it to run any code
// that might force a relayout, or you could get stuck in an infinite loop
if (xfa.host.name != "XFAPresentationAgent") {
// You would load the URL that you want into this variable, based on
// whatever XML data is being passed into your form
var sURL = "www.stackoverflow.com"; // mywebsite/mypage?option=xxx
// URLs are encoded in XHTML. In order to change the URL, you need
// to create the right XHTML string and push it into the Text object's
// <value> node. This is a super simple XHTML shell for this purpose.
// You could add all sorts of markup to make your hyperlink look pretty
var sRichText = "<body><p>Foo</p></body>";
// Assuming you have a text object called "Text1" on the form, this
// call will push the rich text into the node. Note that this call
// will force a re-layout of the form
this.resolveNode("Text1").value.exData.loadXML(sRichText, false, true);
}
There are a couple of caveats: URLs in Acrobat are only supported in Acrobat 9.0 and later. So if someone using an older version of Acrobat opens your form, the URLs won't work.
Also, as you can see from the "if (xfa.host.name !=...)" line, this code won't run properly if the form is being generated on the server, because forcing a re-layout of a form during docReady can cause problems on certain older versions of the LiveCycle server. If you do need to run this script on the server, you should probably pick a different event then form::docReady.
I a number of complaints from users in WorkSpace that clicking links opened them in the same tab so they lost their WorkSpace form, and there's no option to change that in Designer 11. I think the solution I came up with for that would work for you too.
I made buttons with no border and no background, and in their click event have this line (in Javascript, run at client)
app.launchURL("http:/stackoverflow.com/", true);
It would be easy to add some logic to choose the right URL based on the day and it doesn't cause any form re-rendering.
In some spots where the hyperlink is in line with other text, I leave the text of the link blue and underlined but with no hyperlink, and just place the button (no background, no border, no caption) over it. Does require positioned and not flowed subforms for that to work, so depending on your layout it could get a little clunky.
Wow, just realized I am super late to the party. Well, for anyone using ES4 facing a similar problem . . .
Ended up using a 3rd party component to manipulate the PDF's hyperlinks...wish there was a better solution as this one costs about $1000.

Macros in SQL Server Management Studio

Is there any way to implement text editing macros in SSMS? I would, e.g. like to convert the the code as shown below, but with a key-press, not a long-winded regex search and replace.
This:
INSERT INTO [TABLE]
([fieldOne]
,[fieldTwo])
VALUES
(<fieldOne, datetime,>
,<fieldTwo, real(24,0))
Must become this:
INSERT INTO [TABLE]
([fieldOne]
,[fieldTwo])
VALUES
(#fieldOne
,#fieldTwo)
I know SSMS doesn't natively support this, but I also know that it is extensible, if undocumented, and there is also room for a totally external application that will take copied text, transform it, and paste it back, without having to open an editor, paste, edit, copy, and paste back to SSMS.
Editing the stored templates is not an option, as these templates are dynamically generated, and using Ctrl+Shift+M is not an option either, as I still have to type each parameter name, but without the convenience of copying and pasting in the query editor.
There is no SSMS solution! I am looking for some sort of external voodoo that can help me do this.
What about an AutoHotKey script?
Depending on the complexity of your templates, you could either
use AutoHotKey to play back the keystrokes
needed for the regex search and
replace, or
copy the template to
the clipboard and manipulate it
directly within AutoHotKey before
pasting it back.
I'm sure the first option will work. I've not tried the second.
This question gives an indication of how an AutoHotKey script can be written to listen for keyboard chords.
If you are using SSMS 2005 upwards it has in built support for templates. It isn't exactly full blown macro's, but non the less it is still pretty useful.
The syntax is exactly as you have shown in your first code snippet and you simply press Ctrl+Shift+M to bring up a dialog box that prompts you for the values to go into your bits enclosed in angle brackets.
SQL server generates script in this format if you right click on a table and select "Script Table as" then pick either the insert, update or delete option.
You can also create your own custom templates, or modify one of the existing built in ones (click on View -> Template explorer to get access to the other inbuilt templates).
There is a short article on MSDN that explains how to get started with templates.
Was looking for something else, but found this question. If you're still looking for something, try SSMS toolpack: http://www.ssmstoolspack.com/ It has macros and a bunch of other neat things. And it's free!
For SSMS 2016 you can use my Visual Commander extension. It supports macros recording/playback and custom C#/VB commands for editor text manipulations.
First code is template from old-good MS Query Analyzer. Shortcut to filling is Ctrl+M (but I'm not sure, maybe it is Ctrl+Shift+M).
There should be same feature in newer SSMS.
I usually copy the code into another editor (Notepad++, or Delphi /RAD Studio editor), do my macro stuff, and then paste it back into SSMS.

Resources