Farlap
Jul 18 2012, 2:42 am
By: Roy  

Feb 4 2013, 9:03 pm Wormer Post #21



Quote from Azrael
For a better understanding of the inherent problems with these other less efficient editors, check the "Background" collapse box in the first post.
I've read that. Usually you don't need to use \n in Vim regular expressions (except of some really weird cases). Like I said you can match any pattern and substitute it with the given text. For example if you want to change Terran to Zerg everywhere you execute ':%s /Terran/Zerg/g'.



Some.

Feb 4 2013, 9:09 pm Azrael Post #22



First of all, even in the example you just gave, that's less efficient than Farlap because it requires typing in more than just the search term. It is doing the same thing, except objectively worse.

Secondly, what would I enter into Vim to have it search for this:

[04:05 pm] Wormer -- Azrael, tell me what search and replace do you want to do and I'll tell you how to do it in Vim =)
[03:58 pm] Tuxlar -- wait WTF now i can view certain peoples streams but not others?
[03:57 pm] Tuxlar -- now its the opposite
[03:57 pm] Azrael -- The only reason I used text editors really is for large-scale find and replace, which Vim does as badly as Notepad++.
[03:56 pm] Tuxlar -- which is odd because yesterday it was only the chats i had problems with
[03:55 pm] Tuxlar -- its not merely lagging anymore, the feed outright stops
[03:55 pm] Tuxlar -- i cant watch twitch at all now for some reason
[03:54 pm] Azrael -- It felt like Notepad++ :P
[03:52 pm] Tuxlar -- https://www.youtube.com/watch?v=WT5K9wIuQP4 suddenly, i want to dabble in rom hacks again
[03:50 pm] Wormer -- What didn't you like?
[03:50 pm] Wormer -- lol
[03:49 pm] Azrael -- Pfft bad, I'm uninstalling ;o
[03:45 pm] Wormer -- Hi, Azrael! How's your vimming experience? =)
[03:24 pm] Azrael -- I'm watching.
[03:22 pm] jjf28 -- sweet, found a way to hack the start-game countdown timer to 0 :)
[03:19 pm] TiKels -- http://www.twitch.tv/TiKels http://www.twitch.tv/TiKels http://www.twitch.tv/TiKels
[03:19 pm] TiKels -- a-go
[03:19 pm] TiKels -- steam is ago
[03:16 pm] TiKels -- http://www.twitch.tv/tikels/ in a few moments...
[03:13 pm] TiKels -- stream incomingb
[03:05 pm] Wing Zero -- But the archer better be out by the time I do!
[03:04 pm] Wing Zero -- Ill be out in like an hour or two.
[03:03 pm] Wing Zero -- Im at work lol
[03:01 pm] Jack[RCDF -- Wing, TS2 gogo
[03:01 pm] Tuxlar -- </randomthought>
[03:00 pm] Tuxlar -- *enables
[03:00 pm] Tuxlar -- plus it makes the internet look bad, which enabled justification of cracking down on it
[03:00 pm] Tuxlar -- its like a playground for the CIA to do whatever they want
[02:59 pm] Tuxlar -- government fucking loves anonymous
[02:56 pm] TiKels -- alright I'll consider streaming in about 20 actual minutes
[02:55 pm] TiKels -- haha touche
[02:04 pm] Azrael -- Stream from a laptop, obviously.
[02:02 pm] TiKels -- i'm in class
[01:59 pm] TF- -- Shart Mode
[01:53 pm] Azrael -- Neither TiKels nor Oh Man are streaming.

And replace it with this:

Clark Adams (19692007): Prominent American freethought leader and activist.[1]
Jessica Ahlquist A Rhode Island teenager won a court battle to have a prayer banner removed from Cranston High School West and has that received a $40,000-plus scholarship from those who supported her efforts.
Ayaan Hirsi Ali (born 1969): Dutch feminist and politician.[2][3]
Natalie Angier (born 1958): Nonfiction writer and science journalist for The New York Times; 1991 winner of Pulitzer Prize for Beat Reporting.[4]
Dan Barker (born 1949): American atheist activist, current co-president of the Freedom From Religion Foundation, alongside his wife, Annie Laurie Gaylor.[5]
Walter Block (born 1941): Austrian School economist and neoliberal[6]
Peter Brearey (19391998): British secularist, socialist and journalist, Editor of The Freethinker from 1993 until his death.[7]
William Montgomery Brown (18551937): Episcopal bishop and Communist author.[8]

Even though there is some convoluted way for "advanced" text editors to do this, it is grossly inefficient compared to Farlap, with which you simply paste each block of text directly into the program and it does it automatically.

Furthermore, Farlap goes a step further, and uses a second box for the text output, preserving the original text in case you want to make different changes to it, or your replacement goes badly, which can be incredibly helpful when dealing with complex regular expression.

Even more, it tells you how many replacements were made during the process, another very useful piece of information.

Regardless of how much you may like some program for general text editing, it can't hold a candle to Farlap for finding and replacing text.




Feb 4 2013, 9:17 pm Wormer Post #23



I'm feeling you have preconceived opinion about all text editors. Assure you, Vim isn't like the others. I agree that it's not that easy to substitute the text you just given, but tell me when in the world will you need to subsitute so large blocks of text? When I'm editing triggers I don't need to do *that* massive substitutions. And as a side note, Vim also counts number of substitutions.

EDIT:
About undoing the initial text. Vim keeps it as a single change, so you can easily undo all substitutions at once. It keeps the whole undo/redo modifications tree of the file that you can travel. You can undo the file to a specified time: for example undo to a state when the file was 5 seconds (or 1 hour) ago. But it doesn't really have to do anything with our current discussion.

Post has been edited 5 time(s), last time on Feb 4 2013, 9:54 pm by Wormer.



Some.

Feb 4 2013, 9:40 pm Azrael Post #24



Quote from Wormer
I'm feeling you have preconceived opinion about all text editors. Assure you, Vim isn't like the others.
Your next statement contradicts this one.

Quote from Wormer
I agree that it's not that easy to substitute the text you just given
Exactly. So the program is like all other text editors in the sense it is not as powerful or efficient as Farlap in regards to text replacement.

There isn't any facet of find/replace that the program you mentioned does as well as Farlap, never mind better, and there are some things it can't reasonably do at all.

Quote from Wormer
tell me when in the world will you need to subsitute so large blocks of text?
All the time. I use it for restructuring triggers, I use it for large-scale replacements, I use it for reformatting text structures, and innumerable other things which other text editors, including the one you mentioned, simply cannot do well enough

In the Background collapse box which I mentioned earlier, this was the exact example which was used: Finding the contents of the shoutbox, and replacing it with a large block of text, like the Declaration of Independence.

I actually just used Farlap yesterday to add anchors to a list with over a hundred elements on a Wikipedia page. It took me under a minute.

Here are a couple examples of other uses:

Quote from Azrael
I was having to make a lot of minor replacements to a large body of text, and it was pretty tedious having to do them all consecutively. That's why I quickly used Farlap to reformat my large block of text into regex, and put the entries I want to replace at the top of the text block.


Quote from Azrael
I copied a chunk of the system that uses both the DC unit and the location that goes with it in each trigger, and had Farlap strip away all the useless information to generate me a neat list of which units go with which death counts.


Quote from Wormer
When I'm editing triggers I don't need to do *that* massive substitutions.
There are people who can do all their substitutions in regular Notepad, because they just replace things one word at a time. That doesn't mean they should come into the thread and state that Notepad is a viable replacement for Farlap. It doesn't come close to having the same functionality, and it's less efficient in every respect.




Feb 4 2013, 9:55 pm Wormer Post #25



I haven't read the last post of yours yet, but here is what I can say:

It looks like I'm starting to understand the reason why you need so massive substitutions. Let's say we have binary countoffs:
Trigger("Factions (Suggested 4-8)") {
Conditions:
Deaths("Player 7", "Start Location", Exactly, 0);
Deaths("Current Player", "Zerg Creep Colony", Exactly, 0);
Deaths("Current Player", "Disruption Field", At Most, 1);
Deaths("Player 1", "Independent Starport", At Least, 113);
Deaths("Player 1", "Independent Starport", At Most, 224);
Deaths("Player 4", "Independent Starport", At Least, 2^n);
Actions:
Set Deaths("Player 4", "Independent Starport", Subtract, 2^n);
Set Score("Current Player", Add, 2^n, Custom);
Preserve trigger();
}

Let's say n takes values 16, 8, 4, 2, 1 and I want to add (2^n)*3 to Custom score instead of 2^n. I'm not sure if this is achieveable with regular expressions, but in any way I would really need to search for the whole trigger pattern. In this case Farlap is really ahead of text editors in terms of substitution.

If I had a job to make that substitution, I would have used MacroTriggers and written something like:

FOR n = 4 TO 0 BY -1 DO
TRIGGER
OWNERS: @F("Factions (Suggested 4-8)")
CONDITIONS:
Deaths("Player 7", @Exactly, 0, "Start Location")
Deaths("Current Player", @Exactly, 0, "Zerg Creep Colony")
Deaths("Current Player", @AtMost, 1, "Disruption Field")
Deaths("Player 1", @AtLeast, 113, "Independent Starport")
Deaths("Player 1", @AtMost, 224, "Independent Starport")
Deaths("Player 4", @AtLeast, 2^n, "Independent Starport")
ACTIONS:
SetDeaths("Player 4", "Independent Starport", @Subtract, 2^n)
SetScore(@CurrentPlayer, @Add, (2^n)*3, @Custom)
PreserveTrigger()
ENDT
ENDL

But it's another story.

In conclusion I agree that Farlap is superior to trigger editors when it comes to a specific task of changing series of triggers.



Some.

Feb 4 2013, 10:17 pm Wormer Post #26



But then again, what comes to your first example:
Quote from Azrael
I was having to make a lot of minor replacements to a large body of text, and it was pretty tedious having to do them all consecutively. That's why I quickly used Farlap to reformat my large block of text into regex, and put the entries I want to replace at the top of the text block.


In Vim, I just selected the lines that I need to apply substitution and run 2-3 substitute commands, like:
Code
:'<,'>s/BOMBNUM/P2B2/g

Code
:'<,'>s/UNITNAME/Infested Command Center/g


Your second example:
Quote from Azrael
I copied a chunk of the system that uses both the DC unit and the location that goes with it in each trigger, and had Farlap strip away all the useless information to generate me a neat list of which units go with which death counts.


It is not that easy to do but it looks as follows:
Code
:'<,'>s/Trigger\_.\{-}\%27c"\(.\{-})\)"\_.\{-}\%58c"\(.\{-}\)\_.\{-}}/\2 - \1/


Anyways, it's a problem of reverse triggers engineering. In first place I wasn't using plain SCMD triggers at all.



Some.

Feb 4 2013, 10:44 pm Roy Post #27

An artist's depiction of an Extended Unit Death

Quote from Wormer
This is a cool stuff, and I don't want to sound rude, but you can achieve this with Vim and it's regular expressions.
You're not being rude for stating the truth. This program isn't made to replace Vim, obviously, but Vim has a learning curve that far exceeds this program's.

This program serves the purpose of making find and replace across multiple lines as easy and intuitive to the average user with little to no learning curve required. Regex wasn't even in the original release because the program was never intended to be as powerful as more advanced editors; I just threw it in because someone made a request and it was simple to implement.

If you know Vim, by all means, stick to using that, as it is indeed more powerful in what you can do with it.

(And please do note that the name of this program is all tongue-in-cheek.)

Post has been edited 2 time(s), last time on Feb 4 2013, 10:50 pm by Roy.




Feb 4 2013, 10:48 pm Lanthanide Post #28



vim is only good if you're a hardcore linux geek, or want to become one. Otherwise you could get much more efficient use of your time just using Notepad++.



None.

Feb 20 2013, 2:21 am Roy Post #29

An artist's depiction of an Extended Unit Death

I was talking to Azrael about this and realized it may not be immediately apparent to some people:

C# supports named groups for Regex in the form of (?<name>Matching Text) for matching and ${name} for replacing. Since this program uses the C# implementation of Regex, this feature (and others, such as recursive/Regex look behinds) are all available to use.

Example:

Say you want to replace certain parameters in a Bring statement of SCMDraft text triggers. You can do a find/replace using regex as follows:

Find
Bring\((.*), (.*), (.*), (.*), (\d+)\);
Replace
Bring($1, $2, $3, $4, $5);

However, the replace isn't very readable and is subject to breaking if you add or remove groups to the find statement. To remedy both of these issues, we can name our groups:

Find
Bring\((?<player>.*), (?<unit>.*), (?<location>.*), (?<modifier>.*), (?<qty>\d+)\);
Replace
Bring(${player}, ${unit}, ${location}, ${modifier}, ${qty});

Now it's very easy to read what you'll be replacing, and it won't break if you happen to add more groups, because you're using the group names to find what you've matched (as opposed to using the index number of the group).

If we wanted to replace all Bring statements' unit with Terran Marine, we'd just change the ${unit} variable in our replace to "Terran Marine" and we're good to go:


Side Note


Post has been edited 2 time(s), last time on Jun 28 2015, 12:45 am by Roy. Reason: Fixing dead image links




Jun 16 2013, 11:24 pm Roy Post #30

An artist's depiction of an Extended Unit Death

I decided to revisit this project over the weekend and made a few additions:

1) Saving settings. This was long overdue, of course, and I forget why I didn't do it when it was first suggested. I had looked into different ideas on saving a config file, and then something came up and I never got it finished. Regardless of the excuses I may have had, the latest version of Farlap will remember the checkbox selections you make each time you open and close the program. So if you have an ideal setup, Farlap will remember it!

2) Resizing text boxes. Originally, these were fixed ratios that would scale when you resized the entire window, but I realize that's fairly inconvenient if you have a large input and output but are only replacing a few characters. You can now adjust the heights of the three textbox "rows," as well as the ratio of the find and replace boxes.

3) Save/Load. If you have a find/replace you're working on and want to save it off to a file, you can do so now with the click of a button (and then trudging through Microsoft's file dialog window). You can either save the output as a text file, or you can save a Farlap Text File (.ftxt), which will retain the input, find, and replace information (it doesn't save the output because that can be generated on load). Loading can be from an ftxt file, which will update the input/find/replace boxes, or it can be from a text file (or any file, really, if you would want to do that; don't pick something large or it will hang trying to convert the data to a text string) in which case it will just update the input text.

Happy find/replacing!




Jul 14 2013, 6:28 pm Veta Post #31



This is one of my most used SC utilities, 2nd only to scmdraft. I'll check out the update.



None.

Jul 11 2014, 11:21 pm Roy Post #32

An artist's depiction of an Extended Unit Death

Well, it's the summer of a new year, so you know what that means... another Farlap update!

There's only one change, which is a new feature called "Keep Matches Only." This works specifically if you're using Regex and want to strip out and format parts of a block of text, for presenting or using the data.

Take, for example, grabbing all contacts from an ugly Html document:

With the "Keep Matches Only" option checked, all that HTML and CSS stuff that wasn't captured by the Regex expression is removed from the output, leaving just whatever you matched in your "Find" formatted the way you specify in your "Replace." It's pretty handy for when you need to quickly nab data like this.

The DLDB entry has been updated to this new version. Check it out!




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[09:22 am]
Zycorax -- :wob:
[2024-5-23. : 3:50 pm]
Ultraviolet -- :wob:
[2024-5-23. : 6:26 am]
UndeadStar -- :wob:
[2024-5-22. : 6:10 am]
Riney -- Somethings never change.
[2024-5-22. : 6:10 am]
Riney -- I come back after 4 months. Post wob. Make a crappy post in Null. Hit a 0 in magic boxes.
[2024-5-22. : 6:00 am]
Riney -- :wob:
[2024-5-20. : 3:08 pm]
Sylph-Of-Space -- woah! nice! thank you!
[2024-5-20. : 4:05 am]
O)FaRTy1billion[MM] -- the setting exists, it's just hidden in a weird place
[2024-5-20. : 4:04 am]
O)FaRTy1billion[MM] -- instead change "Microtile Overlay" to "Impassable"
[2024-5-20. : 4:04 am]
O)FaRTy1billion[MM] -- er, wait, idk why i was looking for height
Please log in to shout.


Members Online: jun3hong, terrellfroy