Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2018-07

IDE option: Convert selection to string ?

7 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt

Hello,

The IDE contains a 'make resource string' refactoring option.

This requires the selection to be a pascal string.

However, I quite often find myself in the need to create a string constant from arbitrary text:

I test an SQL statement in an SQL tool, and then I copy it to the pascal source file where I need it. I must then manually convert it to a string constant by adding the necessary quotes, doubling single quotes already there and appending +sLineBreak+ etc.

It would be nice if the IDE could do this:
select a block of text, and choose 'Refactoring -> convert to pascal string'

Currently I have a separate tool that does this (both ways: quote and unquote, in case I need to re-rest an SQL statement from my code) but it would be a lot faster if the IDE could do it for me. Most likely it already contains code that does similar things like this.

I cannot imagine I am the only one with this need :)

Any chance of getting such a feature ?

Michael.

Reply by email

Anthony Walter
to Michael Van Canneyt: The IDE contains a 'make resource string' refactoring option. This requires the selection…

How about something that takes the current caret position in the source editor, the clipboard context, and inserts as a Pascal quoted string that wraps with + at the end of line, and appropriate system defined line break characters?

The command for this would be in the menu as "Edit -> Paste as String", and reassignable through custom keyboard bindings.

This would be easy enough to add, but for me unfortunately I've been busy with moving and renovating my house. When I'm done if no one else has added it, I might write it as an add on package.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20180712/838d542a/attachment.html>

Reply by email

Michael Van Canneyt
to Anthony Walter
Anthony Walter wrote 11 lines
How about something that takes the current caret position in the source editor, the clipboard context, and inserts as a Pascal quoted string that wraps with + at the end of line, and appropriate system defined line break characters? The command for this would be in the menu as "Edit -> Paste as String", and reassignable through custom keyboard bindings. This would be easy enough to add, but for me unfortunately I've been busy with moving and renovating my house. When I'm done if no one else has added it, I might write it as an add on package.

I think both options should be available. Sometimes the clipboard contains 'too much' and I want to limit the selection.

The underlying mechanism is of course the same.

Michael.

Reply by email

Martin Frb
to Anthony Walter: How about something that takes the current caret position in the source editor, the…
Anthony Walter wrote 12 lines
How about something that takes the current caret position in the source editor, the clipboard context, and inserts as a Pascal quoted string that wraps with + at the end of line, and appropriate system defined line break characters? The command for this would be in the menu as "Edit -> Paste as String", and reassignable through custom keyboard bindings. This would be easy enough to add, but for me unfortunately I've been busy with moving and renovating my house. When I'm done if no one else has added it, I might write it as an add on package.

For this, have a look ot menu Edit > Multi line paste

Reply by email

Michael Van Canneyt
to Martin Frb
Martin Frb wrote 14 lines
On 12/07/2018 14:36, Anthony Walter via Lazarus wrote: > How about something that takes the current caret position in the > source editor, the clipboard context, and inserts as a Pascal quoted > string that wraps with + at the end of line, and appropriate system > defined line break characters? > > The command for this would be in the menu as "Edit -> Paste as > String", and reassignable through custom keyboard bindings. > > This would be easy enough to add, but for me unfortunately I've been > busy with moving and renovating my house. When I'm done if no one else > has added it, I might write it as an add on package. > For this, have a look ot menu Edit > Multi line paste

'Multipaste'

Very nice, these hidden gems... :)

Michael.

Reply by email

Martin Frb
to Michael Van Canneyt: The IDE contains a 'make resource string' refactoring option. This requires the selection…
Michael Van Canneyt wrote 10 lines
It would be nice if the IDE could do this: select a block of text, and choose 'Refactoring -> convert to pascal string' Currently I have a separate tool that does this (both ways: quote and unquote, in case I need to re-rest an SQL statement from my code) but it would be a lot faster if the IDE could do it for me. Most likely it already contains code that does similar things like this.

While it would be nice as a build in, you can always add it as pascal script macro.

Reply by email