home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.comp.os.windows-11      Steaming pile of horseshit Windows 11      4,852 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 3,091 of 4,852   
   Marian to All   
   Re: Tutorial: Notepad++ shortcuts.xml ma   
   11 Dec 25 09:56:58   
   
   XPost: alt.comp.os.windows-10, alt.comp.microsoft.windows   
   From: marianjones@helpfulpeople.com   
      
   UPDATE:   
      
   Currently every shortcuts.xml mapping is written out as a 6-line block:   
     1700 -> start search   
     1601 -> set search string (funky character)   
     1625 -> clear replace buffer   
     1602 -> set replacement string (ASCII equivalent)   
     1702 -> run replace all   
     1701 -> end   
      
   That's why the file looks so long and repetitive.   
   This started as a convertion of just a couple of funky characters to ASCII.   
   Then it grew over time (years) one by one to include more characters.   
      
   We can't avoid the repetition entirely because Notepad++ macros don't   
   support loops or dictionaries.   
      
   But we can simplify because for Notepad++ macros, we don't actually need   
   the reset/clear/end lines every time.   
      
   The essential trio is:   
       
       
       
   So each mapping shrinks from 6 lines > 3 lines.   
      
   However, if we're open to using a plugin (like PythonScript or LuaScript),   
   we can collapse the whole macro into a dictionary loop such as this:   
    mapping = {   
       "\u2010": "-",  # hyphen   
       "\u2011": "-",  # non-breaking hyphen   
       "\u2013": "-",  # en dash   
       "\u2014": "-",  # em dash   
       "\u2018": "'",  # left single quote   
       "\u2019": "'",  # right single quote   
       "\u201C": '"',  # left double quote   
       "\u201D": '"',  # right double quote   
       "\u2026": "...",# ellipsis   
       "\u2022": "*",  # bullet   
       "\u00A0": " ",  # non-breaking space   
       "\uFEFF": "",   # BOM   
       # ¡K add the rest   
    }   
      
    editor.beginUndoAction()   
    for bad, good in mapping.items():   
       editor.rereplace(bad, good)   
    editor.endUndoAction()   
      
   I'll post the test version of the rewritten macro in the next update.   
   --   
   I go to trouble and time and effort to write my Usenet posts because I'm   
   kind hearted enough to care that everyone gets excellent researched data.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca