TextCutBuf1.src 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. XCOMM! CDE_INSTALLATION_TOP/bin/dtksh
  2. XCOMM $XConsortium: TextCutBuf1.src /main/3 1996/04/23 20:18:52 drk $
  3. XCOMM #########################################################################
  4. XCOMM (c) Copyright 1993, 1994 Hewlett-Packard Company
  5. XCOMM (c) Copyright 1993, 1994 International Business Machines Corp.
  6. XCOMM (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  7. XCOMM (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
  8. XCOMM Novell, Inc.
  9. XCOMM #########################################################################
  10. XCOMM
  11. XCOMM This sample shell script demonstrates how the Text cut, copy and paste
  12. XCOMM facilities work.
  13. XCOMM
  14. XCOMM Pushbutton Callback: cut the currently select text
  15. Cut()
  16. {
  17. if XmTextCut $TEXT $(XtLastTimestampProcessed "-" $(XtDisplay "-" $TEXT));
  18. then
  19. echo "Cut occurred"
  20. else
  21. echo "No primary selection"
  22. fi
  23. }
  24. XCOMM Pushbutton Callback: copy the currently select text
  25. Copy()
  26. {
  27. if XmTextCopy $TEXT $(XtLastTimestampProcessed "-" $(XtDisplay "-" $TEXT));
  28. then
  29. echo "Copy occurred"
  30. else
  31. echo "No primary selection"
  32. fi
  33. }
  34. XCOMM Pushbutton Callback: clear the text selection
  35. ClearSelection()
  36. {
  37. XmTextClearSelection $TEXT $(XtLastTimestampProcessed "-" $(XtDisplay "-" $TEXT))
  38. }
  39. XCOMM Pushbutton Callback: paste the cut buffer at the current insertion position
  40. Paste()
  41. {
  42. if XmTextPaste $TEXT; then
  43. echo "Paste occurred"
  44. else
  45. echo "No primary selection"
  46. fi
  47. }
  48. XCOMM ###################### Create the Main UI ###############################
  49. XtInitialize TOPLEVEL textCutBuf1 TextCutBuf1 "$0" "$@"
  50. XtSetValues $TOPLEVEL allowShellResize:True
  51. XtCreateManagedWidget FORM form XmForm $TOPLEVEL \
  52. XtCreateManagedWidget TEXT text XmText $FORM \
  53. topAttachment:ATTACH_FORM \
  54. topOffset:10 \
  55. leftAttachment:ATTACH_FORM \
  56. leftOffset:10 \
  57. rightAttachment:ATTACH_FORM \
  58. rightOffset:10 \
  59. columns:40 \
  60. value:"This is the default string"
  61. XtCreateManagedWidget TEXT2 text2 XmText $FORM \
  62. topAttachment:ATTACH_WIDGET \
  63. topWidget:$TEXT \
  64. topOffset:10 \
  65. leftAttachment:ATTACH_FORM \
  66. leftOffset:10 \
  67. rightAttachment:ATTACH_FORM \
  68. rightOffset:10 \
  69. bottomAttachment:ATTACH_FORM \
  70. bottomOffset:10 \
  71. columns:40 \
  72. editable:False
  73. XtRealizeWidget $TOPLEVEL
  74. XtCreateApplicationShell TOPLEVEL2 textCutBuf1a TopLevelShell
  75. XtCreateManagedWidget RC rc XmRowColumn $TOPLEVEL2 \
  76. orientation:HORIZONTAL \
  77. numColumns:2 \
  78. packing:PACK_COLUMN
  79. XtCreateManagedWidget PB1 pb1 XmPushButton $RC \
  80. labelString:"Cut Selection"
  81. XtAddCallback $PB1 activateCallback "Cut"
  82. XtCreateManagedWidget PB2 pb2 XmPushButton $RC \
  83. labelString:"Copy Selection"
  84. XtAddCallback $PB2 activateCallback "Copy"
  85. XtCreateManagedWidget PB3 pb3 XmPushButton $RC \
  86. labelString:"Paste"
  87. XtAddCallback $PB3 activateCallback "Paste"
  88. XtCreateManagedWidget PB4 pb4 XmPushButton $RC \
  89. labelString:"Clear Selection"
  90. XtAddCallback $PB4 activateCallback "ClearSelection"
  91. XtRealizeWidget $TOPLEVEL2
  92. XtMainLoop