Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
3.3 KiB

  1. /*
  2. * @doc INTERNAL
  3. *
  4. * @module _URLSUP.H URL detection support |
  5. *
  6. * Author: alexgo (4/1/96)
  7. *
  8. * Copyright (c) 1995-1997, Microsoft Corporation. All rights reserved.
  9. */
  10. #ifndef _URLSUP_H_
  11. #define _URLSUP_H_
  12. #include "_dfreeze.h"
  13. #include "_notmgr.h"
  14. #include "_range.h"
  15. class CTxtEdit;
  16. class IUndoBuilder;
  17. // Maximum URL length. It's a good thing to have a protection like
  18. // this to make sure we don't select the whole document; and we really
  19. // need this for space-containing URLs
  20. #define URL_MAX_SIZE 512
  21. #define URL_MAX_SCOPE 512
  22. // for MoveByDelimiter
  23. #define URL_EATWHITESPACE 32
  24. #define URL_STOPATWHITESPACE 1
  25. #define URL_EATNONWHITESPACE 0
  26. #define URL_STOPATNONWHITESPACE 2
  27. #define URL_EATPUNCT 0
  28. #define URL_STOPATPUNCT 4
  29. #define URL_EATNONPUNCT 0
  30. #define URL_STOPATNONPUNCT 8
  31. #define URL_STOPATCHAR 16
  32. // need this one to initialize a scan with something invalid
  33. #define URL_INVALID_DELIMITER TEXT(' ')
  34. #define LEFTANGLEBRACKET TEXT('<')
  35. #define RIGHTANGLEBRACKET TEXT('>')
  36. /*
  37. * CDetectURL
  38. *
  39. * @class This class will watched edit changes and automatically
  40. * change detected URL's into links (see CFE_LINK && EN_LINK)
  41. */
  42. class CDetectURL : public ITxNotify
  43. {
  44. //@access Public Methods
  45. public:
  46. // constructor/destructor
  47. CDetectURL(CTxtEdit *ped); //@cmember constructor
  48. ~CDetectURL(); //@cmember destructor
  49. // ITxNotify methods
  50. //@cmember called before a change
  51. virtual void OnPreReplaceRange( LONG cp, LONG cchDel, LONG cchNew,
  52. LONG cpFormatMin, LONG cpFormatMax);
  53. //@cmember called after a change
  54. virtual void OnPostReplaceRange( LONG cp, LONG cchDel, LONG cchNew,
  55. LONG cpFormatMin, LONG cpFormatMax);
  56. virtual void Zombie(); //@cmember turn into a zombie
  57. // useful methods
  58. void ScanAndUpdate(IUndoBuilder *publdr);//@cmember scan the changed
  59. // area and update the link status
  60. //@access Private Methods and Data
  61. private:
  62. // worker routines for ScanAndUpdate
  63. BOOL GetScanRegion(LONG& rcpStart, LONG& rcpEnd);//@cmember get the region
  64. // to check and clear the accumltr
  65. void ExpandToURL(CTxtRange& rg, LONG &cchAdvance);
  66. //@cmember expand the range to
  67. // the next URL candidate
  68. BOOL IsURL(CTxtRange& rg); //@cmember returns TRUE if the text
  69. // is a URL.
  70. void SetURLEffects(CTxtRange& rg, IUndoBuilder *publdr); //@cmember Set
  71. // the desired URL effects
  72. //@cmember removes URL effects if
  73. // appropriate
  74. void CheckAndCleanBogusURL(CTxtRange& rg, BOOL &fDidClean, IUndoBuilder *publdr);
  75. //@cmember scan along for white
  76. // space / not whitespace,
  77. // punctuation / non punctuation
  78. // and remember what stopped the scan
  79. LONG MoveByDelimiters(const CTxtPtr& tp, LONG iDir, DWORD grfDelimiters,
  80. WCHAR *pchStopChar);
  81. LONG GetAngleBracket(CTxtPtr &tp, LONG cch = 0);
  82. WCHAR BraceMatch(WCHAR chEnclosing);
  83. CTxtEdit * _ped; //@cmember the edit context
  84. CAccumDisplayChanges _adc; //@cmember change accumulator
  85. // FUTURE (alexgo): we may want to add more options to detection,
  86. // such as the charformat to use on detection, etc.
  87. };
  88. #endif // _URLSUP_H_