Advertisement
Guest User

scite_rev3908.patch

a guest
Aug 19th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # HG changeset patch
  2. # User Jerome LAFORGE <jerome.laforge@gmail.com>
  3. # Date 1345410282 -7200
  4. # Node ID 8a98250736513f3dbf5e16713bf4e3e58cc178d4
  5. # Parent  c0540f310854a758c3fb57e8aa4a76c586e00f15
  6. Override global strip.trailing.spaces with strip.trailing.spaces by extension.
  7. Feature #3556320.
  8.  
  9. diff -r c0540f310854 -r 8a9825073651 src/SciTEBase.h
  10. --- a/src/SciTEBase.h   mer. août 08 23:38:24 2012 +1000
  11. +++ b/src/SciTEBase.h   dim. août 19 23:04:42 2012 +0200
  12. @@ -106,6 +106,7 @@
  13.     std::vector<int> bookmarks;
  14.     FileWorker *pFileWorker;
  15.     PropSetFile props;
  16. +   std::map<std::string, int>stripTrailingSpacesByExtension;
  17.     enum FutureDo { fdNone=0, fdFinishSave=1 } futureDo;
  18.     Buffer() :
  19.             RecentFile(), doc(0), isDirty(false), isReadOnly(false), useMonoFont(false), lifeState(empty),
  20. diff -r c0540f310854 -r 8a9825073651 src/SciTEIO.cxx
  21. --- a/src/SciTEIO.cxx   mer. août 08 23:38:24 2012 +1000
  22. +++ b/src/SciTEIO.cxx   dim. août 19 23:04:42 2012 +0200
  23. @@ -921,7 +921,11 @@
  24.     bool retVal = false;
  25.     // Perform clean ups on text before saving
  26.     wEditor.Call(SCI_BEGINUNDOACTION);
  27. -   if (props.GetInt("strip.trailing.spaces"))
  28. +   std::map<std::string, int>::iterator it = CurrentBuffer()->stripTrailingSpacesByExtension.find(saveName.Extension().AsUTF8().c_str());
  29. +   if (it != CurrentBuffer()->stripTrailingSpacesByExtension.end()) {
  30. +       if (it->second)
  31. +           StripTrailingSpaces();
  32. +   } else if (props.GetInt("strip.trailing.spaces"))
  33.         StripTrailingSpaces();
  34.     if (props.GetInt("ensure.final.line.end"))
  35.         EnsureFinalNewLine();
  36. diff -r c0540f310854 -r 8a9825073651 src/SciTEProps.cxx
  37. --- a/src/SciTEProps.cxx    mer. août 08 23:38:24 2012 +1000
  38. +++ b/src/SciTEProps.cxx    dim. août 19 23:04:42 2012 +0200
  39. @@ -1348,6 +1348,32 @@
  40.         HighlightCurrentWord(true);
  41.     }
  42.  
  43. +   SString stringTrailingSpacePrefix = "strip.trailing.spaces.";
  44. +   CurrentBuffer()->stripTrailingSpacesByExtension.clear();
  45. +   const char *currentKey;
  46. +   const char *currentValue;
  47. +   PropSetFile *currentProp = &CurrentBuffer()->props;
  48. +   do {
  49. +       bool b = currentProp->GetFirst(currentKey, currentValue);
  50. +       while (b) {
  51. +           if (0 == strncmp(stringTrailingSpacePrefix.c_str(), currentKey, stringTrailingSpacePrefix.length())) {
  52. +               SString tmp(currentProp->Expand(currentKey).substr(stringTrailingSpacePrefix.length()));
  53. +               tmp.remove("*.");
  54. +               tmp.substitute(';', '\0');
  55. +               int length = tmp.length();
  56. +               const char *extension = tmp.c_str();
  57. +               while (length > 0) {
  58. +                   if (CurrentBuffer()->stripTrailingSpacesByExtension.find(extension) == CurrentBuffer()->stripTrailingSpacesByExtension.end())
  59. +                       CurrentBuffer()->stripTrailingSpacesByExtension[extension] = atoi(currentValue);
  60. +                   length -= strlen(extension) + 1;
  61. +                   extension += strlen(extension) + 1;
  62. +               }
  63. +           }
  64. +           b = currentProp->GetNext(currentKey, currentValue);
  65. +       }
  66. +       currentProp = currentProp->superPS;
  67. +   } while (currentProp != NULL);
  68. +
  69.     if (extender) {
  70.         FilePath defaultDir = GetDefaultDirectory();
  71.         FilePath scriptPath;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement