Reply to topic  [ 23 posts ]  Go to page 1, 2  Next
Applying QuickFix after I've written a document 
Author Message

Joined: 2010-10-06 00:02:44
Posts: 4
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..


2010-10-06 00:13:34
Profile
User avatar

Joined: 2007-01-17 03:25:42
Posts: 729
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.


2010-10-06 00:48:33
Profile

Joined: 2008-05-17 04:02:32
Posts: 400
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


2010-10-06 02:46:40
Profile

Joined: 2010-10-06 00:02:44
Posts: 4
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.


2010-10-07 04:02:04
Profile
Official Nisus Person
User avatar

Joined: 2003-02-11 10:49:05
Posts: 428
Location: Solana Beach, CA
I'm sorry you experience difficulties with Nisus Writer Pro.

You could try this two-line macro:

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

_________________
Write On!
Mark Hurvitz
Nisus Software Inc.


2010-10-07 16:39:34
Profile ICQ

Joined: 2010-10-06 00:02:44
Posts: 4
Hi,
thanks for the macro, I tested it but it gives me an error.


2010-10-08 00:27:43
Profile

Joined: 2007-03-03 09:55:06
Posts: 494
Location: Europe
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.


2010-10-08 00:44:25
Profile

Joined: 2010-10-06 00:02:44
Posts: 4
Hi,
it works like a charm.
Thanks..


2010-10-08 09:25:36
Profile
User avatar

Joined: 2013-12-31 07:29:10
Posts: 7
Location: Mexico
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.


2014-01-10 17:13:48
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
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 4276 times ]
You'd then click the "Replace All" button. Please let us know if you continue to have trouble.


2014-01-10 17:44:32
Profile WWW
User avatar

Joined: 2013-12-31 07:29:10
Posts: 7
Location: Mexico
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 4270 times ]
2014-01-10 20:31:36
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
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

_________________
philip


2014-01-10 20:39:17
Profile

Joined: 2007-09-20 17:58:56
Posts: 179
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


2014-01-10 22:17:58
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
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


2014-01-10 22:25:24
Profile
User avatar

Joined: 2013-12-31 07:29:10
Posts: 7
Location: Mexico
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
2014-01-11 06:20:38
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 23 posts ]  Go to page 1, 2  Next

Who is online

Users browsing this forum: Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software