SHARE
TWEET

かっこ自動閉じ

a guest Dec 29th, 2015 10 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var prev2=Document.Text.charAt(Document.Selection.GetActivePos()-2);
  2. var prev=Document.Text.charAt(Document.Selection.GetActivePos()-1);
  3. var c=Document.Text.charAt(Document.Selection.GetActivePos());
  4. switch(prev){
  5. case "[":
  6. if(c!="]"){
  7. Document.Selection.Text="]";
  8. Document.Selection.CharLeft();
  9. }
  10. break;
  11. case "(":
  12. if(c!=")"){
  13. Document.Selection.Text=")";
  14. Document.Selection.CharLeft();
  15. }
  16. break;
  17. case "\"":
  18. if(c!="\""){
  19. Document.Selection.Text="\"";
  20. Document.Selection.CharLeft();
  21. }
  22. break;
  23. case "'":
  24. if(c!="'"){
  25. Document.Selection.Text="'";
  26. Document.Selection.CharLeft();
  27. }
  28. break;
  29. case "{":
  30. if(c!="}"){
  31. Document.Selection.Text="}";
  32. Document.Selection.CharLeft();
  33. }
  34. break;
  35. case "<":
  36. if(c!=">"){
  37. Document.Selection.Text=">";
  38. Document.Selection.CharLeft();
  39. }
  40. break;
  41. case "]":
  42. if(c==="]" && prev2==="["){
  43. Document.selection.DeleteLeft(1);
  44. }
  45. break;
  46. case ")":
  47. if(c===")" && prev2==="("){
  48. Document.selection.DeleteLeft(1);
  49. }
  50. break;
  51. case "}":
  52. if(c==="}" && prev2==="{"){
  53. Document.selection.DeleteLeft(1);
  54. }
  55. break;
  56. case ">":
  57. if(c===">" && prev2==="<"){
  58. Document.selection.DeleteLeft(1);
  59. }
  60. break;
  61. default:
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top