Applying QuickFix after I've written a document

Everything related to our flagship word processor.
julius
Posts: 4
Joined: 2010-10-06 00:02:44

Applying QuickFix after I've written a document

Post by julius » 2010-10-06 00:13:34

Hi,
I like the QuickFix funcion and I wonder if it can be applied to a document or a selection after it has been written and not only in real-time when I'm writing a document.

Thanks..

User avatar
Hamid
Posts: 734
Joined: 2007-01-17 03:25:42

Re: Applying QuickFix after I've written a document

Post by Hamid » 2010-10-06 00:48:33

QuickFix works only while you are writing; it is triggered when you press the space bar after a typo or an abbreviation set down in your Glossary files. QuickFix cannot be applied subsequently to a document because the triggering element is then missing.

Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Applying QuickFix after I've written a document

Post by Kino » 2010-10-06 02:46:40

julius wrote:I like the QuickFix funcion and I wonder if it can be applied to a document or a selection after it has been written and not only in real-time when I'm writing a document.
Try this macro. It so-to-say retypes selected texts using insertText command with q option (“apply the user’s QuickFix preferences to the inserted text”). If there is no selection, it creates a copy of the document and works on its whole text (main body and notes). However, it is not practical to run the macro on a large document. It is slow and requires that the target window is always active. In other words, you should not touch your Mac while it is running.

Code: Select all

$doc = Document.active
if $doc == undefined
	exit # no open document
end

$sels = $doc.textSelections
if ! $sels.firstValue.length
	$doc = $doc.copy
	$paraStarts = $doc.text.findAll '^(?=\p{Any})', 'E', '-am'
	$sels = Array.new
	foreach $start in $paraStarts
		$range = $start.text.rangeOfParagraphContentAtIndex $start.location
		$sel = TextSelection.new $start.text, $range
		$sels.appendValue $sel
	end
	if $doc.allNotes.count
		foreach $note in $doc.allNotes
			$sel = TextSelection.new $note.fullText, $note.fullTextContentRange
			$sels.appendValue $sel
		end
	end
end

$null = Cast to String "\x00"
foreach $sel in reversed $sels
	$words = $sel.subtext
	$words.replaceAll '(?<=\s)(?=\S)|(?<=[,.;:!?\'\’"”)])(?=\s)', $null, 'E'
	$words = $words.split $null
	$range = $sel.range
	$range.length = 0
	$doc.setSelection $sel
	$sel.text.deleteInRange $sel.range
	TextSelection.setActiveRange $range
	foreach $word in $words
		$doc.insertText $word, 'q'
	end
end

julius
Posts: 4
Joined: 2010-10-06 00:02:44

Re: Applying QuickFix after I've written a document

Post by julius » 2010-10-07 04:02:04

Hi,
Thanks both for the answers.
What I really want is to correct text that doesn't start paragraphs with uppercase caracter.
Microsoft Word has this function (change case / sentence case) and I can apply it to the text selected.
If the text in the selecion start a paragraph with a lowercase caracter the command change ìt to uppercase.

User avatar
rmark
Official Nisus Person
Posts: 428
Joined: 2003-02-11 10:49:05
Location: Solana Beach, CA
Contact:

Re: Applying QuickFix after I've written a document

Post by rmark » 2010-10-07 16:39:34

I'm sorry you experience difficulties with Nisus Writer Pro.

You could try this two-line macro:

Code: Select all

Find All '^.', 'Ea'
To capitalized
Write On!
Mark Hurvitz
Nisus Software Inc.

julius
Posts: 4
Joined: 2010-10-06 00:02:44

Re: Applying QuickFix after I've written a document

Post by julius » 2010-10-08 00:27:43

Hi,
thanks for the macro, I tested it but it gives me an error.

Groucho
Posts: 496
Joined: 2007-03-03 09:55:06
Location: Europe

Re: Applying QuickFix after I've written a document

Post by Groucho » 2010-10-08 00:44:25

You can also use Find and Replace with PowerFind Pro and the following settings:

Find what: ^.
Replace with: \T{uppercase:\0}

If you prefer a macro, click on the gear and select Macroize…

Cheers, Henry.

julius
Posts: 4
Joined: 2010-10-06 00:02:44

Re: Applying QuickFix after I've written a document

Post by julius » 2010-10-08 09:25:36

Hi,
it works like a charm.
Thanks..

User avatar
appledogx
Posts: 7
Joined: 2013-12-31 07:29:10
Location: Mexico

Re: Applying QuickFix after I've written a document

Post by appledogx » 2014-01-10 17:13:48

I'm very surprised that this feature is not standard in Nisus Writer Pro. It seems like it should be a very basic menu item for an advanced word processor. I had to revert to LibreOffice to change some text I was working with.

I tried the ^. to \T{uppercase:\0} PowerFind Pro and it doesn't seem to work for me. Does it require regex? All I seem to get is the first letter of the sentence highlighted, but no changes to my text.

User avatar
martin
Official Nisus Person
Posts: 4361
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Applying QuickFix after I've written a document

Post by martin » 2014-01-10 17:44:32

appledogx wrote:I tried the ^. to \T{uppercase:\0} PowerFind Pro and it doesn't seem to work for me. Does it require regex? All I seem to get is the first letter of the sentence highlighted, but no changes to my text.
Those find patterns are indeed PowerFind Pro (regex) expressions. Your find dialog should look like this:
find.png
find.png (33.81 KiB) Viewed 5280 times
You'd then click the "Replace All" button. Please let us know if you continue to have trouble.

User avatar
appledogx
Posts: 7
Joined: 2013-12-31 07:29:10
Location: Mexico

Re: Applying QuickFix after I've written a document

Post by appledogx » 2014-01-10 20:31:36

I'm fairly new and not quite getting this for some reason. I have just what you posted, but this is what I get, and what I'm trying to get:
Attachments
Sentence Case.jpg
Sentence Case.jpg (62.14 KiB) Viewed 5274 times

User avatar
phspaelti
Posts: 943
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Applying QuickFix after I've written a document

Post by phspaelti » 2014-01-10 20:39:17

What kinds of changes were you expecting to see?

The expression that Martin described is "doing" exactly what it says: It is capitalising, perhaps redundantly, the first letter of every paragraph. The highlighted letters are the ones targeted. And as you can see they are all capitalised. Of course they were probably already capitalised, but so what?

So what result are you looking for?

Anyhow for what it's worth, here is an attempt at a find expression (macroized) that will do sentence capitalisation in the current selection.
Sentence Capitalize Selection.nwm
(18.36 KiB) Downloaded 138 times
philip

exegete77
Posts: 184
Joined: 2007-09-20 17:58:56

Re: Applying QuickFix after I've written a document

Post by exegete77 » 2014-01-10 22:17:58

Just a thought, perhaps the file needs to be named and saved. I have found other features that don’t seem to stick if the document is not named.
iMac 21.5” / MBP 13” Retina
Mac user since 1990

User avatar
phspaelti
Posts: 943
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Applying QuickFix after I've written a document

Post by phspaelti » 2014-01-10 22:25:24

exegete77 wrote:Just a thought, perhaps the file needs to be named and saved. I have found other features that don’t seem to stick if the document is not named.
This is not relevant. The find/replace is working fine as appledogx's image shows.
It seems he was expecting the first sentence(s) of his file (all in upper case) would be converted to lowercase, and then sentence capitalisation applied. For that result, it will be necessary to do the following steps:
  1. Select the relevant text
  2. Choose Edit > Convert > To lowercase
  3. Use a find expression (or the macro I supplied earlier) to capitalise the sentence initial letters.
philip

User avatar
appledogx
Posts: 7
Joined: 2013-12-31 07:29:10
Location: Mexico

Re: Applying QuickFix after I've written a document

Post by appledogx » 2014-01-11 06:20:38

Well, using this macro you've provided (thank you), I've been able to modify it and get closer... The problem I now have is that if I select after the text, I cannot seem to type any uppercase letters and I'm not quite sure how to cure this.
Attachments
Sentence Case.nwm
(17.53 KiB) Downloaded 127 times

Post Reply