Home Download Buy Blog Forum Support

Multiple lines of user input

Multiple lines of user input

Postby phillip.koebbe on Sat Dec 24, 2011 9:31 pm

Is it possible to get multiple lines of user input using some sort of dialog? I've looked through the API documentation and all I see related to user input is Window.show_quick_panel and Window.show_input_panel. If I understand them correctly, the first lets the user choose from a list (like an HTML select) and the other lets the user input one line of text (like an HTML text input). I'm wanting the user to input multiple lines like an HTML textarea. Possible? If so, could someone point me to an example or documenation?

I'm trying to implement a search and replace that handles multiple pairs at a time. In a Rails project, I often find myself needing to replace constants, class names, and instances over and over, and instead of running three searches, I'd prefer to run just one. When I used TextMate, I created a command thing to pop up an input dialog into which I entered all of my pairs. I'd like to do something similar in ST2. As an example, I might do something like:

CAT=>DOG
Cat=>Dog
cat=>dog

I'd use regular expressions if I knew how to have the replacement retain the case of the subject being replaced.

Thanks much.
-- Phillip

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
end
phillip.koebbe
 
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm

Re: Multiple lines of user input

Postby C0D312 on Sat Dec 24, 2011 10:29 pm

The "Replace" panel has a button called "preserve case" that will do what you're looking for.
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: Multiple lines of user input

Postby phillip.koebbe on Sun Dec 25, 2011 3:31 pm

Thanks, C0D312. That gets me most of the way there. Now my only hurdle is when plural forms differ:

place => county
places => counties

But the preserve case option goes a very long way indeed!

Peace.
-- Phillip

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
end
phillip.koebbe
 
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm

Re: Multiple lines of user input

Postby phillip.koebbe on Sun Dec 25, 2011 5:59 pm

Well, not one to drop something I have in mind to do, I kept whacking at this problem. In the past, I have saved these find/replace pairs to a file so they can be reused. I decided there was no harm in just using that file as the input/display of what the find/replace pairs are. So, after a couple of hours of twiddling around, I came up with something that I think will work well enough for me, and I thought I'd share it just in case it's of interest to anyone else (either for its intended use or an example of how to do something).

https://gist.github.com/1519543

Since I'm pretty new to Python, I'd appreciate any suggestions on how to make the code better.

Peace.
-- Phillip

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
end
phillip.koebbe
 
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 22 guests