Welcome Guest.   Make a donation to an author on the site August 22, 2014, 08:49:11 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2011! Download 30+ custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1] 2 Next   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Is this a worthwhile idea for a program?  (Read 7397 times)
tranglos
Supporting Member
**
Posts: 1,079



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« on: October 07, 2011, 02:12:14 PM »

(How does one create a poll?)

OK, I'm thinking out loud here, so please bear with me or ignore :) Here's a scenario I've had to contend with countless times. I'm translating a large document that contains innumerable specifications, such as power consumption, capacity, operating temperatures, dimensions, weight etc. So, lots of numbers. When translating between English and Polish it involves endless tweaking of punctuation. English "1.5" becomes "1,5" in Polish (decimal separator). English 12,000 becomes "12<non-breaking-space>000" in Polish (thousands separator). Then there are other little tweaks of spacing (we don't put a space before the degree ° sign, for example) and units of measure. You can imagine it gets tedious quickly. Today I've gone though well over a hundred of such lines.

This needs to be automated, and implemented in such a way that it works with any text editing application.  Plus, the solution needs to be abstracted enough to be generally useful.

For a long time I've looked for an excuse to write an app that executes user-created scripts. (At the moment there seems to be a dearth of Delphi scripting solutions that handle Unicode, so this might present a big obstacle, but right now I want to think positive for once :-) Would this be useful at all? Here's what I'm imagining:

1) You press a hotkey, and the as-yet-unnamed app acquires text from the application you are working in. This can be done via the clipboard or (better, harder) by accessing the text directly. So the app grabs the text and:

2) executes a script that you preselected when starting your work. In my case the script would do the appropriate replacements on the various numeric values, but it could do anything. Then:

3) the app puts the result back on clipboard or injects it directly into your editor.

Questions:

So, does this seem like a worthwhile standalone project? Assume the app does nothing else except the points above.

What existing solutions could be used to achieve the same goal? I suppose AHK could be coerced to do that. Anything else? Is it even remotely interesting?

(Yes, I've considered adding this to Echo, but I am not convinced it's a good idea. For one thing, Echo would be capturing the clipboard and modifying its contents nearly instantly, and that would play badly with other apps that monitor the clipboard. In general, I think it'd create a mess, but I haven't excluded that route just yet.)
« Last Edit: October 07, 2011, 02:44:13 PM by tranglos » Logged

Ath
Supporting Member
**
Posts: 2,196



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #1 on: October 07, 2011, 02:19:28 PM »

Might I drop the suggestion 'regex replace' at just in front of your shoes? The source-capturing and result-presenting would be the next challenge ofcourse, but this is just a quicky suggestion Wink
Logged

tranglos
Supporting Member
**
Posts: 1,079



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #2 on: October 07, 2011, 02:24:28 PM »

Might I drop the suggestion 'regex replace' at just in front of your shoes? The source-capturing and result-presenting would be the next challenge ofcourse, but this is just a quicky suggestion Wink

A script can do anything, so it can certainly do regex replacement, as long as the scripting language (or its libraries) have support for regular expressions.

It would be another matter to ask for user input every time. Possible of course, but not as automated as I would like.
Logged

Curt
Supporting Member
**
Posts: 6,323

see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #3 on: October 07, 2011, 02:40:20 PM »

I sure would use such a program  Kiss

However, the Anglophile part of the world makes it difficult to simply make one rule. Many or even most Americans have erroneous learned to say and write "kgs" for kilograms. You and I are using "kg", because we know it never is plural; 1 gram, 2 gram. Are you ready to double the set of rules?
Logged
tranglos
Supporting Member
**
Posts: 1,079



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #4 on: October 07, 2011, 02:48:53 PM »

However, the Anglophile part of the world makes it difficult to simply make one rule. Many or even most Americans have erroneous learned to say and write "kgs" for kilograms. You and I are using "kg", because we know it never is plural; 1 gram, 2 gram. Are you ready to double the set of rules?

That goes in the script smiley

All the program itself does is grab text, pass it on to the script, then put the changed text back. In the script you can do whatever. You are right of course, and then there are different rules for different languages - which is why for the application to be useful to anyone but me, it has to be script based. Then there is no limit to the transformation rules you can create.



Logged

MilesAhead
Member
**
Posts: 4,772



View Profile WWW Give some DonationCredits to this forum member
« Reply #5 on: October 07, 2011, 02:50:56 PM »

You may be better off using a programmable editor like Vim. The mechanism is already debugged. You may be able to find scripts to do some or all of your substitutions. Windows ports of other Linux tools are available such as sed and nawk.

You could check out the available scripts. If you get stuck you could likely find forums of enthusiasts who tinker with scripts or know where to find more that may help you get over the hurdle.

Windows ports of bash shell are available if you need to pipe the output of one into the input of another. It sounds like the type of task that someone would have automated already.  At least partially.

Logged

"Genius is not knowing you can't do it that way."
- MilesAhead
Curt
Supporting Member
**
Posts: 6,323

see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #6 on: October 07, 2011, 03:03:07 PM »

(How does one create a poll?)



Logged
tranglos
Supporting Member
**
Posts: 1,079



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #7 on: October 07, 2011, 03:17:44 PM »


Thanks, Curt!
Logged

tranglos
Supporting Member
**
Posts: 1,079



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #8 on: October 07, 2011, 03:21:14 PM »

You may be better off using a programmable editor like Vim.

I wish! smiley I could do that in EmEditor or UltraEdit as well, seeing as they both come with JavaScript built in. Trouble is, for my specific needs, I work in a highly specialized "vertical" app called Trados (most translators know (of) it; most non-translators don't). Using it is a requirement, and it is actually a good thing, but it lacks certain features. Anyway, I don't have the liberty of using an editor of choice, hence the idea for a sidekick app.
Logged

superboyac
Charter Member
***
Posts: 5,650


Is your software in my list?

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #9 on: October 07, 2011, 03:38:47 PM »

I think it would be a great application, I would use it a lot.

It would be similar to TextMonkey except for being more open and flexible.  Textmonkey has predefined scripts and no ability to change them in any way.  But the rest of the functionality is there as far as reading a clip, processing it, and putting the new clip back in the clipboard.

It's sort of a super-charged find&replace program.  skwire's "list numberer" is also a very specialized version of something like that.  The key point to me is, how do you make something like that easy to use while being flexible enough to be generally appealing?  usually things like this are handled with regex, which nobody really knows how to use, nor would want to use without a gun placed to their head.
Logged

rjbull
Charter Member
***
Posts: 2,746

View Profile Give some DonationCredits to this forum member
« Reply #10 on: October 07, 2011, 03:48:39 PM »

Several utilities for modifying clipboard text (as opposed to saving clips) already exist.  Take a look at my post here in anandcoral's thread NANY 2012 Pledge & Early Beta: Paste Text Like.  In particular I'd recommend you look at Clippy, for two reasons.  One is that you can already set it up with multiple search-and-replace strings, though I doubt Unicode.  The other is for its streamlined operation.  You mark your text in the usual way, press the Clippy hotkey, then Ctrl-V, and your modified text is pasted back over the marked text.  I found simple and convenient.  You might find it interesting to compare Clippy with your current concepts.

Be aware that the Clippy Web site is often down.  It's a small program, and I've attached it to the referenced post.
Logged
mouser
First Author
Administrator
*****
Posts: 33,256



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #11 on: October 07, 2011, 03:56:54 PM »

cough cough..

My Clipboard Help+Spell program can do all of this already.

In addition to what you are asking for (running a user-written script, written in any scripting language; copying text before running script, pasting after it finished), it can also apply a large number of built in operations on text (trimming, adding line numbers, etc.) without using any script.

Plus it will allow you to list your saved transformation operations in a menu that you can trigger, or assign them to specific hotkeys for really quick work.

NOTE: Using scripts is an advanced feature in CHS, and not one heavily documented or used by many people.  But it was set up for exactly this kind of use.

[edit: i should say that because no one ever uses this feature it may be rough around the edges and not very tested.. so i probably need to do a little improvement on it if people actually plan to use it]

ps. CHS runs "scripts" in a very simple way but one that gives most flexibility.  It saves the input text to a temp file, invokes the specified script/executable and passes it temp input file path, desired output file path, and any other arguments.  When the launched script/executable finishes it grabs the output file and puts it back onto clipboard.
« Last Edit: October 07, 2011, 04:11:30 PM by mouser » Logged
rjbull
Charter Member
***
Posts: 2,746

View Profile Give some DonationCredits to this forum member
« Reply #12 on: October 07, 2011, 04:04:52 PM »

mouser, is CHS Unicode, as tranglos requires?
Logged
cranioscopical
Friend of the Site
Supporting Member
**
Posts: 4,167



see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #13 on: October 07, 2011, 04:09:25 PM »

no one ever uses this feature
But I use your built-in stuff umpteen times a day (and here I use "umpteen" in its pure form).
Logged

Chris
mouser
First Author
Administrator
*****
Posts: 33,256



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #14 on: October 07, 2011, 04:09:34 PM »

Good point, CHS is *not* unicode.
Logged
rjbull
Charter Member
***
Posts: 2,746

View Profile Give some DonationCredits to this forum member
« Reply #15 on: October 07, 2011, 04:14:43 PM »

mouser, I think the scripting configuration might be buried too deep.  You have to pick an individual clip, then Modify Format/Case -> User tools -> Configure user tools in order to enter scripts.  It's certainly not obvious script-running possibilities exist from the main menu.  Should script configuration be an item on the main configuration menu instead?
Logged
superboyac
Charter Member
***
Posts: 5,650


Is your software in my list?

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #16 on: October 07, 2011, 04:23:39 PM »

mouser, I didn't even realize CHS could do this until maybe last week or so.  Guys, check it out, it's freaking awesome:
Logged

mouser
First Author
Administrator
*****
Posts: 33,256



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #17 on: October 07, 2011, 04:34:48 PM »

Quote
mouser, I think the scripting configuration might be buried too deep.


actually i think that's being too kind.  it's pretty horrible and confusing the way it is now.

i think the solution is just to move it as just another option in the configuration dialog above, so you can combine it with any other configured built-in modifier you create, to run before or after the built-in transformations.

the real problem is simply that no one has shown much interest in the feature so i haven't bothered to improve it.

maybe what i can do is change that modification dialog to be a tree-based configuration like the main options are, which would give me a little more room to explain options, and then make it a page there.

anyway -- i don't want to take away from this thread, but i'd be happy to discuss it in the CHS forum section -- and i'd be happy to make some improvements to the script running feature if i can find someone who plans to use it.
Logged
rjbull
Charter Member
***
Posts: 2,746

View Profile Give some DonationCredits to this forum member
« Reply #18 on: October 07, 2011, 04:51:47 PM »

no one has shown much interest in the feature so i haven't bothered to improve it.
Maybe IainB hasn't discovered it yet  cheesy

i don't want to take away from this thread, but i'd be happy to discuss it in the CHS forum section
Is there any way to sort of transfer the CHS-related posts above to a new thread over there, preferably retaining a link to this as the origin?
Logged
mouser
First Author
Administrator
*****
Posts: 33,256



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #19 on: October 07, 2011, 05:01:36 PM »

yeah i'll split starting at your first post about chs scripting, and link back to this one.
Logged
40hz
Supporting Member
**
Posts: 10,579



see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #20 on: October 07, 2011, 06:16:56 PM »

mouser, I didn't even realize CHS could do this

Wow! Me neither.

Quote
Guys, check it out, it's freaking awesome

Understatement. Bravo Mouser!

(I really have to stop blathering so much in the forum and start checking out DoCo's software section more carefully. There are some true gems to be found in there.  embarassed )

Logged

Don't you see? It's turtles all the way down!
MilesAhead
Member
**
Posts: 4,772



View Profile WWW Give some DonationCredits to this forum member
« Reply #21 on: October 07, 2011, 06:35:50 PM »

You may be better off using a programmable editor like Vim.

I wish! smiley I could do that in EmEditor or UltraEdit as well, seeing as they both come with JavaScript built in. Trouble is, for my specific needs, I work in a highly specialized "vertical" app called Trados (most translators know (of) it; most non-translators don't). Using it is a requirement, and it is actually a good thing, but it lacks certain features. Anyway, I don't have the liberty of using an editor of choice, hence the idea for a sidekick app.


I don't get it. If you can clipboard stuff out, then paste it back in after transformations, you can paste it into a programmable editor and paste it back?  Maybe I have to be there to see the obstacle.

edit: Maybe that Text Editor Anywhere could bridge the gap between the specialized editor and one of your programmable ones?


« Last Edit: October 07, 2011, 06:47:57 PM by MilesAhead » Logged

"Genius is not knowing you can't do it that way."
- MilesAhead
rjbull
Charter Member
***
Posts: 2,746

View Profile Give some DonationCredits to this forum member
« Reply #22 on: October 08, 2011, 03:42:44 PM »

I don't get it. If you can clipboard stuff out, then paste it back in after transformations, you can paste it into a programmable editor and paste it back?  Maybe I have to be there to see the obstacle.
Think of it in terms of streamlined workflow.  As in my earlier post re.: Clippy, mark text, press Ctrl-C, press Clippy hotkey, press Ctrl-V, job done.  Fewer actions than doing the same job via an editor.
Logged
mouser
First Author
Administrator
*****
Posts: 33,256



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #23 on: October 08, 2011, 03:49:57 PM »

It's not that hard to see why this kind of operation can save a huge amount of time, compare the two workflows:

I have 10 paragraphs of text, for each one i need to perform some formatting on it (like line wrap to 70 columns).

Method 1: For each section of text (say 10 sections):
  • Select it with cursor
  • Hit hotkey assigned to formatter.

Method 2: For each section of text (say 10 sections):
  • Select it with cursor
  • Hit Ctrl+C to copy to clipboard
  • Find formatter tool window, click on it
  • Clear existing text in it (ctrl+A then delete)
  • Paste new clipboard text into it with Ctrl+V
  • Activate desired formatting with menu or button
  • Select it and Ctrl+C to copy new text to clipboard
  • Find previous window
  • Ctrl+V to paste the newly formatted text

Which would you rather do over and over?
Logged
MilesAhead
Member
**
Posts: 4,772



View Profile WWW Give some DonationCredits to this forum member
« Reply #24 on: October 08, 2011, 04:06:55 PM »

Yes but what's the difference between a "formatting program" and an editor that has a script loaded sitting there waiting for the paste? For all purposes the editor is an interpreter running your "formatting program."

Set it as default in Text Editor Anywhere.  Select text, hit the hotkey. Hit Go to run the script in the editor.  What's the difference?
Logged

"Genius is not knowing you can't do it that way."
- MilesAhead
Pages: [1] 2 Next   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.054s | Server load: 0.16 ]