03-24-2022, 04:16 PM | #76 |
Sigil Developer
Posts: 7,772
Karma: 5446592
Join Date: Nov 2009
Device: many
|
We pass a single QStringList that effectively contains the values of match.group(0), match.group(1), ... created from our C++ match info object through the embedded python bridge code , to the replace function in mymod.py, and its returns a single string replacement value back via the bridge code.
We could pass along a counter, or an structure (tuple - think a list of QVariants) for memory storage as well. It should work. Just one more embedded python routine. It will be be a bit quick and dirty, and more limited in scope, but we have plugins to handle the fancy stuff. Or we take advantage of the embedded python routines to return a Replacer object and invoke its routines so that object can have cross call storage until the we delete it. We used that approach for the pre Sigil 1.9 Opf parsing routine before it was rewritten in C++. Or even just pass in a an QString that could hold serialized json for whatever storage they needed. And return a QString pair (replacement value and storage). Last edited by KevinH; 03-24-2022 at 05:10 PM. |
03-24-2022, 04:29 PM | #77 |
Sigil Developer
Posts: 7,772
Karma: 5446592
Join Date: Nov 2009
Device: many
|
I checked out how we internally handle ReplaceAll in Misc/SearchOperations.cpp and for each file we handle the replacements in reverse order so that all match objects are calculated just once. That means using python replacement functions would need changes if we wanted to use them for renumbering things as that would require a new routine that works in spine order from top to bottom in each file, unlike our current C++ approach which is done for better efficiency and speed.
I still think renumbering is better done by Doitsu's excellent plugin anyway. Last edited by KevinH; 03-24-2022 at 05:11 PM. Reason: specify a good renumbering plugin! |
Advert | |
|
03-24-2022, 04:50 PM | #78 |
Grand Sorcerer
Posts: 5,615
Karma: 23187563
Join Date: Dec 2010
Device: Kindle PW2
|
As I've already mentioned in this thread, I'm sure that my AddIDs plugin should cover most renumbering use cases and if I've missed one, I could easily add it.
@Turtle91 would you need full renumbering support in regex functions, or are you already using my AddIDs plugin or other tools for this? |
03-24-2022, 05:05 PM | #79 | |
Sigil Developer
Posts: 7,772
Karma: 5446592
Join Date: Nov 2009
Device: many
|
Yes, I agree. I edited my post to indicate that.
Quote:
|
|
03-24-2022, 06:46 PM | #80 |
Sigil Developer
Posts: 7,772
Karma: 5446592
Join Date: Nov 2009
Device: many
|
The more I think about it, even storage may not be useful since search order is not guaranteed. Saving something across calls is needed for counting/skipping, etc but reverse order would break that. Something to think about.
In addition, one off replaces make storage irrelevant. So providing storage would make sense just for Replace All type situations. Last edited by KevinH; 03-24-2022 at 06:58 PM. |
Advert | |
|
03-24-2022, 10:13 PM | #81 | |
A Hairy Wizard
Posts: 3,121
Karma: 18727091
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Quote:
I haven't looked at the possibilities of regex functions, other than its only limited by the programming talents of the user. I really liked the ability to use it to create Title Case, which Calibre used in their How To, but honestly didn't look into it further....life got in the way. |
|
03-25-2022, 04:45 PM | #82 |
Evangelist
Posts: 425
Karma: 77256
Join Date: Sep 2011
Device: none
|
Perhaps one aspect to explain how I think of what Sigil could be is that coming from some experience of using shells and doing some amount of programming, as well as other things such as being used to automation on macOS as well as some familiarity with Vim and Emacs, is that I am used to being able to use the keyboard for nearly everything and avoiding having to use the mouse most of the time.
I understand most creating EPUBs may not seek such but then again much of EPUB creation is in some sense coding. Such is some of the consideration when I mention thing I would like. I am used to such efficiency yet many others may not be. Perhaps someday but I understand the goals may never align as such. |
03-25-2022, 04:56 PM | #83 |
Sigil Developer
Posts: 7,772
Karma: 5446592
Join Date: Nov 2009
Device: many
|
The point we are trying to make is to then use "open with" with emacs or whatever editor does things the way you want.
Using the keyboard predominantly is fine (BetterRed does that) but having different widgets fighting for focus is not. And there are some things that a mouse or mouse pad are better at including selecting specific but widely separated files in BookBrowser. If you can program, then modify your own copy of Sigil to do what you want. BeckyEbook does that and adds menus and features she needs or wants. Our goal is to make Sigil work like most users want (myself included) who do not want to memorize more than a handful of useful key sequences and rely on the menus and toolbar icons for all others. Last edited by KevinH; 03-25-2022 at 04:58 PM. |
03-28-2022, 11:14 AM | #84 |
Sigil Developer
Posts: 7,772
Karma: 5446592
Join Date: Nov 2009
Device: many
|
Show Dry-Run for any Replace or Replace All
Would anyone here find the following new feature for Sigil useful:
Add a "dry-run" mode for Find and Replace that would show the before and after results from a Regex Replace/Replace-All in a big table but not actually make any changes at all (or possibly wait until user says okay?). Maybe a simple Ctrl-Click on the Replace button to do the dry-run. Imagine a table with two columns, the first showing a short context (3 to 5 words on each side of a match) for each match, and the second column showing the same short context with the replacement made. But no actual replacements are done ( or until the user okays it). The number of words of context could be a user preference. Effectively this would be a faster easier way of making a Checkpoint, doing the ReplaceAll, and comparing using File level highlighted diffs, and deciding whether to keep or revert to the Checkpoint all without Checkpointing at all. Would this be a generally useful addition? |
03-28-2022, 11:47 AM | #85 |
Grand Sorcerer
Posts: 5,615
Karma: 23187563
Join Date: Dec 2010
Device: Kindle PW2
|
IMHO, that would be a great addition. So far, I have been using a private regex tester plugin that shows all regex matches in the validation window, but a built-in option would be much better.
|
03-28-2022, 12:09 PM | #86 |
A Hairy Wizard
Posts: 3,121
Karma: 18727091
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Yes...that would be awesome.
I currently use "Count All" to see if I'm in the ballpark, then replace individual ones a couple times to make sure it's doing it properly, then replace/find until I get tired of it, then replace all - after saving, of course. Seeing everything in a table that I could quick scan, especially with an "accept changes" button would be the bee's knees! |
03-28-2022, 12:54 PM | #87 | |
Guru
Posts: 705
Karma: 2180740
Join Date: Jan 2017
Location: Poland
Device: Misc
|
Quote:
It is especially useful when a given replacement is not unambiguous and depends on a contest. I don't like to mindlessly click "Replace All", so this dry-run preview could become my favorite tool. I use a similar solution every day, but in a simplified form – through a plugin, but at least I can preview the results in the "Validation Results" window. |
|
03-28-2022, 01:29 PM | #88 |
just an egg
Posts: 1,604
Karma: 4798866
Join Date: Mar 2015
Device: Kindle, iOS
|
I like this idea a lot!
I currently do the same as Turtle91: A dry-run table would be awesome! |
03-28-2022, 01:30 PM | #89 |
Addict
Posts: 311
Karma: 3196258
Join Date: Oct 2015
Location: Madison, WI
Device: Kindle 5th Gen
|
I would also find that really useful.
|
03-28-2022, 02:02 PM | #90 |
Sigil Developer
Posts: 7,772
Karma: 5446592
Join Date: Nov 2009
Device: many
|
Okay, it appears to be quite popular. I will start looking at how to actually accomplish that.
Thanks to everyone that provided their feedback. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Possible To-Do List for Future Sigil Releases Post Sigil 1.8 | KevinH | Sigil | 143 | 02-05-2022 12:08 PM |
Icon Redesign for future 1.0 Release of Sigil | shorshe | Sigil | 38 | 06-06-2016 11:29 PM |
Sigil on Nook vs Sigil on Kobo vs Sigil on iBook | rosshalde | Sigil | 12 | 11-13-2014 09:34 AM |
Sigil’s Future Direction (Post 0.4.x) | user_none | Sigil | 90 | 10-11-2011 03:28 PM |
Sigil's Future | crutledge | Sigil | 36 | 07-26-2011 06:02 PM |