nisus.com
https://www.nisus.com/forum/

Applying QuickFix after I've written a document
https://www.nisus.com/forum/viewtopic.php?f=18&t=3940
Page 1 of 2

Author:  julius [ 2010-10-06 00:13:34 ]
Post subject:  Applying QuickFix after I've written a document

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..

Author:  Hamid [ 2010-10-06 00:48:33 ]
Post subject:  Re: Applying QuickFix after I've written a document

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.

Author:  Kino [ 2010-10-06 02:46:40 ]
Post subject:  Re: Applying QuickFix after I've written a document

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:
$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

Author:  julius [ 2010-10-07 04:02:04 ]
Post subject:  Re: Applying QuickFix after I've written a document

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.

Author:  rmark [ 2010-10-07 16:39:34 ]
Post subject:  Re: Applying QuickFix after I've written a document

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

You could try this two-line macro:

Code:
Find All '^.', 'Ea'
To capitalized

Author:  julius [ 2010-10-08 00:27:43 ]
Post subject:  Re: Applying QuickFix after I've written a document

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

Author:  Groucho [ 2010-10-08 00:44:25 ]
Post subject:  Re: Applying QuickFix after I've written a document

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.

Author:  julius [ 2010-10-08 09:25:36 ]
Post subject:  Re: Applying QuickFix after I've written a document

Hi,
it works like a charm.
Thanks..

Author:  appledogx [ 2014-01-10 17:13:48 ]
Post subject:  Re: Applying QuickFix after I've written a document

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.

Author:  martin [ 2014-01-10 17:44:32 ]
Post subject:  Re: Applying QuickFix after I've written a document

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:
Attachment:
find.png
find.png [ 33.81 KiB | Viewed 4262 times ]
You'd then click the "Replace All" button. Please let us know if you continue to have trouble.

Author:  appledogx [ 2014-01-10 20:31:36 ]
Post subject:  Re: Applying QuickFix after I've written a document

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 4256 times ]

Author:  phspaelti [ 2014-01-10 20:39:17 ]
Post subject:  Re: Applying QuickFix after I've written a document

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.
Attachment:
Sentence Capitalize Selection.nwm [18.36 KiB]
Downloaded 122 times

Author:  exegete77 [ 2014-01-10 22:17:58 ]
Post subject:  Re: Applying QuickFix after I've written a document

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.

Author:  phspaelti [ 2014-01-10 22:25:24 ]
Post subject:  Re: Applying QuickFix after I've written a document

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.

Author:  appledogx [ 2014-01-11 06:20:38 ]
Post subject:  Re: Applying QuickFix after I've written a document

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 110 times

Page 1 of 2 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/