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.

103 lines
4.7 KiB

8 months ago
  1. <!doctype html>
  2. <title>CodeMirror: Match Highlighter Demo</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../doc/docs.css">
  5. <link rel="stylesheet" href="../lib/codemirror.css">
  6. <script src="../lib/codemirror.js"></script>
  7. <script src="../addon/scroll/annotatescrollbar.js"></script>
  8. <script src="../addon/search/matchesonscrollbar.js"></script>
  9. <script src="../addon/search/searchcursor.js"></script>
  10. <script src="../addon/search/match-highlighter.js"></script>
  11. <style>
  12. .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
  13. .CodeMirror-focused .cm-matchhighlight {
  14. background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFklEQVQI12NgYGBgkKzc8x9CMDAwAAAmhwSbidEoSQAAAABJRU5ErkJggg==);
  15. background-position: bottom;
  16. background-repeat: repeat-x;
  17. }
  18. .cm-matchhighlight {background-color: lightgreen}
  19. .CodeMirror-selection-highlight-scrollbar {background-color: green}
  20. </style>
  21. <div id=nav>
  22. <a href="https://codemirror.net/5"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
  23. <ul>
  24. <li><a href="../index.html">Home</a>
  25. <li><a href="../doc/manual.html">Manual</a>
  26. <li><a href="https://github.com/codemirror/codemirror5">Code</a>
  27. </ul>
  28. <ul>
  29. <li><a class=active href="#">Match Highlighter</a>
  30. </ul>
  31. </div>
  32. <article>
  33. <h2>Match Highlighter Demo</h2>
  34. <form><textarea id="code" name="code">Select this text: hardtospot
  35. And everywhere else in your code where hardtospot appears will
  36. automatically illuminate. Give it a try! No more hard to spot
  37. variables - stay in context of your code all the time.
  38. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut pharetra
  39. interdum dui eu pulvinar. Mauris maximus ligula venenatis tempus
  40. interdum. Cras hendrerit, ipsum sed ultrices pharetra, ligula diam
  41. porttitor lacus, ac tempor eros est a massa. Nam orci elit, vulputate
  42. in tristique quis, consectetur vitae metus. Pellentesque et enim
  43. elementum, lobortis augue in, lacinia sapien. Morbi eu nunc semper,
  44. sagittis felis a, pellentesque mauris. Lorem ipsum dolor sit amet,
  45. consectetur adipiscing elit. Aenean quis diam turpis.
  46. Fusce lobortis nisl quis aliquet euismod. Aenean vitae nulla non ipsum
  47. efficitur scelerisque. Curabitur auctor, lorem non rhoncus porttitor,
  48. augue ligula lacinia dolor, et vehicula magna lorem imperdiet velit.
  49. Fusce risus sem, hardtospot commodo eleifend hendrerit vitae, mollis
  50. quis risus. Cras tincidunt, justo vitae hendrerit venenatis, urna
  51. dolor placerat tortor, eu lobortis lectus dolor in ligula. Nullam non
  52. erat non nisl vulputate ultrices sit amet vestibulum dolor. Quisque in
  53. tortor porta, pellentesque odio nec, malesuada nibh.
  54. In a dui feugiat, ullamcorper urna in, accumsan magna. Donec egestas
  55. sem nec eros rhoncus, vel gravida purus ornare. Nulla orci mauris,
  56. porta nec pharetra sed, ornare et lorem. Donec luctus turpis nunc,
  57. eget dictum felis mollis et. Sed sodales hardtospot nunc vitae leo
  58. rhoncus imperdiet. Donec elementum malesuada velit quis placerat.
  59. Proin accumsan lorem id nisi volutpat ullamcorper. Vivamus laoreet
  60. dolor ac sem malesuada, ac scelerisque ex efficitur. Aliquam tempus
  61. libero velit, vel tristique augue vulputate nec.
  62. Mauris ultrices leo felis, sit amet congue augue aliquam condimentum.
  63. Vivamus purus leo, mattis vitae dignissim vel, ultricies ac ex. Mauris
  64. eu dolor eu purus ultricies ultrices. Sed euismod feugiat ex et
  65. mattis. Morbi cursus laoreet pharetra. Donec eu dolor sodales,
  66. ultricies nisi et, malesuada urna. Praesent sit amet fringilla felis.
  67. Nam rhoncus, est blandit auctor auctor, lorem ipsum laoreet ipsum,
  68. quis sodales libero odio in lorem. Phasellus odio dolor, elementum
  69. sagittis nibh non, fermentum semper libero. Mauris hendrerit
  70. hardtospot lectus sit amet commodo eleifend. Morbi pulvinar eget nisl
  71. at eleifend. Fusce eget porta erat, vitae lobortis libero.
  72. Phasellus sit amet massa in massa pharetra malesuada. Vestibulum at
  73. quam vel libero aliquam volutpat at ut dui. Praesent scelerisque vel
  74. mauris sit amet vehicula. Phasellus at mi nec ligula cursus interdum
  75. sit amet non quam. Aliquam tempus sollicitudin euismod. Nulla euismod
  76. mollis enim tincidunt placerat. Proin ac scelerisque enim, quis
  77. sollicitudin metus. Pellentesque congue nec sapien ut rhoncus. Sed
  78. eget ornare diam, ut consectetur ante. Aenean eleifend mauris quis
  79. ornare accumsan. In hac habitasse hardtospot platea dictumst.
  80. </textarea></form>
  81. <script>
  82. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  83. lineNumbers: true,
  84. // To highlight on scrollbars as well, pass annotateScrollbar in options
  85. // as below.
  86. highlightSelectionMatches: {showToken: /\w/, annotateScrollbar: true}
  87. });
  88. </script>
  89. <p>Search and highlight occurrences of the selected text.</p>
  90. </article>