home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / enh_e130.zip / Sample.plg < prev    next >
Text File  |  1999-12-09  |  4KB  |  87 lines

  1. /* Sample Plugin for the Enhanced E Editor */
  2.  
  3. /*==============================================================
  4. From these plugin files there will be many VisPro/Rexx commands
  5. that you can use to manipulate text etc in the editor. They must
  6. be written just like a rexx cmd file which is, in all actuality,
  7. what they are. :-)
  8.  
  9. There are two variables that are important for you to use in these
  10. commands in order to communicate with the editor. "window" is a
  11. variable that is used as the editors name in your code and
  12. "Target" is the name of the editor's text window.
  13.  
  14. The code template tool using "Rexx.ext" will help with many of the
  15. commands you can use and we will try to make a set of VisPro commands
  16. available too. Here are a few of the basic ones that are available
  17. to you.
  18.  
  19. /* Get first character position Target Multi-Line Entry Field */
  20. FirstChar=VpItem(window,Target,'SENDMSG','0x01d6')
  21.  
  22. /* Get selection range Target Multi-Line Entry Field */
  23. PARSE VALUE VpGetIndex(window,Target) with First Last
  24.  
  25. /* Get text in range Target Multi-Line Entry Field */
  26. /* needs the previous call to get the "First" & "Last" variables */
  27. SelectedText = VpGetItemValue(window,Target,First,Last)
  28.  
  29. /* Get all text in Target Multi-Line Entry Field */
  30. Document = VpGetItemValue(window,Target)
  31.  
  32. /* Select a range the Target Multi-Line Entry Field */
  33. CALL VpSelect window,Target,First,Last
  34.  
  35. /* Add item at current location Target Multi-Line Entry Field */
  36. CALL VpAddItem window, Target, 'CURRENT', value
  37.  
  38. /* Put up a message box */
  39. response=VpMessageBox(window,'Your TitleBarText','Your message here')
  40.  
  41. Look over the supplied examples to see how to use some of these.
  42. You can cut and paste these commands to help you build your own
  43. plugins. When you are finished you can delete this whole commented
  44. area. The example plugin below will lowercase selected text.
  45. ===============================================================*/
  46.  
  47.                 /* Get the range of the selected text                 */
  48. Parse Value VpGetIndex(window,Target) with First Last
  49.  
  50.                 /* Now read the text from "First" to "Last"           */
  51. SelectedText = VpGetItemValue(window,Target,First,Last)
  52.  
  53.                 /* Use the rexx "translate" command to lowercase      */
  54.                 /* the variable "SelectedText"                        */
  55. SelectedText=translate(SelectedText,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')
  56.  
  57.                 /* Now highlight the text from "First" to "Last"      */
  58.                 /* again just in case someone has unhighlighted       */
  59.                 /* it while we were away                              */
  60. Call VpSelect window,Target,First,Last
  61.  
  62.                 /* Adding our variable "SelectedText" to the current  */
  63.                 /* location will replace the selected text with the   */
  64.                 /* "translate"d text                                  */
  65. Call VpAddItem window, Target, 'CURRENT', SelectedText
  66.  
  67.                 /* You won't really want to do the following probably */
  68.                 /* but it's just another example of what you can do.  */
  69.  
  70.                 /* Set the titlebar text variable                     */
  71. Title="Bob's LowerCase for Selected Text Utility v6.81"
  72.  
  73.                 /* Set the message text variables (msg1 msg2 msg3)    */
  74.                 /* '0d0a'x is hex for a carraige return/line feed     */
  75. msg1="Thanks for using Bob's LowerCase for Selected Text Utility v6.81"||'0d0a0d0a'x
  76. msg2='Be sure to try my Uppercase and Shotgun Case Utilities which are now in version 7.01 and 12 gauge'
  77. msg3=' respectively at a store near you...'||'0d0a0d0a'x||'Utterly and Sincerely,'||'0d0a'x||'Bob' '0d0a'x
  78.  
  79.                 /* Open the messagebox with the three msg's           */
  80.                 /* concatenated together with "||"                    */
  81. response=VpMessageBox(window,Title,msg1||msg2||msg3)
  82.  
  83.                 /* Do another one for the fun of it                   */
  84. msg1='BTW: I pretty much had the LowerCasing working since version 1. Since then I have been'
  85. msg2=' working on these advertising windows.'||'0d0a0d0a'x||'Thanks,'||'0d0a'x||'Bob'
  86. response=vpmessagebox(window,title,msg1||msg2)
  87.