copy "cblproto.cpy". $set sourceformat(variable) program-id. filemanager. * List files in a directory and allow actions to be done on them. * Actions include view (text or binary), edit, email, and delete. * * Also allows navigation around directory structure, examination of * environment variables, and execution of shell commands. Search * for names or content, using simple string searches or regexes. * Directory tree structure can be shown and navigated round, also * directories in a filesystem. A navigation history is maintained * enabling simple navigation back (and forwards again). * * Detects whether terminal is colour-capable - uses colour if so, * and underline for highlight if not. * * Allows either a combined view of files and directories or * switching between file and directory views. Combined view can * have directories first or all in-line. *author. Mike Fleming. special-names. crt status is ws-key-status console is crt cursor is ws-cursor. file-control. select sh-command-file assign sh-command-line organization line sequential status ws-file-status-disp. file section. fd sh-command-file. 01 sh-command-rec. 03 sh-command-x pic x occurs 1000. working-storage section. copy "cbltypes.cpy". * Type definitions of C data types for use calling C programs 77 char pic s9(2) comp-5 is typedef. 77 uns-char pic 9(2) comp-5 is typedef. 77 short pic s9(4) comp-5 is typedef. 77 uns-short pic 9(4) comp-5 is typedef. 77 int pic s9(9) comp-5 is typedef. 77 uns-int pic 9(9) comp-5 is typedef. $IF P64 set 77 long pic s9(18) comp-5 is typedef. 77 uns-long pic 9(18) comp-5 is typedef. 77 size-t pic 9(18) comp-5 is typedef. 77 wchar-t pic 9(9) comp-5 is typedef. $ELSE 77 long pic s9(9) comp-5 is typedef. 77 uns-long pic 9(9) comp-5 is typedef. 77 size-t pic 9(9) comp-5 is typedef. 77 wchar-t pic 9(4) comp-5 is typedef. $END 77 l-long pic s9(18) comp-5 is typedef. 77 uns-l-long pic 9(18) comp-5 is typedef. 77 d-l-float comp-2 is typedef. 77 d-float comp-2 is typedef. 77 float comp-1 is typedef. 77 proc-pointer procedure-pointer is typedef. 77 data-pointer pointer is typedef. 77 void pic 9(2) comp-5 is typedef. 78 default-convention-val value 0. 78 cdecl-convention-val value 0. 78 pascal-convention-val value 11. 78 fast-convention-val value 2. 78 std-convention-val value 74. 78 sys-convention-val value 16. 78 opt-convention-val value 0. 78 pasc17-convention-val value 35. 78 cdec17-convention-val value 32. * End of type definitions * Define constants to drive screen and array sizes 78 c-scr-lines value 23. 78 c-max-files value 10000. 78 c-max-dirs value 2000. 78 c-max-dir-stack value 100. * End of constants * Allow communication with the fileview program 01 extdirname pic x(200) external. 01 extfilename pic x(200) external. 01 extlineno pic 9(9) comp external. 01 extline pic x(5000) external. * Stored values 01 ws-cobdata pic x(1000). 01 ws-home pic x(200). 01 ws-ps1 pic x(80). 01 ws-file-status pic x(2) comp-x. 01 ws-file-status-disp redefines ws-file-status. 88 valid-io value "00" "02". 88 end-of-file value "10". 88 dupl-key value "22". 88 no-rec value "23". 88 no-file value "35". 88 file-locked value "9A". 88 rec-locked value "9D". 03 ws-file-status-1 pic x. 03 ws-file-status-2. 05 ws-file-status-2-num pic x comp-x. 01 ws-file-status-2-disp pic 9(3). 01 ws-scr-start. 03 ws-scr-start-line pic 9(2) value 03. *> Adjust as required 03 ws-scr-start-col pic 9(2) value 01. * Number of occurrences of ws-file-entry is changed by changing * the value of c-max-files, above 01 ws-file-tbl. 03 ws-file-entry occurs 1 to c-max-files times depending on ws-last-file. 05 ws-file-name pic x(100). 05 ws-file-name-uc pic x(100). 05 ws-file-name-len pic 9(4). 05 ws-file-ext pic x(10). 05 ws-file-ext-uc pic x(10). 05 ws-file-size pic 9(10). 05 ws-file-date pic 9(8). 05 ws-file-time pic 9(4). 05 ws-file-type pic x. 88 dir-entry value "D". 88 file-entry value "F". 05 ws-file-name-quoted-ind pic x. 88 file-name-quoted value "Y" false "N". 05 ws-file-orig-line pic 9(9). * Number of occurrences of ws-dir-entry is changed by changing * value of c-max-dirs, above 01 ws-dir-tbl. 03 ws-dir-entry occurs 1 to c-max-dirs times depending on ws-last-dir. 05 ws-dir-name pic x(100). 05 ws-dir-name-uc pic x(100). 05 ws-dir-name-len pic 9(4) comp. 05 ws-dir-date pic 9(8). 05 ws-dir-time pic 9(4). 05 ws-dir-name-quoted-ind pic x. 88 dir-name-quoted value "Y" false "N". * Number of occurrences of ws-dir-stack-entry is changed by * changing value of c-max-dir-stack, above 01 ws-dir-stack-tbl. 03 ws-dir-stack-entry occurs c-max-dir-stack times. 05 ws-dir-stack-name pic x(100). 05 ws-dir-stack-quoted-ind pic x. 05 ws-dir-stack-view pic 9. 05 ws-dir-stack-from pic 9(9) comp. 05 ws-dir-stack-line pic 9(2). 01 ws-posn-tbl. 03 ws-posn-entry occurs 2 times. 05 ws-from pic 9(9) comp. 05 ws-to pic 9(9) comp. 05 ws-last-line pic 9(9) comp. 05 ws-scr-line-no pic 9(2). * Number of lines excluding headers is set by c-scr-lines * Table containing lines to be displayed on screen, in their * display format 01 ws-scr-tbl. 03 ws-scr-line occurs c-scr-lines times. 05 ws-scr-name pic x(54). 05 ws-scr-date pic x(8). 05 filler pic x. 05 ws-scr-time pic x(5). 05 filler pic x. 05 ws-scr-size pic z(9)9. * For mixed display types - set colour of line according to * this value 01 ws-scr-file-type-tbl. 03 ws-scr-file-type-entry occurs c-scr-lines times. 05 ws-scr-file-type pic x. 88 scr-file-entry value "F". 88 scr-dir-entry value "D". 01 ws-view pic 9. 88 file-view value 1. 88 dir-view value 2. 88 stack-view value 3. * Assorted numeric variables 01 ws-counts-and-pointers. 03 ws-last-file pic 9(9) comp. 03 ws-last-dir pic 9(9) comp. 03 ws-file-ptr pic 9(9) comp. 03 ws-dir-ptr pic 9(9) comp. 03 ws-dir-stack-ptr pic 9(4) comp. 03 ws-ptr pic s9(9) comp. 03 ws-arr-ptr pic 9(9) comp. 03 ws-scr-ptr pic 9(2) comp. 03 ws-tab-ptr pic 9(2) comp. 03 ws-l pic 9(2) comp. 03 ws-disp-line pic 9(2) comp. 03 ws-last-char pic 9(2) comp. 03 ws-str-len pic 9(4) comp. 03 ws-to-line pic 9(9) comp. 03 ws-last-page-top-line pic 9(9) comp. 03 ws-search-msg-start pic 9(2) comp. 03 ws-rename-msg-start pic 9(2) comp. 03 ws-text-ptr pic 9(4) comp. 03 ws-msg-len pic 9(2) comp. 03 ws-msg-ptr pic 9(2) comp. 03 ws-fname-ptr pic 9(4) comp. 03 ws-fname-len pic 9(4) comp. 03 ws-space-cnt pic 9(4) comp. 03 ws-envvar-cnt pic 9(4) comp. 03 ws-path-ptr pic 9(4) comp. 03 ws-cobdata-len pic 9(4) comp. 03 ws-ps1-len pic 9(4) comp. 03 ws-shell-ptr pic 9(9) comp. 03 ws-saved-from pic 9(9) comp. 03 ws-search-ptr pic 9(4) comp. 03 ws-search-escaped-len pic 9(4) comp. 03 ws-lookfor-ptr pic 9(4) comp. 03 ws-lookfor-escaped-len pic 9(4) comp. 03 ws-start-line pic 9(4) comp. 03 ws-find-len pic 9(4) comp. 03 ws-find-ptr pic 9(4) comp. 03 ws-findexp-ptr pic 9(4) comp. 03 ws-solidus-cnt pic 9(2) comp. 03 ws-dollar-cnt pic 9(2) comp. 03 ws-line-increment pic s9(2) comp. * Indicators 01 ws-indicators. 03 ws-os-type-ind pic x. 88 unix-os value "U". 88 windows-os value "W". 88 unknown-os value space. 03 ws-colour-ok-ind pic x. 88 colour-ok value "Y" false "N". 03 ws-search-wrapped-ind pic x. 88 search-wrapped value "Y" false "N". 03 ws-string-found-ind pic x. 88 string-found value "Y" false "N". 03 ws-file-found-ind pic x. 88 file-found value "Y" false "N". 03 ws-rename-done-ind pic x. 88 rename-done value "Y" false "N". 03 ws-name-wildcard-ind pic 9. 88 name-wildcard value 1. 03 ws-path-wildcard-ind pic 9. 88 path-wildcard value 1. 03 ws-name-space-ind pic 9. 88 name-space value 1. 03 ws-ask-question-ind pic x. 88 ask-question values "Y" "Q" false "N". 88 ask-y-or-n value "Y". 03 ws-valid-sort-ind pic x. 88 valid-sort value "Y" false "N". 03 ws-valid-defaults-ind pic x. 88 valid-defaults value "Y" false "N". 03 ws-valid-path-ind pic x. 88 valid-path value "Y" false "N". 03 ws-valid-to-addr-ind pic x. 88 valid-to-addr value "Y" false "N". 03 ws-valid-cc-addr-ind pic x. 88 valid-cc-addr value "Y" false "N". 03 ws-home-quoted-ind pic x. 88 home-quoted value "Y" false "N". 03 ws-pwd-quoted-ind pic x. 88 pwd-quoted value "Y" false "N". 03 ws-path-name-quoted-ind pic x. 88 path-name-quoted value "Y" false "N". 03 ws-fname-quoted-ind pic x. 88 fname-quoted value "Y" false "N". 03 ws-view-cmd-ind pic x. 88 view-cmd value "Y". 88 valid-view-cmd values "Y" "N" space. 03 ws-from-view-ind pic x. 88 from-view value "Y" false "N". 03 ws-exit-confirm-ind pic x. 88 exit-confirm value "Y" false "N". 03 ws-lookfor-active-ind pic x. 88 lookfor-active value "Y" false "N". 03 ws-find-active-ind pic x. 88 find-active value "Y" false "N". 03 ws-combi-view-ind pic x. 88 combi-view value "Y" false "N". 03 ws-delete-type-ind pic x. 88 delete-file value "D". 88 delete-dir value "F". 03 ws-combi-order-ind pic x. 88 dirs-first value "F". 88 dirs-inline value "I". 03 ws-display-ind pic x. 88 display-mixed value "M". 88 display-windows value "W". * Values from keyboard 01 ws-action pic x. 01 ws-keypress pic x. 01 ws-saved-keypress pic x. * Variables for repositioning if not by name 01 ws-fname-size pic 9(10). 01 ws-fname-date pic 9(8). 01 ws-fname-time pic 9(4). 01 ws-fname-ext pic x(10). * Variables for search 01 ws-search pic x(80). 01 ws-search-escaped pic x(160). 01 ws-search-regexp pic x(81). 01 ws-search-type pic x. 88 grep-search value "G". 88 string-search value "S". 01 ws-delim pic x(80). 01 ws-check-line pic x(80). 01 ws-grep-line pic x(81). 01 ws-dummy pic x(80). 01 ws-search-msg pic x(80). 01 ws-rename-msg pic x(80). 01 ws-lookfor pic x(80). 01 ws-lookfor-escaped pic x(160). 01 ws-find pic x(80). 01 ws-findexp pic x(400). 01 ws-case-sens-flag pic x(2). 01 ws-sort-seq pic x(5). * Variables for system call 01 ws-system-text pic x(500). 01 ws-default-system-text pic x(500). 01 ws-saved-system-text pic x(500). 01 ws-text-1 pic x(500). 01 ws-default-view-cmd-ind pic x. 01 ws-saved-view-cmd-ind pic x. 01 ws-system-err-msg pic x(80). 01 ws-shell pic x(1500). 01 ws-delim-ptr pic 9(4) comp. * File name and extension 01 ws-fname pic x(100). 01 ws-fname-temp pic x(100). 01 ws-extension pic x(10). 88 cobol-extension value "CBL" "COB" "CPY" *> Standard nonstd "88" "99" *> Company2 nonstd "SEL" "FD" "FS" "DEC" *> Company2 nonstd "LIB" "LNK" "WS". *> Company2 88 c-extension value "C". 88 html-extension value "HTM" "HTML" "SHTML". 88 php-extension value "PHP". 01 ws-new-filename pic x(60). * Default action and case sensitivity 01 ws-defaults. 03 ws-check-exit-ind pic x. 88 check-exit value "Y" false "N". 88 valid-check-exit values "Y" "N" space. 03 ws-default-action pic x value "V". 88 valid-default-action values "V" "H" "E" "!". 03 ws-case-sens-search-ind pic x. 88 case-sens-search value "Y" false "N". 88 valid-case-sens-search values "Y" "N" space. 03 ws-case-sens-look-ind pic x. 88 case-sens-look value "Y" false "N". 88 valid-case-sens-look values "Y" "N" space. 03 ws-case-sens-find-ind pic x. 88 case-sens-find value "Y" false "N". 88 valid-case-sens-find values "Y" "N" space. 03 ws-del-keypress-ind pic x. 88 del-keypress value "Y" false "N". 88 valid-del-keypress values "Y" "N" space. 03 ws-del-pause pic 9. 03 ws-cmd-keypress-ind pic x. 88 cmd-keypress value "Y" false "N". 88 valid-cmd-keypress values "Y" "N" space. 03 ws-cmd-pause pic 9. 03 ws-defaults-ok pic x. 88 valid-defaults-ok values "Y" "N" space. 01 ws-saved-defaults pic x(6). 01 ws-disp-case-sens-search pic x(20). 01 ws-disp-case-sens-look pic x(20). 01 ws-disp-case-sens-find pic x(20). * Display values and controls 01 ws-last-file-disp pic z(3)9. 01 ws-last-dir-disp pic z(3)9. 01 ws-dir-ctrl pic x(40). 01 ws-file-ctrl pic x(40). 01 ws-line-ctrl. 03 filler value "foreground-colour ". 03 ws-line-fg pic x. 01 ws-owner-disp pic x(40). 01 ws-group-disp pic x(40). * Email variables 01 ws-subject pic x(60). 01 ws-to-addr pic x(60). 01 ws-cc-addr pic x(60). 01 ws-env-addr pic x(60). 01 ws-subject-len pic 9(4) comp. 01 ws-to-addr-len pic 9(4) comp. 01 ws-cc-addr-len pic 9(4) comp. 01 ws-valemail-params. 03 ws-valemail-addr pic x(1000). 03 ws-valemail-err-msg pic x(80). 03 ws-valemail-valid-ind pic x. 88 email-valid value "Y" false "N". * Sort variables 01 ws-dir-sort-priority. 03 ws-dir-name-priority pic x. 88 valid-dir-name-priority values "A" "D" space. 03 ws-dir-date-priority pic x. 88 valid-dir-date-priority values "A" "D" space. 03 ws-dir-sort-ok pic x. 88 valid-dir-sort-ok values "Y" "N" space. 01 ws-saved-dir-sort-priority pic x(3). 01 ws-dir-sort-case-sens pic x. 88 valid-dir-sort-case-sens values "Y" "N" space. 01 ws-file-sort-priority. 03 ws-file-name-priority pic x. 88 valid-file-name-priority values "A" "D" space. 03 ws-file-type-priority pic x. 88 valid-file-type-priority values "A" "D" space. 03 ws-file-date-priority pic x. 88 valid-file-date-priority values "A" "D" space. 03 ws-file-size-priority pic x. 88 valid-file-size-priority values "A" "D" space. 03 ws-file-sort-ok pic x. 88 valid-file-sort-ok values "Y" "N" space. 01 ws-saved-file-sort-priority pic x(5). 01 ws-file-sort-case-sens pic x. 88 valid-file-sort-case-sens values "Y" "N" space. * Cursor positioning 01 ws-cursor. 03 ws-cursor-line pic 9(2). 03 ws-cursor-col pic 9(2). 01 ws-linecol. 03 ws-line pic 9(2). 03 ws-col pic 9(2) value is 1. 01 ws-msg-linecol. 03 ws-msg-line pic 9(2). 03 ws-msg-col pic 9(2). * Fields for "cd abc def" 01 ws-dir-1 pic x(60). 01 ws-dir-2 pic x(60). 01 ws-dir-part-1 pic x(60). 01 ws-dir-part-2 pic x(60). 01 ws-dir-part-1-len pic 9(4) comp. 01 ws-dir-part-2-len pic 9(4) comp. * Error/warning message 01 ws-msg pic x(80). 01 ws-msg-disp pic x(80). * Screen fields - use when accepting a series of fields from * a screen 01 ws-field pic 9(2) comp. 01 ws-last-field pic 9(2) comp. * Fields for directory sort screen 78 c-dir-sort-name-field value 1. 78 c-dir-sort-case-sens-field value c-dir-sort-name-field + 1. 78 c-dir-sort-date-field value c-dir-sort-case-sens-field + 1. 78 c-dir-sort-ok-field value c-dir-sort-date-field + 1. * Fields for file sort screen 78 c-file-sort-name-field value 1. 78 c-file-sort-case-sens-field value c-file-sort-name-field + 1. 78 c-file-sort-type-field value c-file-sort-case-sens-field + 1. 78 c-file-sort-date-field value c-file-sort-type-field + 1. 78 c-file-sort-size-field value c-file-sort-date-field + 1. 78 c-file-sort-ok-field value c-file-sort-size-field + 1. * Fields for default screen 78 c-default-exit-field value 1. 78 c-default-action-field value c-default-exit-field + 1. 78 c-default-search-field value c-default-action-field + 1. 78 c-default-look-field value c-default-search-field + 1. 78 c-default-find-field value c-default-look-field + 1. 78 c-default-del-key-field value c-default-find-field + 1. 78 c-default-del-pause-field value c-default-del-key-field + 1. 78 c-default-cmd-key-field value c-default-del-pause-field + 1. 78 c-default-cmd-pause-field value c-default-cmd-key-field + 1. 78 c-default-ok-field value c-default-cmd-pause-field + 1. * Fields for various library routines * Parameters for CBL_GET_OS 01 ws-get-os-info-params cblt-os-info-params. * Parameters for CBL_DIR_SCAN 01 ws-filemask pic x(60). 01 ws-handle usage pointer. 01 ws-pattern. 03 ws-pattern-len cblt-x2-comp5. 03 ws-pattern-content pic x(60). 01 ws-dir-pattern. 03 ws-dir-pattern-len cblt-x2-comp5. 03 ws-dir-pattern-content pic x(60). 01 ws-search-attr cblt-x4-comp5. 01 ws-search-flags cblt-os-flags. 01 ws-call-status pic x(2) comp-5. 01 ws-entry. 03 ws-attribute cblt-x4-comp5. 03 ws-date-stamp. 05 ws-year cblt-x4-comp5. 05 ws-month cblt-x2-comp5. 05 ws-day cblt-x2-comp5. 05 ws-hour cblt-x2-comp5. 05 ws-minute cblt-x2-comp5. 05 ws-second cblt-x2-comp5. 05 ws-millisec cblt-x2-comp5. 05 ws-dst cblt-x1-comp5. 03 ws-size cblt-x8-comp5. 03 ws-name. 05 ws-max-len cblt-x2-comp5. 05 ws-entry-name pic x(100). * Parameter for CBL_AND 01 ws-and-value cblt-x4-comp5. * Parameter for CBL_CHECK_FILE_EXISTS 01 ws-fe-param cblt-fileexist-buf. * Parameters for CBL_GET_CURRENT_DIR 01 ws-pwd pic x(200). 01 ws-pwd-flags cblt-os-flags. 01 ws-pwd-len cblt-os-size. * Parameters for CBL_LOCATE_FILE, used to translate $dirname * to actual dirname 01 ws-dir pic x(60). 01 ws-full-spec. 03 ws-full-name-len cblt-x2-compx. 03 ws-full-name pic x(70). 01 ws-mode cblt-x1-compx. 01 ws-exist-flag cblt-x1-compx. 01 ws-path-flag cblt-x1-compx. * Parameters for CBL_EXEC_RUN_UNIT 01 ws-run-unit-id cblt-x8-comp5. 01 ws-stack-size cblt-os-size. 01 ws-run-unit-flags cblt-os-flags. 78 c-call-and-wait value 1. 78 c-inherit-all-vars value zero. 78 c-inherit-env-only value 2. 78 c-inherit-console value zero. 78 c-new-console value 4. 78 c-run-unit-flags value c-call-and-wait + c-inherit-all-vars + c-inherit-console. * Used for various things 01 ws-path-name pic x(200). 01 ws-path-name-temp pic x(200). * End of fields for various library routines * Parameter for sleep 01 ws-sleep uns-int. * Fields for virtual file 01 ws-vfile-id cblt-vfile-handle. 01 ws-vfile-status cblt-vfile-status. 01 ws-vfile-buff-len cblt-x4-comp5. 01 ws-vfile-offset cblt-x4-comp5. 01 ws-vfile-len cblt-x4-comp5. 01 ws-vfile-status-disp pic 9(6). 01 ws-vfile-lines pic s9(9) comp. 01 ws-vfile-entry. 03 ws-vfile-rec-len pic 9(4) comp. 03 ws-vfile-rec pic x(105). 01 ws-heap-title pic x(45). 01 ws-heap-entry pic s9(9) comp. * End of virtual file fields * Fields for regular expression search operation 01 ws-c-flags int. 01 ws-e-flags int. 01 ws-return int. 01 ws-error pic x(200). 01 ws-err-len size-t. 01 ws-regerror-len size-t. 01 ws-regex-t. 03 re-nsub uns-long. 03 re-comp pointer. 03 re-cflags int. 03 re-erroff uns-long. 03 re-len uns-long. 03 re-min-col-val wchar-t. 03 re-max-col-val wchar-t. 03 re-cols occurs 10 times. 05 re-lsub pointer. 05 re-esub pointer. 03 re-map pic x(256). 03 re-maxsub int. 01 ws-safety-buffer pic x(2000). *> In case of overflow 78 reg-extended value 1. 78 reg-icase value 2. 78 reg-nosub value 4. 78 reg-newline value 8. 78 reg-notbol value x'100'. 78 reg-noteol value x'200'. * End of search fields * Screen handling and ADIS stuff 01 ws-key-status. 03 ws-key-type pic x. 88 Accept-terminated value "0". 88 User-func value "1". 88 ADIS-key value "2". 88 Data-key value "3". 03 ws-key-code-1 pic 9(2) comp-x. 88 Escape-key value zero. *> With key type 1 88 F-key values 1 through 12. 88 F1 value 1. *> With key type 1 88 F2 value 2. *> With key type 1 88 F3 value 3. *> With key type 1 88 F4 value 4. *> With key type 1 88 F5 value 5. *> With key type 1 88 F6 value 6. *> With key type 1 88 F7 value 7. *> With key type 1 88 F8 value 8. *> With key type 1 88 F9 value 9. *> With key type 1 88 F10 value 10. *> With key type 1 88 F11 value 11. *> With key type 1 88 F12 value 12. *> With key type 1 88 Page-Up value 53. *> With key type 1 88 Page-Down value 54. *> With key type 1 88 Ctrl-Page-Up value 55. *> With key type 1 88 Ctrl-Page-Down value 56. *> With key type 1 88 Enter-key value 48. *> With key type 0 88 Enter-key-ADIS value zero 2. *> With key type 2 88 cursor-left value 3. *> With key type 2 88 cursor-right value 4. *> With key type 2 88 cursor-up value 5. *> With key type 2 88 cursor-down value 6. *> With key type 2 88 Home-key value 7. *> With key type 2 88 Tab-key value 8 11. *> With key type 2 88 Backtab-key value 9 12. *> With key type 2 88 End-key value 10. *> With key type 2 88 Insert-key value 16. *> With key type 2 88 Delete-key value 17. *> With key type 2 88 Backspace-key value 14. *> With key type 2 88 Ctrl-E value 22. *> With key type 2 88 Ctrl-F value 13. *> With key type 2 88 Ctrl-key value 49. *> With key type 0 nonstd* For some reason, Company2 has non-standard mappings for some keys: nonstd* 66 and 67 for paging keys (should be Alt-B and Alt-C) nonstd* 69 and 72 for Home/End keys (should be Alt-E and Alt-H) nonstd* 71 for Delete key (should be Alt-G) nonstd* Non-standard keys are User-func keys, not ADIS nonstd 88 Page-Up-nonstd value 66. *> With key type 1 ** nonstd 88 Page-Down-nonstd value 67. *> With key type 1 ** nonstd 88 Home-key-nonstd value 69. *> With key type 1 ** nonstd 88 End-key-nonstd value 72. *> With key type 1 ** nonstd 88 Delete-key-nonstd value 71. *> With key type 1 ** 03 ws-key-code-2 pic x comp-x. * With key type 0, key-code-1 49 88 Ctrl-B value 2. 88 Ctrl-G value 7. 01 get-single-char-func pic 9(2) comp-x value 26. 01 ws-adis-panel-function pic 9(2) comp-x. 01 ws-adis-panel-dummy-param pic x. 01 ws-set-bit-pairs pic 9(2) comp-x value 1. 01 ws-key-control. 03 ws-key-setting pic 9(2) comp-x. 03 ws-key-control-type pic x value "1". 03 ws-first-key. 05 ws-first-key-num pic 9(2) comp-x. 03 ws-num-of-keys pic 9(2) comp-x. * Define constants 78 c-last-dir-sort-field value length ws-dir-sort-priority. 78 c-last-file-sort-field value length ws-file-sort-priority. 78 c-vfile-reclen-len value length ws-vfile-rec-len. 78 black value zero. 78 blue value 1. 78 green value 2. 78 cyan value 3. 78 red value 4. 78 magenta value 5. 78 yellow value 6. 78 white value 7. 78 black-x value "0". 78 blue-x value "1". 78 green-x value "2". 78 cyan-x value "3". 78 red-x value "4". 78 magenta-x value "5". 78 yellow-x value "6". 78 white-x value "7". screen section. 01 ss-dir background-colour black foreground-colour white. 03 blank screen. 03 line 5. 03 col 10 value "Directory:". 03 line + 1. 03 col 10 pic x(60) using ws-dir. 03 line + 2. 03 col 10 value "Allows the use of AIX-style substitution, ie.". 03 line + 2. 03 col 10 value "string1 string2". 03 line + 2. 03 col 10 value "where string1 in the current directory name is replaced". 03 line + 1. 03 col 10 value "by string2 and the directory changed to the result". 01 ss-filemask background-colour black foreground-colour white. 03 blank screen. 03 line 5. 03 col 10 value "File selection:". 03 line + 1. 03 col 10 pic x(60) using ws-filemask. 03 line + 2. 03 col 10 value "Pattern can include wildcards eg. *.cbl". 03 line + 1. 03 col 10 value "* - replace any number of characters". 03 line + 1. 03 col 10 value "? - replace one character". 03 line + 1. 03 col 10 value "! - escape next character". 01 ss-main background-colour black foreground-colour white. 03 blank screen. 03 ss-main-top-lines foreground-colour yellow. 05 col 2 pic x(48) from ws-pwd. 05 col + 2 from ws-last-dir-disp control ws-dir-ctrl. 05 col + 1 value " Directories" control ws-dir-ctrl. 05 col + 2 from ws-last-file-disp control ws-file-ctrl. 05 col + 1 value " Files" control ws-file-ctrl. 05 line + 1. 05 col 1 pic x(80) value all "=". 03 scr-view-area. 05 scr-view-entry occurs c-scr-lines times. 07 line + 1. 07 col 1 pic x(80) from ws-scr-line. 01 ss-dir-sort background-colour black foreground-colour yellow auto-skip. 03 blank screen. 03 line 3. 03 col 34 value "Directory sort" highlight underline. 03 line + 2. 03 col 18 value "Field to sort on (Ascending or Descending):". 03 line + 2. 03 col 20 value "Name:". 03 ss-dir-sort-name col + 2 using ws-dir-name-priority. 03 col 32 value "(default)". 03 line + 1. 03 col 24 value "Case sensitive:". 03 ss-dir-sort-case-sens col + 2 using ws-dir-sort-case-sens. 03 line + 1. 03 col 20 value "Date:". 03 ss-dir-sort-date col 28 using ws-dir-date-priority. 03 line + 2. 03 col 20 value "All OK?". 03 ss-dir-sort-ok col 28 using ws-dir-sort-ok. 03 col 32 value "(Y or N)". 01 ss-file-sort background-colour black foreground-colour yellow auto-skip. 03 blank screen. 03 line 3. 03 col 37 value "File sort" highlight underline. 03 line + 2. 03 col 18 value "Field to sort on (Ascending or Descending):". 03 line + 2. 03 col 20 value "Name:". 03 ss-file-sort-name col 28 using ws-file-name-priority. 03 col 32 value "(default)". 03 line + 1. 03 col 24 value "Case sensitive:". 03 ss-file-sort-case-sens col + 2 using ws-file-sort-case-sens. 03 line + 1. 03 col 20 value "Type:". 03 ss-file-sort-type col 28 using ws-file-type-priority. 03 line + 1. 03 col 20 value "Date:". 03 ss-file-sort-date col 28 using ws-file-date-priority. 03 line + 1. 03 col 20 value "Size:". 03 ss-file-sort-size col 28 using ws-file-size-priority. 03 line + 2. 03 col 20 value "All OK?". 03 ss-file-sort-ok col 28 using ws-file-sort-ok. 03 col 32 value "(Y or N)". 01 ss-defaults background-colour black foreground-colour yellow auto-skip. 03 blank screen. 03 line 2. 03 col 36 value "Defaults" highlight underline. 03 line + 2. 03 col 12 value "Request confirmation of exit:". 03 ss-check-exit col + 2 using ws-check-exit-ind. 03 line + 2. 03 col 12 value "Default action:". 03 ss-default-action col + 2 using ws-default-action. 03 line + 2. 03 col 12 value "V". 03 col 20 value "View file". 03 line + 1. 03 col 12 value "H". 03 col 20 value "Hex view of file". 03 line + 1. 03 col 12 value "E". 03 col 20 value "Edit file". 03 line + 1. 03 col 12 value "!". 03 col 20 value "Execute command (define on next screen)". 03 line + 2. 03 col 12 value "Case sensitive search:". 03 ss-case-sens-search col + 2 using ws-case-sens-search-ind. 03 line + 1. 03 col 12 value "Case sensitive lookfor:". 03 ss-case-sens-look col + 2 using ws-case-sens-look-ind. 03 line + 1. 03 col 12 value "Case sensitive find:". 03 ss-case-sens-find col + 2 using ws-case-sens-find-ind. 03 line + 2. 03 col 12 value "Keypress after deletion:". 03 ss-del-keypress col + 2 using ws-del-keypress-ind. 03 line + 1. 03 col 12 value " - If no keypress, show message and pause this long:". 03 ss-del-pause col + 2 using ws-del-pause. 03 col + 2 value "seconds". 03 line + 1. 03 col 20 value "(zero = no delete message)". 03 line + 1. 03 col 12 value "Keypress after command:". 03 ss-cmd-keypress col + 2 using ws-cmd-keypress-ind. 03 line + 1. 03 col 12 value " - If no keypress, show message and pause this long:". 03 ss-cmd-pause col + 2 using ws-cmd-pause. 03 col + 2 value "seconds". 03 line + 1. 03 col 20 value "(zero = no display of command outcome)". 03 line + 2. 03 col 20 value "All OK?". 03 ss-defaults-ok col 28 using ws-defaults-ok. 03 col 32 value "(Y or N)". 01 ss-email-file background-colour black foreground-colour yellow auto-skip. 03 blank screen. 03 line 3. 03 col 35 value "Email file" highlight underline. 03 line + 2. 03 col 5 value "Subject:". 03 col 15 using ws-subject. 03 line + 2. 03 col 5 value "To:". 03 col 15 using ws-to-addr. 03 line + 2. 03 col 5 value "Cc:". 03 col 15 using ws-cc-addr. 03 line + 2. 03 col 1 from ws-msg-disp. 01 ss-search-unix background-colour black foreground-colour yellow. 03 blank screen. 03 line 3. 03 col 37 value "Search" highlight underline. 03 line + 2. 03 col 10 value "Search string:". 03 line + 1. 03 col 1 pic x(80) using ws-search. 03 line + 2. 03 col 10 value "For regular expression, start and end with one of /, ?, or =". 03 line + 2. 03 col 10 value "Search is ". 03 col + 1 from ws-disp-case-sens-search. 03 col + 2 value "(use D - defaults - to change)". 03 line + 2. 03 col 1 pic x(80) from ws-search-msg. 01 ss-search-windows background-colour black foreground-colour yellow. 03 blank screen. 03 line 3. 03 col 37 value "Search" highlight underline. 03 line + 2. 03 col 10 value "Search string:". 03 line + 1. 03 col 1 pic x(80) using ws-search. 03 line + 2. 03 col 10 value "Search is ". 03 col + 1 from ws-disp-case-sens-search. 03 col + 2 value "(use D - defaults - to change)". 03 line + 2. 03 col 1 pic x(80) from ws-search-msg. 01 ss-lookfor background-colour black foreground-colour yellow. 03 blank screen. 03 line 3. 03 col 36 value "Look for" highlight underline. 03 line + 2. 03 col 10 value "Look for string:". 03 line + 1. 03 col 1 pic x(80) using ws-lookfor. 03 line + 2. 03 col 10 value "Lookfor is ". 03 col + 1 from ws-disp-case-sens-look. 03 col + 2 value "(use D - defaults - to change)". 03 line + 2. 03 col 10 value "Filename pattern: ". 03 col + 1 from ws-pattern-content. 03 line + 1. 03 col 10 value "Search string is treated as regular expression". 03 line + 2. 03 col 10 value "Use C or F with an empty pattern to rescan directory". 03 line + 2. 03 col 1 pic x(80) from ws-search-msg. 01 ss-find background-colour black foreground-colour yellow. 03 blank screen. 03 line 3. 03 col 38 value "Find" highlight underline. 03 line + 2. 03 col 10 value "Look for files:". 03 line + 1. 03 col 1 pic x(80) using ws-find. 03 line + 2. 03 col 10 value "Find is ". 03 col + 1 from ws-disp-case-sens-find. 03 col + 2 value "(use D - defaults - to change)". 03 line + 2. 03 col 10 value "Find string may contain wildcards - *, ?". 03 line + 2. 03 col 10 value "Use C or F with an empty pattern to rescan directory". 03 col 1 pic x(80) from ws-search-msg. 01 ss-system-call background-colour black foreground-colour yellow. 03 blank screen. 03 line 3. 03 col 29 value "Execute system command" highlight underline. 03 line 5. 03 col 1 value "Command to execute:". 03 line + 1. 03 col 1 pic x(80) using ws-system-text. 03 line + 2. 03 col 1 value "Show output in viewer:". 03 col + 2 using ws-view-cmd-ind. 03 col + 5 value "(Y/N, default N)". 03 line + 2. 03 col 1 pic x(80) from ws-system-err-msg. 03 line + 2. 03 col 5 value "The characters #F or #f will be replaced by the current file name". 03 line + 1. 03 col 5 value "and the characters #P or #p will be replaced by the current path". 03 line + 1. 03 col 5 value "eg. if the current path is /var/def file and the current file". 03 line + 1. 03 col 5 value "is aaa.cbl then the command". 03 line + 1. 03 col 5 value "diff #P/#F $SRC/#f". 03 line + 1. 03 col 5 value "will be interpreted as". 03 line + 1. 03 col 5 value "diff /var/def/aaa.cbl $SRC/aaa.cbl". 03 line + 2. 03 col 5 value "Current file name:". 03 col + 2 from ws-fname. 03 line + 1. 03 col 5 value "Current path name:". 03 col + 2 from ws-pwd. 01 ss-unix-details background-colour black foreground-colour yellow. 03 blank screen. 03 line 3. 03 col 36 value "Details" highlight underline. 03 line + 2. 03 col 10 value "Name:". 03 col 25 from ws-file-name(ws-arr-ptr). 03 line + 2. 03 col 10 value "Path:". 03 col 25 from ws-pwd. 03 line + 2. 03 col 10 value "Permissions:". 03 col 25 from sh-command-rec(1:10). 03 line + 2. 03 col 10 value "Owner:". 03 col 25 from ws-owner-disp. 03 line + 2. 03 col 10 value "Group:". 03 col 25 from ws-group-disp. 03 line + 2. 03 col 10 value "Size:". 03 col 25 from ws-scr-size(ws-l)(ws-scr-ptr:). 03 line + 2. 03 col 10 value "Last modified:". 03 col 25 from ws-scr-date(ws-l). 03 col 34 from ws-scr-time(ws-l). 03 line 25. 03 col 60 value "Press any key". 01 ss-windows-details background-colour black foreground-colour yellow. 03 blank screen. 03 line 3. 03 col 36 value "Details" highlight underline. 03 line + 2. 03 col 2 from sh-command-rec(1:78). 03 line 25. 03 col 60 value "Press any key". 01 ss-rename background-colour black foreground-colour yellow. 03 blank screen. 03 line 3. 03 col 37 value "Rename" highlight underline. 03 line + 2. 03 col 11 value "New filename:". 03 line + 1. 03 col 11 pic x(60) using ws-new-filename. 03 line + 2. 03 col 11 value "New filename must not include a pathname". 03 line + 2. 03 col 1 pic x(80) from ws-rename-msg. 01 ss-pwd background-colour black foreground-colour yellow. 03 blank screen. 03 line 3. 03 col 31 value "Current directory" highlight underline. 03 line + 2. 03 col 1 pic x(200) from ws-pwd. 01 ss-help-unix-1 background-colour black foreground-colour yellow. 03 blank screen. 03 line 2. 03 col 2 value "Escape". 03 col 18 value "End". 03 line + 1. 03 col 2 value "F1". 03 col 18 value "Show this screen". 03 line + 2. 03 col 2 value "Tab". 03 col 18 value "Toggle between file and directory views". 03 line + 1. 03 col 2 value "Enter". 03 col 18 value "Directory view - cd into selected directory". 03 line + 1. 03 col 18 value "File view - carry out default action". 03 line + 1. 03 col 2 value "D". 03 col 18 value "Set default action and search/lookfor case sensitivity". 03 line + 1. 03 col 2 value "U, ^". 03 col 18 value "Go up a level in directory". 03 line + 1. 03 col 2 value "~". 03 col 18 value "Change directory to home directory". 03 line + 1. 03 col 2 value "C". 03 col 18 value "Change directory". 03 line + 1. 03 col 2 value "F". 03 col 18 value "Change filemask pattern". 03 line + 1. 03 col 2 value "R, F5". 03 col 18 value "Refresh directory view". 03 line + 1. 03 col 2 value "S". 03 col 18 value "Change sort order". 03 line + 2. 03 col 2 value "V". 03 col 18 value "View file using fileview". 03 line + 1. 03 col 2 value "H". 03 col 18 value "View file using hexview". 03 line + 1. 03 col 2 value "E". 03 col 18 value "Edit file". 03 line + 1. 03 col 2 value "M". 03 col 18 value "Email file". 03 line + 1. 03 col 2 value "F2". 03 col 18 value "Rename file". 03 line + 1. 03 col 2 value "X, Delete". 03 col 18 value "Delete file or directory". 03 line 25. 03 col 60 value "Press any key". 01 ss-help-unix-2 background-colour black foreground-colour yellow. 03 blank screen. 03 line 2. 03 col 2 value "/". 03 col 18 value "Search in names - simple search or regular expression". 03 line + 1. 03 col 2 value "F3". 03 col 18 value "Repeat last search". 03 line + 1. 03 col 2 value "L". 03 col 18 value "Look for files containing a specified string". 03 line + 2. 03 col 2 value "Cursor left". 03 col 18 value "Return to previous directory". 03 line + 1. 03 col 2 value "Cursor right". 03 col 18 value "Go to next directory (previously visited)". 03 line + 1. 03 col 2 value "F7". 03 col 18 value "Show directory stack". 03 line + 2. 03 col 2 value "_". 03 col 18 value "Show full name of current directory". 03 line + 1. 03 col 2 value "?". 03 col 18 value "Show details of selected file or directory". 03 line + 1. 03 col 2 value "$". 03 col 18 value "Show values of environment variables". 03 line + 1. 03 col 2 value "+". 03 col 18 value "Show tree structure of directories and allow selection". 03 line + 1. 03 col 2 value "%". 03 col 18 value "Show directories in current filesystem with total file size". 03 line + 1. 03 col 18 value "in kB and allow selection". 03 line + 1. 03 col 2 value "@". 03 col 18 value "As for % but sorted in reverse order of size". 03 line + 1. 03 col 2 value "#". 03 col 18 value "Find files in this and subsidiary directories". 03 line + 2. 03 col 2 value "!". 03 col 18 value "Execute a shell command". 03 line + 1. 03 col 2 value ":". 03 col 18 value "Enter shell". 03 line + 2. 03 col 2 value "F9". 03 col 18 value "Toggle between separate file & dir views and combined view". 03 line + 1. 03 col 2 value "F8". 03 col 18 value "When in combined view, toggle between all in line (like Unix)". 03 line + 1. 03 col 18 value "and directories first (like Windows)". 03 line 25. 03 col 60 value "Press any key". 01 ss-help-windows-1 background-colour black foreground-colour yellow. 03 blank screen. 03 line 2. 03 col 2 value "Escape". 03 col 18 value "End". 03 line + 1. 03 col 2 value "F1". 03 col 18 value "Show this screen". 03 line + 2. 03 col 2 value "Tab". 03 col 18 value "Toggle between file and directory views". 03 line + 1. 03 col 2 value "Enter". 03 col 18 value "Directory view - cd into selected directory". 03 line + 1. 03 col 18 value "File view - carry out default action". 03 line + 1. 03 col 2 value "D". 03 col 18 value "Set default action and search/lookfor case sensitivity". 03 line + 1. 03 col 2 value "U, ^". 03 col 18 value "Go up a level in directory". 03 line + 1. 03 col 2 value "~". 03 col 18 value "Change directory to home directory". 03 line + 1. 03 col 2 value "C". 03 col 18 value "Change directory". 03 line + 1. 03 col 2 value "F". 03 col 18 value "Change filemask pattern". 03 line + 1. 03 col 2 value "R, F5". 03 col 18 value "Refresh directory view". 03 line + 1. 03 col 2 value "S". 03 col 18 value "Change sort order". 03 line + 2. 03 col 2 value "V". 03 col 18 value "View file using fileview". 03 line + 1. 03 col 2 value "H". 03 col 18 value "View file using hexview". * 03 line + 1. * 03 col 2 value "E". * 03 col 18 value * "Edit file". 03 line + 1. 03 col 2 value "F2". 03 col 18 value "Rename file". 03 line + 1. 03 col 2 value "X, Delete". 03 col 18 value "Delete file or directory". 03 line 25. 03 col 60 value "Press any key". 01 ss-help-windows-2 background-colour black foreground-colour yellow. 03 blank screen. 03 line 2. 03 col 2 value "/". 03 col 18 value "Search for string in names". 03 line + 1. 03 col 2 value "F3". 03 col 18 value "Repeat last search". 03 line + 1. 03 col 2 value "L". 03 col 18 value "Look for files containing a specified string". 03 line + 2. 03 col 2 value "Cursor left". 03 col 18 value "Return to previous directory". 03 line + 1. 03 col 2 value "Cursor right". 03 col 18 value "Go to next directory (previously visited)". 03 line + 1. 03 col 2 value "F7". 03 col 18 value "Show directory stack". 03 line + 2. 03 col 2 value "_". 03 col 18 value "Show full name of current directory". 03 line + 1. 03 col 2 value "?". 03 col 18 value "Show details of selected file or directory". 03 line + 1. 03 col 2 value "$". 03 col 18 value "Show values of environment variables". 03 line + 1. 03 col 2 value "+". 03 col 18 value "Show tree structure of directories and allow selection". * 03 line + 1. * 03 col 2 value "%". * 03 col 18 value * "Show directories in current filesystem with total file size". * 03 line + 1. * 03 col 18 value * "in kB and allow selection". * 03 line + 1. * 03 col 2 value "@". * 03 col 18 value * "As for % but sorted in reverse order of size". * 03 line + 1. * 03 col 2 value "#". * 03 col 18 value * "Find files in this and subsidiary directories". 03 line + 2. 03 col 2 value "!". 03 col 18 value "Execute a shell command". 03 line + 1. 03 col 2 value ":". 03 col 18 value "Enter shell". 03 line + 2. 03 col 2 value "F9". 03 col 18 value "Toggle between separate file & dir views and combined view". 03 line + 1. 03 col 2 value "F8". 03 col 18 value "When in combined view, toggle between all in line (like Unix)". 03 line + 1. 03 col 18 value "and directories first (like Windows)". 03 line 25. 03 col 60 value "Press any key". procedure division. a-control section. perform b1-start perform b5-main until (User-func and Escape-key) and (exit-confirm or not check-exit) perform b9-end goback . b1-start section. * What operating system are we running under? call "CBL_GET_OS_INFO" using ws-get-os-info-params evaluate cblte-osi-os-type when 128 set unix-os to true when 131 set windows-os to true when other set unknown-os to true end-evaluate * Set F1-F10 and Escape to be intercepted by the program move "1" to ws-key-control-type move 1 to ws-key-setting move zero to ws-first-key-num move 13 to ws-num-of-keys call x"AF" using ws-set-bit-pairs ws-key-control perform x1-intercept-cursor-keys * Resetting COBDATA is necessary as only files in the directories * named in COBDATA will be deleted by CBL_DELETE_FILE, which may * have very unintended consequences. Putting "./" in front of the * filename does nothing to alter this behaviour. display "COBDATA" upon environment-name accept ws-cobdata from environment-value display "COBDATA" upon environment-name display space upon environment-value if ws-cobdata = spaces move zero to ws-cobdata-len else perform varying ws-cobdata-len from length ws-cobdata by -1 until ws-cobdata(ws-cobdata-len:1) not = space end-perform end-if * Get $HOME for the ~ keypress display "HOME" upon environment-name accept ws-home from environment-value * Do we want to check exit? display "FM_CHECK_EXIT" upon environment-name accept ws-check-exit-ind from environment-value if ws-check-exit-ind not = "N" set check-exit to true end-if * Any special requirements for display? * M will show mixed files and directories * W will show mixed files and directories, directories first display "FM_DISPLAY" upon environment-name accept ws-display-ind from environment-value * Have we got colour capability? * Assume we have for anything but Unix if unix-os move z"mfinfocmp $TERM | grep colors# >/dev/null 2>&1" to ws-shell call "SYSTEM" using ws-shell if return-code zero set colour-ok to true else set colour-ok to false end-if else set colour-ok to true end-if move zero to ws-del-pause move spaces to ws-key-status move zero to ws-sleep if ws-home(1:1) = '"' set home-quoted to true move ws-home(2:) to ws-path-name-temp move ws-path-name-temp to ws-home perform varying ws-ptr from length ws-home by -1 until ws-ptr < 1 or ws-home(ws-ptr:1) = '"' end-perform if ws-ptr >= 1 move space to ws-home(ws-ptr:1) end-if end-if if extdirname not = spaces and not = low-values move extdirname to ws-path-name else accept ws-path-name from command-line end-if * Note: if user puts in a pathname with a wildcard, the shell will * already have expanded that by the time it gets in here. I want to * cater for having spaces in a pathname though. * If we have an embedded space, it needs to be quoted if ws-path-name not = spaces perform varying ws-ptr from length ws-path-name by -1 until ws-path-name(ws-ptr:1) not = space end-perform perform varying ws-ptr from ws-ptr by -1 until ws-ptr < 1 or ws-path-name(ws-ptr:1) = space end-perform if ws-ptr < 1 set path-name-quoted to false else set path-name-quoted to true end-if perform s7-change-dir end-if * Set defaults and starting conditions * Initial values move spaces to ws-pattern-content move spaces to ws-dir-sort-priority ws-file-sort-priority move "A" to ws-dir-name-priority ws-file-name-priority move "Y" to ws-dir-sort-case-sens ws-file-sort-case-sens set case-sens-search to true set case-sens-look to false set case-sens-find to true set del-keypress to true set cmd-keypress to true set from-view to false set exit-confirm to false set search-wrapped to false move spaces to ws-search ws-lookfor set file-view to true evaluate true when display-mixed set combi-view to true set dirs-inline to true when display-windows set combi-view to true set dirs-first to true when other set combi-view to false set dirs-inline to true end-evaluate * Do the initial directory scan and set up the first screen perform s1-scan-dir if not combi-view and ws-last-file zero set dir-view to true end-if perform s11-set-view * Start our directory stack off move zero to ws-dir-stack-ptr move 1 to ws-saved-from perform s9-push-dir-stack perform s3-display-screen . b5-main section. * ws-l is the entry number in the displayed array of files * ws-arr-ptr is the entry in the file/dir table being pointed to * ws-last-page-top-line is the first line of the last page of the file compute ws-l = ws-line - (ws-scr-start-line - 1) compute ws-arr-ptr = (ws-from(ws-view) + ws-l) - 1 compute ws-last-page-top-line = (ws-last-line(ws-view) - c-scr-lines) + 1 if ws-last-page-top-line < 1 move 1 to ws-last-page-top-line end-if * Get the keypress and redisplay whatever was in that position accept ws-keypress at ws-linecol auto display ws-scr-line(ws-l)(ws-col:1) at ws-linecol control ws-line-ctrl move function upper-case(ws-keypress) to ws-keypress * Check which key has been pressed and action accordingly * It's a big evaluate statement but not complex so I've left it * as is rather than splitting it up * Code to deal with non-standard key mappings * Delete this evaluate statement if your place is rational nonstd evaluate true also true nonstd when User-func also Page-Up-nonstd nonstd set User-func nonstd Page-Up to true nonstd when User-func also Page-Down-nonstd nonstd set User-func nonstd Page-Down to true nonstd when User-func also Home-key-nonstd nonstd set ADIS-key nonstd Home-key to true nonstd when User-func also End-key-nonstd nonstd set ADIS-key nonstd End-key to true nonstd when User-func also Delete-key-nonstd nonstd set ADIS-key nonstd Delete-key to true nonstd end-evaluate evaluate true also true when Accept-terminated also Ctrl-key evaluate ws-keypress when "C" perform c1-change-dir when "F" perform c3-change-filemask when "R" perform s1-scan-dir perform s3-display-screen when "/" perform c5-search when "!" perform c7-system-call when "V" when "H" if file-view and not (combi-view and dir-entry(ws-arr-ptr)) perform c9-view-file end-if when "X" perform c11-delete-object when "U" when "^" perform c13-cd-to-parent when "S" if dir-view perform c15-dir-sort-order else perform c17-file-sort-order end-if when "D" perform c19-set-default-action when "E" if file-view and not (combi-view and dir-entry(ws-arr-ptr)) perform c21-edit-file end-if when "M" if file-view and not (combi-view and dir-entry(ws-arr-ptr)) perform c23-email-file end-if when "?" if ws-last-line(ws-view) > zero perform c25-show-details end-if when "_" perform c27-show-pwd when "L" if ws-last-file not zero perform c29-lookfor end-if when "$" when "%" when "@" perform c31-show-command-output when "~" perform c33-go-home when ":" perform c41-shell-session when "+" perform c45-show-dir-tree when "#" perform c51-find when "T" if file-view perform c53-tail-file end-if end-evaluate when Accept-terminated also Enter-key when ADIS-key also Enter-key-ADIS if dir-view or (combi-view and dir-entry(ws-arr-ptr)) perform c35-change-dir else * Execute the default action on the file evaluate ws-default-action when "V" move "V" to ws-keypress perform c9-view-file when "H" move "H" to ws-keypress perform c9-view-file when "E" perform c21-edit-file when "!" move space to ws-keypress move ws-default-system-text to ws-system-text perform c7-system-call end-evaluate end-if perform s3-display-screen when User-func also Escape-key evaluate true when from-view move ws-saved-keypress to ws-keypress set Accept-terminated to true if ws-dir-stack-ptr > 1 subtract 1 from ws-dir-stack-ptr end-if perform c31-show-command-output when check-exit move ws-line to ws-scr-line-no(ws-view) move "Exit? (Y/N)" to ws-msg set ask-y-or-n to true perform x5-display-message perform s3-display-screen move ws-keypress to ws-exit-confirm-ind * Reset user-func and escape key, unset by x5-display-message set User-func to true set Escape-key to true when other set exit-confirm to true exit section end-evaluate when User-func also F1 perform c43-show-help when User-func also F2 if file-view and not (combi-view and dir-entry(ws-arr-ptr)) perform c47-rename-file end-if when User-func also F3 * Repeat the last search - unset string-found first set string-found to false evaluate true when string-search perform d1-string-search when grep-search perform d3-grep-search end-evaluate if string-found perform s3-display-screen end-if when User-func also F5 perform s1-scan-dir perform s3-display-screen when User-func also F7 perform c49-show-dir-stack when User-func also F8 if combi-view if dirs-first set dirs-inline to true else set dirs-first to true end-if end-if perform s1-scan-dir perform s11-set-view perform s3-display-screen when User-func also F9 if combi-view set combi-view to false else set combi-view to true end-if perform s1-scan-dir if not combi-view and file-view and ws-last-file zero set dir-view to true end-if perform s11-set-view perform s3-display-screen when User-func also F2 *> A few keypresses that could be used when User-func also F4 when User-func also F6 when User-func also F10 when User-func also F11 when User-func also F12 continue when User-func also Page-Up *> Go one page back evaluate ws-from(ws-view) when > c-scr-lines subtract c-scr-lines from ws-from(ws-view) when other move 1 to ws-from(ws-view) end-evaluate move ws-scr-start-line to ws-scr-line-no(ws-view) perform s3-display-screen when User-func also Page-Down *> Go down a page evaluate true when ws-to(ws-view) < ws-last-line(ws-view) add c-scr-lines to ws-from(ws-view) if ((ws-from(ws-view) + c-scr-lines) - 1) > ws-last-line(ws-view) compute ws-scr-line-no(ws-view) = (ws-from(ws-view) - ws-last-page-top-line) + ws-scr-start-line move ws-last-page-top-line to ws-from(ws-view) else move ws-scr-start-line to ws-scr-line-no(ws-view) end-if when other compute ws-scr-line-no(ws-view) = ws-scr-start-line + (ws-to(ws-view) - ws-from(ws-view)) end-evaluate perform s3-display-screen when ADIS-key also Tab-key * Toggle view if in separate files & directories mode if not combi-view move ws-line to ws-scr-line-no(ws-view) if dir-view set file-view to true else set dir-view to true end-if perform s11-set-view perform s3-display-screen end-if when ADIS-key also cursor-up * Go up a line evaluate true when ws-l > 1 * not at start of screen, move highlight up move -1 to ws-line-increment perform s15-move-line when ws-from(ws-view) > 1 * at start of screen, move screen window up subtract 1 from ws-from(ws-view) move ws-line to ws-scr-line-no(ws-view) perform s3-display-screen end-evaluate when ADIS-key also cursor-down * Go down a line evaluate true when (ws-from(ws-view) + ws-l) > ws-last-line(ws-view) * at end of file continue when ws-l < c-scr-lines * not at end of screen, move highlight up move +1 to ws-line-increment perform s15-move-line when ws-from(ws-view) < ws-last-page-top-line * at end of screen, move screen window down add 1 to ws-from(ws-view) move ws-line to ws-scr-line-no(ws-view) perform s3-display-screen end-evaluate when ADIS-key also Home-key move 1 to ws-from(ws-view) move ws-scr-start-line to ws-scr-line-no(ws-view) perform s3-display-screen when ADIS-key also End-key if ws-last-line(ws-view) > c-scr-lines move ws-last-page-top-line to ws-from(ws-view) compute ws-line = (ws-scr-start-line + c-scr-lines) - 1 else compute ws-line = (ws-scr-start-line + ws-last-line(ws-view)) - 1 end-if move ws-line to ws-scr-line-no(ws-view) perform s3-display-screen when ADIS-key also Delete-key perform c11-delete-object when ADIS-key also cursor-left perform c37-cd-to-last-dir when ADIS-key also cursor-right perform c39-cd-to-next-dir end-evaluate . b9-end section. . c1-change-dir section. * Get a new directory to look at move spaces to ws-dir display ss-dir accept ss-dir if User-func and Escape-key set Accept-terminated to true perform s3-display-screen exit section end-if move spaces to ws-dir-part-1 ws-dir-part-2 * Have we got a "cd abc def" construction, where "abc" gets * substituted by "def" as per AIX? unstring ws-dir delimited by all spaces into ws-dir-part-1 ws-dir-part-2 if ws-dir-part-2 not = spaces * We've got two strings. Replace all occurrences of part-1 * with part-2. * For some reason, "delimiter in" doesn't work if part-1 is * at the end of ws-dir, although the delimiter does get * removed. Hence the loop end condition is to see if the * unstring has had any effect. perform varying ws-dir-part-1-len from length ws-dir-part-1 by -1 until ws-dir-part-1(ws-dir-part-1-len:1) not = space end-perform perform varying ws-dir-part-2-len from length ws-dir-part-2 by -1 until ws-dir-part-2(ws-dir-part-2-len:1) not = space end-perform move ws-pwd to ws-dir unstring ws-dir delimited by ws-dir-part-1 (1:ws-dir-part-1-len) into ws-dir-1 ws-dir-2 perform with test after until ws-dir-1 = ws-dir move spaces to ws-dir string ws-dir-1 delimited by space ws-dir-part-2(1:ws-dir-part-2-len) delimited by size ws-dir-2 delimited by space into ws-dir unstring ws-dir delimited by ws-dir-part-1 (1:ws-dir-part-1-len) into ws-dir-1 ws-dir-2 end-perform move ws-dir to ws-path-name perform d17-cd exit section end-if * There's just the one string, so cd to that * "~" symbol needs translating. Assume it'll only be at the * start of the string. if ws-dir(1:1) = "~" move ws-dir(2:) to ws-path-name-temp move spaces to ws-dir string "$HOME" ws-path-name-temp delimited by size into ws-dir end-if * If directory name contains "$", it needs translating move zero to ws-dollar-cnt inspect ws-dir tallying ws-dollar-cnt for all "$" if ws-dollar-cnt > zero move spaces to ws-full-name move length ws-full-name to ws-full-name-len move 1 to ws-mode call "CBL_LOCATE_FILE" using by reference ws-dir ws-mode ws-full-spec ws-exist-flag ws-path-flag returning ws-call-status if ws-call-status zero move ws-full-name to ws-dir end-if end-if * We now have a relative or absolute filename move ws-dir to ws-path-name if ws-dir(1:1) = '"' set path-name-quoted to true else set path-name-quoted to false end-if perform d17-cd . c3-change-filemask section. * Get a new filemask display ss-filemask accept ss-filemask evaluate true when (User-func and Escape-key) set Accept-terminated to true perform s3-display-screen when other * Rescan directory with new filemask move ws-filemask to ws-pattern-content perform s1-scan-dir * If there are no files, switch to directory view if file-view and not combi-view and ws-last-file zero set dir-view to true perform s11-set-view end-if perform s3-display-screen end-evaluate . c5-search section. * Search for a string or a regex perform x3-pass-cursor-keys move 0101 to ws-cursor if case-sens-search move "case-sensitive" to ws-disp-case-sens-search else move "case-insensitive" to ws-disp-case-sens-search end-if if unix-os display ss-search-unix accept ss-search-unix else display ss-search-windows accept ss-search-windows end-if * Determine type of search by whether search string has * delimiters - if string starts and ends with the same * character and it's /, ?, or =, it's a regex search, as long * as we're in Unix * At some point I'll try to find out what it takes to do * regexes in Windows set string-found to false perform until string-found or ws-search = spaces or (User-func and Escape-key) evaluate ws-cursor-col when 1 continue *> Repeat last search when 2 set string-search to true when other if ws-search(1:1) = ws-search(ws-cursor-col - 1:1) and (ws-search(1:1) = "/" or "?" or "=") and unix-os set grep-search to true else set string-search to true end-if end-evaluate if string-search perform d1-string-search else perform d3-grep-search end-if if not string-found if unix-os display ss-search-unix accept ss-search-unix else display ss-search-windows accept ss-search-windows end-if move spaces to ws-search-msg end-if end-perform perform x1-intercept-cursor-keys if User-func and Escape-key set Accept-terminated to true *> Don't end if Esc pressed end-if perform s3-display-screen . c7-system-call section. * Use 'call "SYSTEM"' to make a system call * Enable the current filename and pathname to be substituted * and save the other details (date, size, etc) so we can * reposition to the same place whatever the type of sort is * currently being used move ws-line to ws-scr-line-no(ws-view) compute ws-ptr = ws-from(ws-view) + ws-l - 1 if file-view move ws-file-name(ws-ptr) to ws-fname move ws-file-name-len(ws-ptr) to ws-fname-len move ws-file-name-quoted-ind(ws-ptr) to ws-fname-quoted-ind move ws-file-size(ws-ptr) to ws-fname-size move ws-file-date(ws-ptr) to ws-fname-date move ws-file-time(ws-ptr) to ws-fname-time move ws-file-ext(ws-ptr) to ws-fname-ext else move ws-dir-name(ws-ptr) to ws-fname move ws-dir-name-len(ws-ptr) to ws-fname-len move ws-dir-name-quoted-ind(ws-ptr) to ws-fname-quoted-ind move ws-dir-date(ws-ptr) to ws-fname-date move ws-dir-time(ws-ptr) to ws-fname-time end-if if fname-quoted move ws-fname to ws-fname-temp(2:) add 2 to ws-fname-len move "'" to ws-fname-temp(1:1) ws-fname-temp(ws-fname-len:1) move ws-fname-temp to ws-fname end-if * Get the command if this isn't a default action if ws-keypress = "!" perform x3-pass-cursor-keys move spaces to ws-system-err-msg perform with test after until (User-func and Escape-key) or ws-system-text = spaces or (ws-system-text not = spaces and valid-view-cmd) display ss-system-call move spaces to ws-system-err-msg accept ss-system-call if (User-func and Escape-key) or ws-system-text = spaces exit perform end-if move function upper-case(ws-view-cmd-ind) to ws-view-cmd-ind if not valid-view-cmd move " " & "View output must be Y or N" to ws-system-err-msg end-if end-perform perform x1-intercept-cursor-keys end-if * If Escape pressed or no command given, exit if (User-func and Escape-key) or ws-system-text = spaces set Accept-terminated to true *> Don't end if Esc pressed perform s3-display-screen exit section end-if * If we want to view the command output with a file viewer, we * need to set all that up move 1 to ws-shell-ptr move spaces to ws-shell if view-cmd string 'cobrun fileview "<' delimited by size into ws-shell pointer ws-shell-ptr end-if * Do we want to make any substitutions? * First, file name move ws-system-text to ws-shell(ws-shell-ptr:) perform with test after until ws-delim = spaces move spaces to ws-delim unstring ws-shell delimited by "#F" or "#f" into ws-text-1 delimiter ws-delim count in ws-delim-ptr if ws-delim = spaces exit perform end-if move ws-shell(ws-delim-ptr + 3:) to ws-text-1 if ws-delim-ptr = 1 or ws-shell(ws-delim-ptr:1) = space add 1 to ws-delim-ptr move "./" to ws-shell(ws-delim-ptr:) add 2 to ws-delim-ptr else add 1 to ws-delim-ptr end-if move ws-fname(1:ws-fname-len) to ws-shell(ws-delim-ptr:) add ws-fname-len to ws-delim-ptr move ws-text-1 to ws-shell(ws-delim-ptr:) end-perform * Second, path name perform with test after until ws-delim = spaces move spaces to ws-delim unstring ws-shell delimited by "#P" or "#p" into ws-text-1 delimiter ws-delim count in ws-delim-ptr if ws-delim = spaces exit perform end-if move ws-shell(ws-delim-ptr + 3:) to ws-text-1 add 1 to ws-delim-ptr move ws-pwd(1:ws-pwd-len) to ws-shell(ws-delim-ptr:) add ws-pwd-len to ws-delim-ptr move ws-text-1 to ws-shell(ws-delim-ptr:) end-perform * Delimit the command with a low-values byte perform varying ws-text-ptr from length ws-shell by -1 until ws-shell(ws-text-ptr:1) not = space end-perform * May need changes for Windows OS, for redirection of error * messages when viewing output in a viewer if view-cmd *> We want to see errors in viewer move z' 2>&1"' to ws-shell(ws-text-ptr + 1:) else move x'00' to ws-shell(ws-text-ptr + 1:1) end-if display "COBDATA" upon environment-name display ws-cobdata(1:ws-cobdata-len) upon environment-value * Clear the screen down so command will display properly * NB. If running in Animator in a single session, things may * appear wonky display " " at 0101 with erase eos call "SYSTEM" using ws-shell display "COBDATA" upon environment-name display space upon environment-value evaluate true *> Leave outcome visible if required when view-cmd continue when cmd-keypress display "Press any key" accept ws-keypress at 2580 auto set Accept-terminated to true *> Don't end if Esc pressed when ws-cmd-pause > zero move ws-cmd-pause to ws-sleep call "sleep" using by value ws-sleep move zero to ws-sleep end-evaluate * Command may have changed the contents of the directory. Rescan * it and then try to position everything as it was before command * execution. evaluate true when lookfor-active perform d9-lookfor-files perform s3-display-screen when find-active perform d23-find-files perform s3-display-screen when other perform d11-reposition end-evaluate . c9-view-file section. * View a file using fileview or hexview if ws-file-name(ws-arr-ptr) = spaces exit section end-if move ws-line to ws-scr-line-no(ws-view) move ws-file-name(ws-arr-ptr) to ws-fname move ws-file-name-len(ws-arr-ptr) to ws-fname-len move ws-file-name-quoted-ind(ws-arr-ptr) to ws-fname-quoted-ind move function upper-case(ws-file-ext(ws-arr-ptr)) to ws-extension if fname-quoted move ws-fname to ws-fname-temp(2:) add 2 to ws-fname-len move "'" to ws-fname-temp(1:1) ws-fname-temp(ws-fname-len:1) move ws-fname-temp to ws-fname end-if * Need to anchor the filename in the directory structure if ws-fname(1:1) = "/" or ws-fname(1:2) = "./" move ws-fname(1:ws-fname-len) to extfilename else move spaces to extfilename string "./" ws-fname(1:ws-fname-len) delimited by size into extfilename end-if * By default, use fileview or hexview. If the files are too big, * fall back to more or od. evaluate ws-keypress when "V" call "fileview" if return-code = 1 move spaces to ws-shell string "more " ws-fname(1:ws-fname-len) x'00' delimited by size into ws-shell call "SYSTEM" using ws-shell end-if when "H" call "hexview" if return-code = 1 move spaces to ws-shell string "od -Ad -tcx " ws-fname(1:ws-fname-len) x'00' delimited by size into ws-shell call "SYSTEM" using ws-shell end-if end-evaluate perform s3-display-screen . c11-delete-object section. * Delete either a file or a directory move ws-line to ws-scr-line-no(ws-view) if file-view move ws-file-name(ws-arr-ptr) to ws-fname move ws-file-name-len(ws-arr-ptr) to ws-fname-len move ws-file-name-quoted-ind(ws-arr-ptr) to ws-fname-quoted-ind move ws-file-size(ws-arr-ptr) to ws-fname-size move ws-file-date(ws-arr-ptr) to ws-fname-date move ws-file-time(ws-arr-ptr) to ws-fname-time else move ws-dir-name(ws-arr-ptr) to ws-fname move ws-dir-name-len(ws-arr-ptr) to ws-fname-len move ws-dir-name-quoted-ind(ws-arr-ptr) to ws-fname-quoted-ind move ws-dir-date(ws-arr-ptr) to ws-fname-date move ws-dir-time(ws-arr-ptr) to ws-fname-time end-if if ws-fname = spaces *> Should never happen exit section end-if move spaces to ws-msg if file-view and not (combi-view and dir-entry(ws-arr-ptr)) set delete-file to true else set delete-dir to true end-if if delete-file string "Delete file " ws-fname(1:ws-fname-len) "? (Y/N)" delimited by size into ws-msg else string "Delete directory " ws-fname(1:ws-fname-len) "? (Y/N)" delimited by size into ws-msg end-if set ask-y-or-n to true perform x5-display-message perform s3-display-screen * Delete the file if it's in file view * For directory view, we can't use CBL_DELETE_DIR as it only * works on empty directories, so use "rm -rf" to clear it out * and delete it if ws-keypress = "N" exit section end-if if fname-quoted move ws-fname to ws-fname-temp(2:) add 2 to ws-fname-len if delete-file move '"' to ws-fname-temp(1:1) ws-fname-temp(ws-fname-len:1) else move "'" to ws-fname-temp(1:1) ws-fname-temp(ws-fname-len:1) end-if move ws-fname-temp to ws-fname end-if set ask-question to false * Now do the deletion - CBL_DELETE_FILE for a file and * a system call to rm -rf (Unix) or rmdir /s /q (Windows) * for a directory if delete-file call "CBL_DELETE_FILE" using by reference ws-fname if return-code zero move "File deleted OK" to ws-msg evaluate true when del-keypress perform x5-display-message when ws-del-pause > zero move ws-del-pause to ws-sleep perform x5-display-message end-evaluate else move spaces to ws-msg move return-code to ws-file-status if ws-file-status-1 = "9" move ws-file-status-2-num to ws-file-status-2-disp string "Error deleting file - 9/" ws-file-status-2-disp delimited by size into ws-msg else string "Error deleting file - " ws-file-status-disp delimited by size into ws-msg end-if perform x5-display-message end-if else move spaces to ws-shell if unix-os string "rm -rf " ws-fname(1:ws-fname-len) x'00' delimited by size into ws-shell else string "rmdir /s /q " ws-fname(1:ws-fname-len) x'00' delimited by size into ws-shell end-if call "SYSTEM" using ws-shell if return-code zero move "Directory deleted OK" to ws-msg evaluate true when del-keypress perform x5-display-message when ws-del-pause > zero move ws-del-pause to ws-sleep perform x5-display-message end-evaluate else move "Error deleting directory" to ws-msg perform x5-display-message end-if end-if * Rescan directory and try to reposition back where we were perform d11-reposition . c13-cd-to-parent section. * This will need changes for Windows but until I have a Windows * environment to test them in, I'll have to leave it * For Windows root detection, possibly ws-pwd(2:) = ":\" which * allows any mapped drive but might not be sophisticated enough * so possibly tally ws-pwd for ":\" or ":/", whichever way MF * supplies the slashes if ws-pwd = "/" *> We're already in root (Unix) exit section end-if * Derive parent directory from current directory by lopping off * the last bit move ws-pwd to ws-path-name move ws-pwd-quoted-ind to ws-path-name-quoted-ind perform varying ws-ptr from length ws-path-name by -1 until ws-ptr = 1 or ws-path-name(ws-ptr:1) = "/" end-perform if ws-ptr = 1 move "/" to ws-path-name set path-name-quoted to false else move spaces to ws-path-name(ws-ptr:) end-if move ws-from(ws-view) to ws-saved-from perform s7-change-dir move spaces to ws-pattern-content perform s1-scan-dir * If we came from the parent into the child, don't put the * parent on the stack again, just go back one if ws-dir-stack-ptr > 1 and ws-dir-stack-name(ws-dir-stack-ptr - 1) = ws-pwd subtract 1 from ws-dir-stack-ptr else perform s9-push-dir-stack end-if * If there are no files, switch to directory view if file-view and ws-last-file zero set dir-view to true perform s11-set-view end-if perform s3-display-screen . c15-dir-sort-order section. * Change sort priority for directories * If they press Escape, we want to revert to the way it was move ws-line to ws-scr-line-no(ws-view) move ws-dir-sort-priority to ws-saved-dir-sort-priority move space to ws-dir-sort-ok display ss-dir-sort move 1 to ws-field * Accept and validate the fields perform d5-dir-sort-priority with test after until (User-func and Escape-key) or (ws-dir-sort-ok = "Y" and valid-sort) * If they pressed Escape, stay as we are * Only re-sort if things have changed evaluate true when (User-func and Escape-key) set Accept-terminated to true *> Don't end if Esc pressed move ws-saved-dir-sort-priority to ws-dir-sort-priority when ws-dir-sort-priority not = ws-saved-dir-sort-priority perform x7-sort-dirs end-evaluate perform s3-display-screen . c17-file-sort-order section. * Change sort priority * If they press Escape, we want to revert to the way it was move ws-line to ws-scr-line-no(ws-view) move ws-file-sort-priority to ws-saved-file-sort-priority move space to ws-file-sort-ok display ss-file-sort move 1 to ws-field * Accept and validate the fields perform d7-file-sort-priority with test after until (User-func and Escape-key) or (ws-file-sort-ok = "Y" and valid-sort) * If they pressed Escape, stay as we are * Only re-sort if things have changed evaluate true when (User-func and Escape-key) set Accept-terminated to true *> Don't end if Esc pressed move ws-saved-file-sort-priority to ws-file-sort-priority when ws-file-sort-priority not = ws-saved-file-sort-priority perform x8-sort-files end-evaluate perform s3-display-screen . c19-set-default-action section. * Set assorted defaults: * Action to take when enter is pressed in file view * Whether to check if we should exit when Escape is pressed * Whether searches, finds, and lookfors should be case * sensitive or not (set independently of each other) * Whether to confirm deletes * Whether to want return pressed after a successful delete or * just display a message for an interval (and length of interval) move ws-line to ws-scr-line-no(ws-view) move ws-defaults to ws-saved-defaults move space to ws-defaults-ok display ss-defaults move 1 to ws-field * Accept and validate the fields perform d8-defaults with test after until (User-func and Escape-key) or (ws-defaults-ok = "Y" and valid-defaults) * If they pressed Escape, stay as we are * Only re-sort if things have changed if User-func and Escape-key set Accept-terminated to true *> Don't end if Esc pressed move ws-saved-defaults to ws-defaults perform s3-display-screen exit section end-if * If the default action is going to be to make a system call, * find out what the system call is if ws-default-action = "!" move ws-system-text to ws-saved-system-text move ws-view-cmd-ind to ws-saved-view-cmd-ind move ws-default-system-text to ws-system-text move ws-default-view-cmd-ind to ws-view-cmd-ind perform x3-pass-cursor-keys move spaces to ws-system-err-msg perform with test after until (User-func and Escape-key) or ws-system-text = spaces or (ws-system-text not = spaces and valid-view-cmd) display ss-system-call move spaces to ws-system-err-msg accept ss-system-call if (User-func and Escape-key) or ws-system-text = spaces exit perform end-if move function upper-case(ws-view-cmd-ind) to ws-view-cmd-ind if not valid-view-cmd move " " & "View output must be Y or N" to ws-system-err-msg end-if end-perform if not (User-func and Escape-key) move ws-system-text to ws-default-system-text move ws-view-cmd-ind to ws-default-view-cmd-ind end-if perform x1-intercept-cursor-keys end-if set Accept-terminated to true *> Don't end if Esc pressed perform s3-display-screen . c21-edit-file section. * Call vi to edit a file - don't do it if it's a file we know to * be a binary, as that way lies madness if windows-os exit section end-if if ws-file-name(ws-arr-ptr) = spaces exit section end-if move ws-line to ws-scr-line-no(ws-view) move ws-file-name(ws-arr-ptr) to ws-fname move ws-file-name-len(ws-arr-ptr) to ws-fname-len move ws-file-name-quoted-ind(ws-arr-ptr) to ws-fname-quoted-ind move function upper-case(ws-file-ext(ws-arr-ptr)) to ws-extension evaluate ws-extension when "IDY" when "INT" when "GNT" move "Editing a binary file not allowed" to ws-msg perform x5-display-message perform s3-display-screen exit section when spaces * Might be a binary file so give a warning and let them decide * Assume if the name starts with a ".", it's OK if ws-fname(1:1) not = "." move "File may be binary - continue editing? (Y/N)" to ws-msg set ask-y-or-n to true perform x5-display-message if ws-keypress = "N" perform s3-display-screen exit section end-if end-if end-evaluate move spaces to ws-shell if fname-quoted string "vi './" ws-fname(1:ws-fname-len) "'" x'00' delimited by size into ws-shell else string "vi ./" ws-fname(1:ws-fname-len) x'00' delimited by size into ws-shell end-if call "SYSTEM" using ws-shell perform s3-display-screen . c23-email-file section. * Email the selected file to a specified recipient if windows-os exit section end-if if ws-file-name(ws-arr-ptr) = spaces exit section end-if * Set up the required fields move ws-line to ws-scr-line-no(ws-view) move ws-file-name(ws-arr-ptr) to ws-fname move ws-file-name-len(ws-arr-ptr) to ws-fname-len move ws-file-name-quoted-ind(ws-arr-ptr) to ws-fname-quoted-ind move ws-fname to ws-subject move ws-fname-len to ws-subject-len move spaces to ws-to-addr ws-cc-addr perform x3-pass-cursor-keys move spaces to ws-msg * Get email addresses display ss-email-file perform d15-validate-email with test after until (User-func and Escape-key) or (ws-subject not = spaces and valid-to-addr and valid-cc-addr) perform x1-intercept-cursor-keys if User-func and Escape-key set Accept-terminated to true *> Don't end if Esc pressed perform s3-display-screen exit section end-if perform varying ws-to-addr-len from length ws-to-addr by -1 until ws-to-addr(ws-to-addr-len:1) not = space end-perform if ws-cc-addr = spaces move zero to ws-cc-addr-len else perform varying ws-cc-addr-len from length ws-cc-addr by -1 until ws-cc-addr(ws-cc-addr-len:1) not = space end-perform end-if if fname-quoted move ws-fname to ws-fname-temp(2:) add 2 to ws-fname-len move '"' to ws-fname-temp(1:1) ws-fname-temp(ws-fname-len:1) move ws-fname-temp to ws-fname end-if * Shell command uuencodes file and pipes it to mail move spaces to ws-shell string "/usr/bin/uuencode " ws-fname(1:ws-fname-len) " " ws-fname(1:ws-fname-len) " | /usr/bin/mail -s '" ws-subject(1:ws-subject-len) "' " ws-to-addr(1:ws-to-addr-len) " " ws-cc-addr(1:ws-cc-addr-len) x'00' delimited by size into ws-shell call "SYSTEM" using ws-shell perform s3-display-screen . c25-show-details section. * Show details of the selected file or directory. Combine details * already held in table with those returned from ls -l. move ws-line to ws-scr-line-no(ws-view) move spaces to sh-command-line if unix-os if file-view and not (combi-view and dir-entry(ws-arr-ptr)) string "< /usr/bin/ls -Xl " ws-file-name(ws-arr-ptr) delimited by size into sh-command-line else string "< /usr/bin/ls -Xld " ws-dir-name(ws-arr-ptr) delimited by size into sh-command-line end-if else if file-view and not (combi-view and dir-entry(ws-arr-ptr)) string '< dir | find "' ws-file-name(ws-arr-ptr) '"' delimited by size into sh-command-line else string '< dir | find "' ws-dir-name(ws-arr-ptr) '"' delimited by size into sh-command-line end-if end-if open input sh-command-file move spaces to sh-command-rec perform until sh-command-rec not = spaces read sh-command-file at end move "No information found" to sh-command-rec end-read end-perform close sh-command-file * Details are now in sh-command-rec if unix-os * Position the size field so it's right-justified if ws-scr-size(ws-l) zero move length ws-scr-size to ws-scr-ptr else move 1 to ws-scr-ptr inspect ws-scr-size(ws-l) tallying ws-scr-ptr for leading space end-if * Get the owner and group fields unstring sh-command-rec(17:) delimited by all spaces into ws-owner-disp ws-group-disp display ss-unix-details else * For the time being, nothing flash about Windows display ss-windows-details end-if accept ws-keypress at 2580 auto set Accept-terminated to true *> Don't end if Esc pressed perform s3-display-screen . c27-show-pwd section. * Show the current working directory move ws-line to ws-scr-line-no(ws-view) display ss-pwd accept ws-keypress at 2580 auto set Accept-terminated to true *> Don't end if Esc pressed perform s3-display-screen . c29-lookfor section. * Search for a string or a regex in files in current directory move ws-line to ws-scr-line-no(ws-view) perform x3-pass-cursor-keys move 0101 to ws-cursor if case-sens-look move "case-sensitive" to ws-disp-case-sens-look else move "case-insensitive" to ws-disp-case-sens-look end-if display ss-lookfor accept ss-lookfor set file-found to false * Need to sort out two different lookfors, one for Unix (already * done) and a Windows one which presumably would use findstr /m perform until file-found or ws-lookfor = spaces or (User-func and Escape-key) perform d9-lookfor-files if not file-found display ss-lookfor accept ss-lookfor move spaces to ws-search-msg end-if end-perform if file-found move ws-scr-start to ws-scr-line-no(ws-view) set lookfor-active to true end-if perform x1-intercept-cursor-keys if User-func and Escape-key set Accept-terminated to true *> Don't end if Esc pressed end-if perform s3-display-screen . c31-show-command-output section. * $ - show environment variables * % - show directory space usage in this filesystem * @ - as % but in reverse size order * %, @ - allow selection of a directory if (ws-keypress = "%" or "@") and windows-os exit section end-if move ws-line to ws-scr-line-no(ws-view) evaluate ws-keypress when "$" move " Return selected line " keep in this filesystem "$(df $PWD | tail -n1 | awk '{print $7}')" *> Filesystem we're in " 2>/dev/null" delimited by size into extfilename when "@" move spaces to extfilename string "-s " *> Return selected line " keep in this filesystem "$(df $PWD | tail -n1 | awk '{print $7}')" *> Filesystem we're in " 2>/dev/null | sort -k1nr" *> Sort size reverse num delimited by size into extfilename when other exit section end-evaluate display "COBDATA" upon environment-name display ws-cobdata(1:ws-cobdata-len) upon environment-value call "fileview" display "COBDATA" upon environment-name display space upon environment-value * If we're doing a usage display and enter is pressed on a line, the * line number is returned in extlineno and the line itself * in extline. We then use this to cd to the selected directory. The * directory name needs to be extracted from the returned line. if ws-keypress = "$" perform s3-display-screen exit section end-if if extlineno zero *> Nothing selected and not from-view *> Not in nested view perform s3-display-screen exit section end-if set from-view to false if extlineno not zero *> They've selected an entry perform d13-get-selected-path end-if * If nothing was selected or the path wasn't found, find where * we were from the stack and go back there if extlineno zero or ws-path-name = spaces move ws-dir-stack-name(ws-dir-stack-ptr) to ws-path-name move ws-dir-stack-quoted-ind(ws-dir-stack-ptr) to ws-path-name-quoted-ind move ws-from(ws-view) to ws-saved-from perform s7-change-dir move spaces to ws-pattern-content perform s1-scan-dir move ws-dir-stack-view(ws-dir-stack-ptr) to ws-view move ws-dir-stack-from(ws-dir-stack-ptr) to ws-from(ws-view) move ws-dir-stack-line(ws-dir-stack-ptr) to ws-scr-line-no(ws-view) perform s11-set-view perform s3-display-screen exit section end-if * Head off to the selected directory move ws-from(ws-view) to ws-saved-from perform s7-change-dir if return-code zero set from-view to true move ws-keypress to ws-saved-keypress move spaces to ws-pattern-content perform s1-scan-dir perform s9-push-dir-stack if ws-last-file zero set dir-view to true else set file-view to true end-if move ws-view to ws-dir-stack-view(ws-dir-stack-ptr) move 1 to ws-dir-stack-from(ws-dir-stack-ptr) move ws-scr-start-line to ws-dir-stack-line(ws-dir-stack-ptr) perform s11-set-view end-if perform s3-display-screen . c33-go-home section. * Change directory into the home directory move ws-home to ws-path-name move ws-home-quoted-ind to ws-path-name-quoted-ind perform d17-cd . c35-change-dir section. * Change directory into the selected directory if combi-view move ws-file-name(ws-arr-ptr) to ws-path-name move ws-file-name-quoted-ind(ws-arr-ptr) to ws-path-name-quoted-ind else move ws-dir-name(ws-arr-ptr) to ws-path-name move ws-dir-name-quoted-ind(ws-arr-ptr) to ws-path-name-quoted-ind end-if perform d17-cd . c37-cd-to-last-dir section. * Change directory to the previous one on the stack, and decrement * stack pointer if ws-dir-stack-ptr < 2 exit section end-if move ws-view to ws-dir-stack-view(ws-dir-stack-ptr) move ws-from(ws-view) to ws-dir-stack-from(ws-dir-stack-ptr) move ws-line to ws-dir-stack-line(ws-dir-stack-ptr) subtract 1 from ws-dir-stack-ptr perform d19-cd-stack . c39-cd-to-next-dir section. * If there's further directories on the stack, increment pointer * and go to next directory if ws-dir-stack-ptr > c-max-dir-stack or ws-dir-stack-name(ws-dir-stack-ptr + 1) = spaces exit section end-if if ws-dir-stack-ptr > zero move ws-view to ws-dir-stack-view(ws-dir-stack-ptr) move ws-from(ws-view) to ws-dir-stack-from(ws-dir-stack-ptr) move ws-line to ws-dir-stack-line(ws-dir-stack-ptr) end-if add 1 to ws-dir-stack-ptr perform d19-cd-stack . c41-shell-session section. * Use 'call "SYSTEM"' with $SHELL to make a system call * The environment variable SHELL contains the shell invocation move z"$SHELL" to ws-shell display "COBDATA" upon environment-name display ws-cobdata(1:ws-cobdata-len) upon environment-value * Save PS1 value display "PS1" upon environment-name move low-values to ws-ps1 accept ws-ps1 from environment-value perform varying ws-ps1-len from length ws-ps1 by -1 until ws-ps1(ws-ps1-len:1) not = low-values end-perform * Clear the screen down so command will display properly * NB. If running in Animator in a single session, things may * appear wonky display " " at 0101 with erase eos * Change PS1 value display "PS1" upon environment-name display '"filemanager shell > "' upon environment-value perform varying ws-ps1-len from length ws-ps1 by -1 until ws-ps1(ws-ps1-len:1) not = low-values end-perform call "SYSTEM" using ws-shell display "COBDATA" upon environment-name display space upon environment-value display "PS1" upon environment-name display ws-ps1(1:ws-ps1-len) upon environment-value * Directory contents may have changed perform d11-reposition . c43-show-help section. * Show the help screen(s), allowing paging back up from page 2 move ws-line to ws-scr-line-no(ws-view) perform with test after until not User-func or not Page-Up if unix-os display ss-help-unix-1 else display ss-help-windows-1 end-if accept ws-keypress at 2580 auto if unix-os display ss-help-unix-2 else display ss-help-windows-2 end-if accept ws-keypress at 2580 auto nonstd if User-func and Page-Up-nonstd nonstd set Page-Up to true nonstd end-if end-perform set Accept-terminated to true *> Don't end if Esc pressed perform s3-display-screen . c45-show-dir-tree section. * + - show tree structure, generated with program filetree move ws-line to ws-scr-line-no(ws-view) display "COBDATA" upon environment-name display ws-cobdata(1:ws-cobdata-len) upon environment-value move z'cobrun fileindex " Don't end if Esc pressed end-if if rename-done perform d11-reposition else perform s3-display-screen end-if . c49-show-dir-stack section. * Write the stack out to a heap and view it with heapview, * allowing a different entry to be selected if required move ws-line to ws-scr-line-no(ws-view) call "CBL_OPEN_VFILE" using by reference ws-vfile-id ws-vfile-status returning ws-call-status if ws-vfile-status(1:1) not = "0" exit section end-if move zero to ws-vfile-offset ws-vfile-lines perform varying ws-ptr from 1 by 1 until ws-ptr > c-max-dir-stack or ws-dir-stack-name(ws-ptr) = spaces move ws-dir-stack-name(ws-ptr) to ws-vfile-rec perform varying ws-vfile-rec-len from length ws-vfile-rec by -1 until ws-vfile-rec(ws-vfile-rec-len:1) not = space end-perform if ws-ptr = ws-dir-stack-ptr move " **" to ws-vfile-rec(ws-vfile-rec-len + 1:) add 3 to ws-vfile-rec-len end-if compute ws-vfile-buff-len = c-vfile-reclen-len + ws-vfile-rec-len call "CBL_WRITE_VFILE" using by value ws-vfile-id ws-vfile-offset ws-vfile-buff-len by reference ws-vfile-entry add ws-vfile-buff-len to ws-vfile-offset add 1 to ws-vfile-lines end-perform move "Directory stack" to ws-heap-title call "heapview" using ws-heap-title ws-vfile-id ws-vfile-status ws-vfile-lines ws-vfile-offset "Y" ws-heap-entry call "CBL_CLOSE_VFILE" using by value ws-vfile-id if ws-heap-entry not zero and ws-heap-entry not = ws-dir-stack-ptr move ws-view to ws-dir-stack-view(ws-dir-stack-ptr) move ws-from(ws-view) to ws-dir-stack-from(ws-dir-stack-ptr) move ws-line to ws-dir-stack-line(ws-dir-stack-ptr) move ws-heap-entry to ws-dir-stack-ptr perform d19-cd-stack else perform s3-display-screen end-if . c51-find section. * Look for a file by name within the directory structure * descending from the current position. Wildcards are allowed. * Case sensitivity of find can be selected in defaults screen move ws-line to ws-scr-line-no(ws-view) perform x3-pass-cursor-keys move 0101 to ws-cursor if case-sens-find move "case-sensitive" to ws-disp-case-sens-find else move "case-insensitive" to ws-disp-case-sens-find end-if display ss-find accept ss-find set file-found to false perform until file-found or ws-find = spaces or (User-func and Escape-key) perform d23-find-files if not file-found display ss-find accept ss-find move spaces to ws-search-msg end-if end-perform if file-found move ws-scr-start to ws-scr-line-no(ws-view) set lookfor-active to true end-if perform x1-intercept-cursor-keys if User-func and Escape-key set Accept-terminated to true *> Don't end if Esc pressed end-if perform s3-display-screen . c53-tail-file section. * Execute a tail -f on the selected file move ws-line to ws-scr-line-no(ws-view) move spaces to ws-shell string "/usr/bin/clear;/usr/bin/tail -f " ws-file-name(ws-arr-ptr)(1:ws-file-name-len(ws-arr-ptr)) x'00' delimited by size into ws-shell call "SYSTEM" using ws-shell if User-func and Escape-key set Accept-terminated to true *> Don't end if Esc pressed end-if perform s3-display-screen . d1-string-search section. * Go down array, checking each line for the search string * Case sensitivity of search can be selected in defaults screen evaluate true when ws-cursor-col > 1 compute ws-str-len = ws-cursor-col - 1 when ws-str-len > zero continue when other perform varying ws-str-len from length ws-search by -1 until ws-search(ws-str-len:1) not = spaces end-perform end-evaluate move spaces to ws-delim * Take into account the cursor position when deciding where to * start search from compute ws-start-line = ws-from(ws-view) + ws-l * ws-start-line = (ws-from(ws-view) + ws-l) - 1 set search-wrapped to false * Use unstring with the delimiter clause - if we finish up with a * value in the delimiter field, we've found it in the string perform varying ws-ptr from ws-start-line by 1 until string-found or (search-wrapped and ws-ptr > ws-start-line) if ws-ptr > ws-last-line(ws-view) and not search-wrapped move zero to ws-ptr set search-wrapped to true exit perform cycle end-if if file-view if case-sens-search unstring ws-file-name(ws-ptr) delimited by ws-search(1:ws-str-len) into ws-dummy delimiter ws-delim else unstring function upper-case(ws-file-name(ws-ptr)) delimited by function upper-case( ws-search(1:ws-str-len)) into ws-dummy delimiter ws-delim end-if else if case-sens-search unstring ws-dir-name(ws-ptr) delimited by ws-search(1:ws-str-len) into ws-dummy delimiter ws-delim else unstring function upper-case(ws-dir-name(ws-ptr)) delimited by function upper-case( ws-search(1:ws-str-len)) into ws-dummy delimiter ws-delim end-if end-if if ws-delim not = spaces set string-found to true end-if end-perform if not string-found compute ws-search-msg-start = (80 - length "Not found") / 2 move "Not found" to ws-search-msg(ws-search-msg-start:) exit section end-if * Can we show this line on the current page? If so, don't move * forward, just change highlight position. Don't forget that ws-ptr * will have incremented at the loop end. subtract 1 from ws-ptr if (ws-ptr > ws-from(ws-view) and (ws-ptr - ws-from(ws-view)) < c-scr-lines) compute ws-scr-line-no(ws-view) = ws-scr-start-line + (ws-ptr - ws-from(ws-view)) else move ws-ptr to ws-from(ws-view) move ws-scr-start-line to ws-scr-line-no(ws-view) end-if . d3-grep-search section. * Go down array, using regcomp and regexec on each line to * check for the search string * Search pattern in a null-terminated string * Lose the first and last characters of the search string if ws-cursor-col > 1 compute ws-str-len = ws-cursor-col - 3 move ws-search(2:ws-str-len) to ws-search-regexp add 1 to ws-str-len move x'00' to ws-search-regexp(ws-str-len:1) end-if * Compile regular expression * No need to return position of matches move reg-nosub to ws-c-flags * Case sensitive? if not case-sens-search add reg-icase to ws-c-flags end-if call "regcomp" using by reference ws-regex-t ws-search-regexp (1:ws-str-len) by value ws-c-flags returning ws-return * Is it a valid regex? if ws-return not zero move spaces to ws-error move length ws-error to ws-err-len call "regerror" using by value ws-return by reference ws-regex-t ws-error by value ws-err-len returning ws-regerror-len subtract 1 from ws-regerror-len compute ws-search-msg-start = (80 - (ws-regerror-len + length "Invalid search regex: ")) / 2 string "Invalid search regex: " ws-error(1:ws-regerror-len) delimited by size into ws-search-msg(ws-search-msg-start:) exit section end-if * Take into account the cursor position when deciding where to * start search from compute ws-start-line = ws-from(ws-view) + ws-l * ws-start-line = (ws-from(ws-view) + ws-l) - 1 set search-wrapped to false * Null-terminate each line, then use regexec to look for the * compiled regular expression perform varying ws-ptr from ws-start-line by 1 until string-found or (search-wrapped and ws-ptr > ws-start-line) if ws-ptr > ws-last-line(ws-view) and not search-wrapped move zero to ws-ptr set search-wrapped to true exit perform cycle end-if if file-view move ws-file-name(ws-ptr) to ws-grep-line else move ws-dir-name(ws-ptr) to ws-grep-line end-if perform varying ws-str-len from length ws-grep-line by -1 until ws-grep-line(ws-str-len:1) not = space end-perform move x'00' to ws-grep-line(ws-str-len + 1:1) call "regexec" using by reference ws-regex-t ws-grep-line by value zero by reference ws-dummy by value ws-e-flags returning ws-return if ws-return zero set string-found to true end-if end-perform if not string-found compute ws-search-msg-start = (80 - length "Not found") / 2 move "Not found" to ws-search-msg(ws-search-msg-start:) exit section end-if * Can we show this line on the current page? If so, don't move * forward, just change highlight position. Don't forget that ws-ptr * will have been incremented at the end of the loop. subtract 1 from ws-ptr if (ws-ptr > ws-from(ws-view) and (ws-ptr - ws-from(ws-view)) < c-scr-lines) compute ws-scr-line-no(ws-view) = ws-scr-start-line + (ws-ptr - ws-from(ws-view)) else move ws-ptr to ws-from(ws-view) move ws-scr-start-line to ws-scr-line-no(ws-view) end-if . d5-dir-sort-priority section. * Get the directory sort priority fields move c-dir-sort-ok-field to ws-last-field * This should never happen but just in case... if ws-field < 1 or > ws-last-field move 1 to ws-field end-if * Accept whichever field we're pointing to evaluate ws-field when c-dir-sort-name-field accept ss-dir-sort-name move function upper-case(ws-dir-name-priority) to ws-dir-name-priority display ss-dir-sort-name when c-dir-sort-case-sens-field accept ss-dir-sort-case-sens move function upper-case(ws-dir-sort-case-sens) to ws-dir-sort-case-sens display ss-dir-sort-case-sens when c-dir-sort-date-field accept ss-dir-sort-date move function upper-case(ws-dir-date-priority) to ws-dir-date-priority display ss-dir-sort-date when c-dir-sort-ok-field accept ss-dir-sort-ok move function upper-case(ws-dir-sort-ok) to ws-dir-sort-ok display ss-dir-sort-ok end-evaluate * Have they pressed Escape? if User-func and Escape-key exit section end-if * Now validate what's been input so far set valid-sort to true evaluate ws-field when c-dir-sort-name-field if not valid-dir-name-priority move "Name priority must be 'A', 'D', or space" to ws-msg set valid-sort to false end-if when c-dir-sort-case-sens-field if not valid-dir-sort-case-sens move "Case sensitivity must be 'Y', 'N', or space" to ws-msg set valid-sort to false end-if * allow space with sort by name if we're going back to sort by * name field if ws-dir-name-priority not = space and ws-dir-sort-case-sens = space and (not ADIS-key or not (cursor-left or cursor-up)) move "Case sensitivity must be 'Y' or 'N'" to ws-msg set valid-sort to false end-if when c-dir-sort-date-field if not valid-dir-date-priority move "Date priority must be 'A', 'D', or space" to ws-msg set valid-sort to false end-if when c-dir-sort-ok-field if not valid-dir-sort-ok move "Answer must be 'Y', 'N', or space" to ws-msg set valid-sort to false end-if end-evaluate * Have they not answered "Y" to "All OK?"? if valid-sort and ws-field = ws-last-field and (ws-dir-sort-ok = "N" or space) move 1 to ws-field exit section end-if if valid-sort and ws-dir-sort-ok = "Y" * How many fields have they filled in? * Allow for the fact that sort-ok is filled in move zero to ws-space-cnt inspect ws-dir-sort-priority(1:ws-last-field) tallying ws-space-cnt for all space evaluate (ws-last-field - ws-space-cnt) when 1 move "A" to ws-dir-name-priority move "Y" to ws-dir-sort-case-sens when 2 continue when other move "Select only one to sort on (default name)" to ws-msg move 1 to ws-field set valid-sort to false end-evaluate if ws-dir-name-priority not = space and ws-dir-sort-case-sens = space move "Case sensitivity must be 'Y' or 'N'" to ws-msg set valid-sort to false end-if end-if * If it's invalid, tell them and go round again if not valid-sort move space to ws-dir-sort-ok set ask-question to false perform x5-display-message display ss-dir-sort exit section end-if perform s13-evaluate-next-field . d7-file-sort-priority section. * Get the file sort priority fields move c-file-sort-ok-field to ws-last-field * This should never happen but just in case... if ws-field < 1 or > ws-last-field move 1 to ws-field end-if * Accept whichever field we're pointing to evaluate ws-field when c-file-sort-name-field accept ss-file-sort-name move function upper-case(ws-file-name-priority) to ws-file-name-priority display ss-file-sort-name when c-file-sort-case-sens-field accept ss-file-sort-case-sens move function upper-case(ws-file-sort-case-sens) to ws-file-sort-case-sens display ss-file-sort-case-sens when c-file-sort-type-field accept ss-file-sort-type move function upper-case(ws-file-type-priority) to ws-file-type-priority display ss-file-sort-type when c-file-sort-date-field accept ss-file-sort-date move function upper-case(ws-file-date-priority) to ws-file-date-priority display ss-file-sort-date when c-file-sort-size-field accept ss-file-sort-size move function upper-case(ws-file-size-priority) to ws-file-size-priority display ss-file-sort-size when c-file-sort-ok-field accept ss-file-sort-ok move function upper-case(ws-file-sort-ok) to ws-file-sort-ok display ss-file-sort-ok end-evaluate * Have they pressed Escape? if User-func and Escape-key exit section end-if * Now validate what's been input so far set valid-sort to true evaluate ws-field when c-file-sort-name-field if not valid-file-name-priority move "Name priority must be 'A', 'D', or space" to ws-msg set valid-sort to false end-if when c-file-sort-case-sens-field if not valid-file-sort-case-sens move "Case sensitivity must be 'Y', 'N', or space" to ws-msg set valid-sort to false end-if * allow space with sort by name if we're going back to sort by * name field if ws-file-name-priority not = space and ws-file-sort-case-sens = space and (not ADIS-key or not (cursor-left or cursor-up)) move "Case sensitivity must be 'Y' or 'N'" to ws-msg set valid-sort to false end-if when c-file-sort-type-field if not valid-file-type-priority move "Type priority must be 'A', 'D', or space" to ws-msg set valid-sort to false end-if when c-file-sort-date-field if not valid-file-date-priority move "Date priority must be 'A', 'D', or space" to ws-msg set valid-sort to false end-if when c-file-sort-size-field if not valid-file-size-priority move "Size priority must be 'A', 'D', or space" to ws-msg set valid-sort to false end-if when c-file-sort-ok-field if not valid-file-sort-ok move "Answer must be 'Y', 'N', or space" to ws-msg set valid-sort to false end-if end-evaluate * Have they not answered "Y" to "All OK?"? if valid-sort and ws-field = ws-last-field and (ws-file-sort-ok = "N" or space) move 1 to ws-field exit section end-if if valid-sort and ws-file-sort-ok = "Y" * How many fields have they filled in? * Allow for the fact that sort-ok is filled in move zero to ws-space-cnt inspect ws-file-sort-priority(1:ws-last-field) tallying ws-space-cnt for all space if (ws-last-field - ws-space-cnt) > 2 move "Select only one to sort on (default name)" to ws-msg move 1 to ws-field set valid-sort to false end-if evaluate (ws-last-field - ws-space-cnt) when 1 move "A" to ws-file-name-priority move "Y" to ws-file-sort-case-sens when 2 continue when other move "Select only one to sort on (default name)" to ws-msg move 1 to ws-field set valid-sort to false end-evaluate if ws-file-name-priority not = space and ws-file-sort-case-sens = space move "Case sensitivity must be 'Y' or 'N'" to ws-msg set valid-sort to false end-if end-if * If it's invalid, tell them and go round again if not valid-sort move space to ws-file-sort-ok set ask-question to false perform x5-display-message display ss-file-sort exit section end-if perform s13-evaluate-next-field . d8-defaults section. * Get defaults fields move c-default-ok-field to ws-last-field * This should never happen but just in case... if ws-field < 1 or > ws-last-field move 1 to ws-field end-if * Accept whichever field we're pointing to evaluate ws-field when c-default-exit-field accept ss-check-exit move function upper-case(ws-check-exit-ind) to ws-check-exit-ind display ss-check-exit when c-default-action-field accept ss-default-action move function upper-case(ws-default-action) to ws-default-action display ss-default-action when c-default-search-field accept ss-case-sens-search move function upper-case(ws-case-sens-search-ind) to ws-case-sens-search-ind display ss-case-sens-search when c-default-look-field accept ss-case-sens-look move function upper-case(ws-case-sens-look-ind) to ws-case-sens-look-ind display ss-case-sens-look when c-default-find-field accept ss-case-sens-find move function upper-case(ws-case-sens-find-ind) to ws-case-sens-find-ind display ss-case-sens-look when c-default-del-key-field accept ss-del-keypress move function upper-case(ws-del-keypress-ind) to ws-del-keypress-ind display ss-del-keypress when c-default-del-pause-field accept ss-del-pause when c-default-cmd-key-field accept ss-cmd-keypress move function upper-case(ws-cmd-keypress-ind) to ws-cmd-keypress-ind display ss-cmd-keypress when c-default-cmd-pause-field accept ss-cmd-pause when c-default-ok-field accept ss-defaults-ok move function upper-case(ws-defaults-ok) to ws-defaults-ok display ss-defaults-ok end-evaluate * Have they pressed Escape? if User-func and Escape-key exit section end-if * Now validate what's been input so far evaluate true when not valid-check-exit move "Confirm exit must be 'Y' or 'N'" to ws-msg set valid-defaults to false when not valid-default-action move "Default action must be 'V', 'H', 'E', or '!'" to ws-msg set valid-defaults to false when not valid-case-sens-search move "Case sensitive search must be 'Y' or 'N'" to ws-msg set valid-defaults to false when not valid-case-sens-look move "Case sensitive lookfor must be 'Y' or 'N'" to ws-msg set valid-defaults to false when not valid-case-sens-find move "Case sensitive find must be 'Y' or 'N'" to ws-msg set valid-defaults to false when not valid-del-keypress move "Delete keypress must be 'Y' or 'N'" to ws-msg set valid-defaults to false when not valid-defaults-ok move "Answer must be 'Y', 'N', or space" to ws-msg set valid-defaults to false when other set valid-defaults to true end-evaluate * Have they not answered "Y" to "All OK?"? if valid-sort and ws-field = ws-last-field and (ws-file-sort-ok = "N" or space) move 1 to ws-field exit section end-if * If it's invalid, tell them and go round again if not valid-defaults move space to ws-defaults-ok set ask-question to false perform x5-display-message display ss-defaults exit section end-if perform s13-evaluate-next-field . d9-lookfor-files section. * Set up a command line to do greps on all files and return list * of files containing the regex evaluate true when ws-cursor-col > 1 compute ws-str-len = ws-cursor-col - 1 when ws-str-len > zero continue when other perform varying ws-str-len from length ws-lookfor by -1 until ws-lookfor(ws-str-len:1) not = spaces end-perform end-evaluate move zero to ws-lookfor-escaped-len perform varying ws-lookfor-ptr from 1 by 1 until ws-lookfor-ptr > ws-str-len if ws-lookfor(ws-lookfor-ptr:1) = '"' add 1 to ws-lookfor-escaped-len move "\" to ws-lookfor-escaped (ws-lookfor-escaped-len:1) end-if add 1 to ws-lookfor-escaped-len move ws-lookfor(ws-lookfor-ptr:1) to ws-lookfor-escaped (ws-lookfor-escaped-len:1) end-perform move spaces to sh-command-line if unix-os if not case-sens-look move "-i" to ws-case-sens-flag else move spaces to ws-case-sens-flag end-if if ws-file-sort-case-sens = "N" move "en-GB" to ws-sort-seq else move "C" to ws-sort-seq end-if string '< /usr/bin/grep -l ' delimited by size ws-case-sens-flag delimited by space ' -e "' ws-lookfor-escaped(1:ws-lookfor-escaped-len) '" ' ws-pattern-content(1:ws-pattern-len) ' 2>/dev/null | LANG=' delimited by size ws-sort-seq delimited by space ' sort' delimited by size into sh-command-line else if not case-sens-look move "/i" to ws-case-sens-flag else move spaces to ws-case-sens-flag end-if string '< findstr /m ' delimited by size ws-case-sens-flag delimited by space ' "' ws-lookfor-escaped(1:ws-lookfor-escaped-len) '" ' ws-pattern-content(1:ws-pattern-len) into sh-command-line end-if open input sh-command-file read sh-command-file at end close sh-command-file compute ws-search-msg-start = (80 - length "No files found") / 2 move "No files found" to ws-search-msg(ws-search-msg-start:) move ws-last-line(1) to ws-last-file exit section end-read move zero to ws-last-file perform until end-of-file call "CBL_CHECK_FILE_EXIST" using by reference sh-command-rec ws-fe-param returning ws-call-status if ws-call-status not zero read sh-command-file at end continue end-read exit perform cycle end-if set file-found to true add 1 to ws-last-file if sh-command-rec(1:) = '"' move sh-command-rec(2:) to ws-file-name(ws-last-file) perform varying ws-ptr from length ws-file-name by -1 until ws-file-name(ws-last-file)(ws-ptr:1) = '"' end-perform move space to ws-file-name(ws-last-file)(ws-ptr:1) compute ws-file-name-len(ws-last-file) = ws-ptr - 1 set file-name-quoted(ws-last-file) to true else move sh-command-rec to ws-file-name(ws-last-file) perform varying ws-ptr from length ws-file-name by -1 until ws-file-name(ws-last-file)(ws-ptr:1) not = space end-perform move ws-ptr to ws-file-name-len(ws-last-file) set file-name-quoted(ws-last-file) to false end-if move function upper-case(ws-file-name(ws-last-file)) to ws-file-name-uc(ws-last-file) perform varying ws-ptr from ws-ptr by -1 until ws-ptr < 2 or ws-file-name(ws-last-file)(ws-ptr:1) = "." end-perform if ws-ptr not < 2 move ws-file-name(ws-last-file)(ws-ptr + 1:) to ws-file-ext(ws-last-file) else move spaces to ws-file-ext(ws-last-file) end-if move function upper-case(ws-file-ext(ws-last-file)) to ws-file-ext-uc(ws-last-file) move cblte-fe-filesize to ws-file-size(ws-last-file) compute ws-file-date(ws-last-file) = (cblte-fe-year * 10000) + (cblte-fe-month * 100) + cblte-fe-day compute ws-file-time(ws-last-file) = (cblte-fe-hours * 100) + cblte-fe-minutes read sh-command-file at end continue end-read end-perform close sh-command-file if not file-found compute ws-search-msg-start = (80 - length "No files found") / 2 move "No files found" to ws-search-msg(ws-search-msg-start:) move ws-last-line(1) to ws-last-file else set file-view to true move 1 to ws-from(ws-view) move ws-last-file to ws-last-line(ws-view) end-if . d11-reposition section. * Try and put everything back to where it was. Save the current * top line, rescan, then work out which line to highlight move ws-from(ws-view) to ws-saved-from perform s1-scan-dir * Can we find the file again? If not, get the next one on, * depending on how it's been sorted if file-view perform varying ws-ptr from 1 by 1 until ws-ptr > ws-last-file or ws-file-name(ws-ptr) = ws-fname end-perform if ws-ptr > ws-last-file perform e1-find-next-file end-if else perform varying ws-ptr from 1 by 1 until ws-ptr > ws-last-dir or ws-dir-name(ws-ptr) = ws-fname end-perform if ws-ptr > ws-last-dir perform e3-find-next-dir end-if end-if * The file/directory will have been removed if we did a delete * or our system command changed the name, hence checking for * the name being not < * Set the start of the screen move ws-saved-from to ws-from(ws-view) * Set the highlight line compute ws-scr-line-no(ws-view) = ws-scr-start-line + (ws-ptr - ws-saved-from) perform s3-display-screen . d13-get-selected-path section. * Find the selected path returned in extline move 1 to ws-ptr unstring extline delimited by all spaces into ws-dummy pointer ws-ptr move extline(ws-ptr:) to ws-path-name set path-name-quoted to true . d15-validate-email section. accept ss-email-file move spaces to ws-msg if (User-func and Escape-key) exit section end-if if ws-subject = spaces move "No subject given" to ws-msg perform x9-centre-msg display ss-email-file exit section end-if * Evaluate environment variables if ws-to-addr(1:1) = "$" display ws-to-addr(2:) upon environment-name accept ws-env-addr from environment-value move ws-env-addr to ws-valemail-addr else move ws-to-addr to ws-valemail-addr end-if call "valemail" using ws-valemail-params if not email-valid string "To email: " ws-valemail-err-msg delimited by size into ws-msg perform x9-centre-msg set valid-to-addr to false display ss-email-file exit section else set valid-to-addr to true move ws-valemail-addr to ws-to-addr end-if if ws-cc-addr = spaces set valid-cc-addr to true exit section end-if if ws-cc-addr(1:1) = "$" display ws-cc-addr(2:) upon environment-name accept ws-env-addr from environment-value move ws-env-addr to ws-valemail-addr else move ws-cc-addr to ws-valemail-addr end-if call "valemail" using ws-valemail-params if not email-valid string "Cc email: " ws-valemail-err-msg delimited by size into ws-msg perform x9-centre-msg set valid-cc-addr to false display ss-email-file exit section end-if set valid-cc-addr to true move ws-valemail-addr to ws-cc-addr . d17-cd section. move ws-from(ws-view) to ws-saved-from perform s7-change-dir move spaces to ws-pattern-content perform s1-scan-dir perform s9-push-dir-stack evaluate true when (ws-last-dir zero and dir-view) move ws-line to ws-scr-line-no(ws-view) set file-view to true when (ws-last-file zero and file-view) move ws-line to ws-scr-line-no(ws-view) set dir-view to true end-evaluate perform s11-set-view perform s3-display-screen . d19-cd-stack section. move ws-dir-stack-name(ws-dir-stack-ptr) to ws-path-name move ws-dir-stack-quoted-ind(ws-dir-stack-ptr) to ws-path-name-quoted-ind move ws-from(ws-view) to ws-saved-from perform s7-change-dir move spaces to ws-pattern-content perform s1-scan-dir move ws-dir-stack-view(ws-dir-stack-ptr) to ws-view move ws-dir-stack-from(ws-dir-stack-ptr) to ws-from(ws-view) move ws-dir-stack-line(ws-dir-stack-ptr) to ws-scr-line-no(ws-view) evaluate true when (ws-last-dir zero and dir-view) move ws-line to ws-scr-line-no(ws-view) set file-view to true when (ws-last-file zero and file-view) move ws-line to ws-scr-line-no(ws-view) set dir-view to true end-evaluate perform s11-set-view perform s3-display-screen . d21-file-rename section. move zero to ws-solidus-cnt inspect ws-new-filename tallying ws-solidus-cnt for all "/" if ws-solidus-cnt not zero compute ws-rename-msg-start = (80 - length "'/' not allowed") / 2 move "'/' not allowed" to ws-rename-msg(ws-rename-msg-start:) exit section end-if call "CBL_CHECK_FILE_EXIST" using by reference ws-new-filename ws-fe-param returning ws-call-status if ws-call-status zero string "Overwrite file " delimited by size ws-new-filename delimited by space "? (Y/N)" delimited by size into ws-msg set ask-y-or-n to true perform x5-display-message if ws-keypress = "N" exit section end-if call "CBL_DELETE_FILE" using by reference ws-new-filename returning ws-call-status end-if call "CBL_RENAME_FILE" using by reference ws-fname ws-new-filename returning ws-call-status set rename-done to true . d23-find-files section. * Set up a command line to do a find from current directory * and return list of found files evaluate true when ws-cursor-col > 1 compute ws-find-len = ws-cursor-col - 1 when ws-find-len > zero continue when other perform varying ws-find-len from length ws-find by -1 until ws-find(ws-find-len:1) not = spaces end-perform end-evaluate move spaces to ws-findexp move 1 to ws-findexp-ptr perform varying ws-find-ptr from 1 by 1 until ws-find-ptr > ws-find-len evaluate ws-find(ws-find-ptr:1) when "*" when "?" if (ws-find-ptr = 1 or ws-find(ws-find-ptr - 1:1) not = "\") move "\" to ws-findexp(ws-findexp-ptr:1) add 1 to ws-findexp-ptr end-if move ws-find(ws-find-ptr:1) to ws-findexp(ws-findexp-ptr:1) add 1 to ws-findexp-ptr when "a" through "z" when "A" through "Z" if not case-sens-find move "[" to ws-findexp(ws-findexp-ptr:1) add 1 to ws-findexp-ptr move function lower-case(ws-find(ws-find-ptr:1)) to ws-findexp(ws-findexp-ptr:1) add 1 to ws-findexp-ptr move function upper-case(ws-find(ws-find-ptr:1)) to ws-findexp(ws-findexp-ptr:1) add 1 to ws-findexp-ptr move "]" to ws-findexp(ws-findexp-ptr:1) add 1 to ws-findexp-ptr else move ws-find(ws-find-ptr:1) to ws-findexp(ws-findexp-ptr:1) add 1 to ws-findexp-ptr end-if when other move ws-find(ws-find-ptr:1) to ws-findexp(ws-findexp-ptr:1) add 1 to ws-findexp-ptr end-evaluate end-perform subtract 1 from ws-findexp-ptr move spaces to sh-command-line string "< /usr/bin/find . -name " ws-findexp(1:ws-findexp-ptr) " 2>/dev/null" delimited by size into sh-command-line open input sh-command-file read sh-command-file at end close sh-command-file compute ws-search-msg-start = (80 - length "No files found") / 2 move "No files found" to ws-search-msg(ws-search-msg-start:) move ws-last-line(1) to ws-last-file exit section end-read move zero to ws-last-file perform until end-of-file call "CBL_CHECK_FILE_EXIST" using by reference sh-command-rec ws-fe-param returning ws-call-status if ws-call-status not zero read sh-command-file at end continue end-read exit perform cycle end-if set file-found to true add 1 to ws-last-file if sh-command-rec(1:) = '"' move sh-command-rec(2:) to ws-file-name(ws-last-file) perform varying ws-ptr from length ws-file-name by -1 until ws-file-name(ws-last-file)(ws-ptr:1) = '"' end-perform move space to ws-file-name(ws-last-file)(ws-ptr:1) set file-name-quoted(ws-last-file) to true compute ws-file-name-len(ws-last-file) = ws-ptr - 1 else move sh-command-rec to ws-file-name(ws-last-file) perform varying ws-ptr from length ws-file-name by -1 until ws-file-name(ws-last-file)(ws-ptr:1) not = space end-perform move ws-ptr to ws-file-name-len(ws-last-file) set file-name-quoted(ws-last-file) to false end-if set file-entry(ws-last-file) to true move function upper-case(ws-file-name(ws-last-file)) to ws-file-name-uc(ws-last-file) perform varying ws-ptr from ws-file-name-len(ws-last-file) by -1 until ws-ptr < 2 or ws-file-name(ws-last-file)(ws-ptr:1) = "." end-perform if ws-ptr not < 2 move ws-file-name(ws-last-file)(ws-ptr + 1:) to ws-file-ext(ws-last-file) else move spaces to ws-file-ext(ws-last-file) end-if move function upper-case(ws-file-ext(ws-last-file)) to ws-file-ext-uc(ws-last-file) move cblte-fe-filesize to ws-file-size(ws-last-file) compute ws-file-date(ws-last-file) = (cblte-fe-year * 10000) + (cblte-fe-month * 100) + cblte-fe-day compute ws-file-time(ws-last-file) = (cblte-fe-hours * 100) + cblte-fe-minutes read sh-command-file at end continue end-read end-perform close sh-command-file if not file-found compute ws-search-msg-start = (80 - length "No files found") / 2 move "No files found" to ws-search-msg(ws-search-msg-start:) move ws-last-line(1) to ws-last-file else set file-view to true move 1 to ws-view move 1 to ws-from(1) move ws-last-file to ws-last-line(1) end-if . e1-find-next-file section. perform varying ws-ptr from 1 by 1 until ws-ptr > ws-last-file evaluate true when ws-file-name-priority = "A" if (ws-file-sort-case-sens = "N" and ws-file-name-uc(ws-ptr) > function upper-case(ws-fname)) or (ws-file-sort-case-sens not = "N" and ws-file-name(ws-ptr) > ws-fname) exit perform end-if when ws-file-name-priority = "D" if (ws-file-sort-case-sens = "N" and ws-file-name-uc(ws-ptr) < function upper-case(ws-fname)) or (ws-file-sort-case-sens not = "N" and ws-file-name(ws-ptr) < ws-fname) exit perform end-if when ws-file-type-priority = "A" if (ws-file-sort-case-sens = "N" and ws-file-ext-uc(ws-ptr) > function upper-case(ws-fname-ext)) or (ws-file-sort-case-sens not = "N" and ws-file-ext(ws-ptr) > ws-fname-ext) exit perform end-if when ws-file-type-priority = "D" if (ws-file-sort-case-sens = "N" and ws-file-ext-uc(ws-ptr) > function upper-case(ws-fname-ext)) or (ws-file-sort-case-sens not = "N" and ws-file-ext(ws-ptr) > ws-fname-ext) exit perform end-if when ws-file-date-priority = "A" if ws-file-date(ws-ptr) > ws-fname-date or (ws-file-date(ws-ptr) = ws-fname-date and ws-file-time(ws-ptr) > ws-fname-time) exit perform end-if when ws-file-date-priority = "D" if ws-file-date(ws-ptr) < ws-fname-date or (ws-file-date(ws-ptr) = ws-fname-date and ws-file-time(ws-ptr) < ws-fname-time) exit perform end-if when ws-file-size-priority = "A" if ws-file-size(ws-ptr) > ws-fname-size exit perform end-if when ws-file-size-priority = "D" if ws-file-size(ws-ptr) < ws-fname-size exit perform end-if end-evaluate end-perform if ws-ptr > ws-last-file move ws-last-file to ws-ptr end-if . e3-find-next-dir section. perform varying ws-ptr from 1 by 1 until ws-ptr > ws-last-dir evaluate true when ws-dir-name-priority = "A" if (ws-dir-sort-case-sens = "N" and ws-dir-name-uc(ws-ptr) > function upper-case(ws-fname)) or (ws-dir-sort-case-sens not = "N" and ws-dir-name(ws-ptr) > ws-fname) exit perform end-if when ws-dir-name-priority = "D" if (ws-dir-sort-case-sens = "N" and ws-dir-name-uc(ws-ptr) < function upper-case(ws-fname)) or (ws-dir-sort-case-sens not = "N" and ws-dir-name(ws-ptr) < ws-fname) exit perform end-if when ws-dir-date-priority = "A" if ws-dir-date(ws-ptr) > ws-fname-date or (ws-dir-date(ws-ptr) = ws-fname-date and ws-dir-time(ws-ptr) > ws-fname-time) exit perform end-if when ws-dir-date-priority = "D" if ws-dir-date(ws-ptr) < ws-fname-date or (ws-dir-date(ws-ptr) = ws-fname-date and ws-dir-time(ws-ptr) < ws-fname-time) exit perform end-if end-evaluate end-perform . s1-scan-dir section. * If we're in separate file & dir view mode, do two separate * scans - scan for files using filemask pattern, scan for all * directories (filemask = "*") * * Otherwise do a single scan, differentiating between file and * directory entries in the file table * If we haven't got a pattern, just assume it's all files set lookfor-active to false if ws-pattern-content = spaces move "*" to ws-pattern-content move 1 to ws-pattern-len else perform varying ws-pattern-len from length ws-pattern-content by -1 until ws-pattern-content(ws-pattern-len:1) not = space end-perform end-if * Now get all the files in the directory using the filemask pattern move zero to ws-last-line(1) ws-last-line(2) ws-last-file ws-last-dir move spaces to ws-file-tbl ws-dir-tbl if combi-view if dirs-first move 2 to ws-search-attr perform t1-get-files move 1 to ws-search-attr perform t1-get-files else move 3 to ws-search-attr move zero to ws-last-dir perform t1-get-files end-if else move 1 to ws-search-attr perform t1-get-files end-if if not combi-view perform t3-get-dirs end-if * Get the current directory name move zero to ws-pwd-flags move length ws-pwd to ws-pwd-len move spaces to ws-pwd call "CBL_GET_CURRENT_DIR" using by value ws-pwd-flags ws-pwd-len by reference ws-pwd returning ws-call-status if ws-pwd(1:1) = '"' move ws-pwd(2:) to ws-path-name move ws-path-name to ws-pwd perform varying ws-ptr from length ws-pwd by -1 until ws-pwd(ws-ptr:1) = '"' end-perform move space to ws-pwd(ws-ptr:1) set pwd-quoted to true else set pwd-quoted to false end-if if ws-pwd = spaces *> Shouldn't be, but just in case move zero to ws-pwd-len else perform varying ws-pwd-len from ws-pwd-len by -1 until ws-pwd(ws-pwd-len:1) not = space end-perform end-if move 1 to ws-from(1) ws-from(2) move ws-scr-start to ws-scr-line-no(1) ws-scr-line-no(2) if not combi-view perform x7-sort-dirs end-if perform x8-sort-files . s3-display-screen section. * Nothing terribly complex, just work out the range of lines * to display and put them into the scr-line array move spaces to ws-scr-tbl compute ws-to(ws-view) = (ws-from(ws-view) + c-scr-lines) - 1 if ws-to(ws-view) > ws-last-line(ws-view) move ws-last-line(ws-view) to ws-to(ws-view) end-if move zero to ws-scr-ptr perform varying ws-ptr from ws-from(ws-view) by 1 until ws-ptr > ws-to(ws-view) add 1 to ws-scr-ptr if dir-view move ws-dir-name(ws-ptr) to ws-scr-name(ws-scr-ptr) string ws-dir-date(ws-ptr)(7:2) "/" ws-dir-date(ws-ptr)(5:2) "/" ws-dir-date(ws-ptr)(3:2) delimited by size into ws-scr-date(ws-scr-ptr) string ws-dir-time(ws-ptr)(1:2) ":" ws-dir-time(ws-ptr)(3:2) delimited by size into ws-scr-time(ws-scr-ptr) else move ws-file-name(ws-ptr) to ws-scr-name(ws-scr-ptr) string ws-file-date(ws-ptr)(7:2) "/" ws-file-date(ws-ptr)(5:2) "/" ws-file-date(ws-ptr)(3:2) delimited by size into ws-scr-date(ws-scr-ptr) string ws-file-time(ws-ptr)(1:2) ":" ws-file-time(ws-ptr)(3:2) delimited by size into ws-scr-time(ws-scr-ptr) if file-entry(ws-ptr) move ws-file-size(ws-ptr) to ws-scr-size(ws-scr-ptr) end-if move ws-file-type(ws-ptr) to ws-scr-file-type(ws-scr-ptr) end-if end-perform if combi-view compute ws-last-file-disp = ws-last-file - ws-last-dir else move ws-last-file to ws-last-file-disp end-if move ws-last-dir to ws-last-dir-disp * Now display the main screen and highlight the current line display ss-main evaluate true when stack-view display "Stack view" at 0150 with erase eol foreground-colour cyan when combi-view perform varying ws-ptr from 1 by 1 until ws-ptr > ws-scr-ptr if scr-dir-entry(ws-ptr) move green-x to ws-line-fg compute ws-line = ws-ptr + (ws-scr-start-line - 1) perform x11-display-line end-if end-perform end-evaluate move ws-scr-line-no(ws-view) to ws-line if colour-ok compute ws-ptr = ws-line - (ws-scr-start-line - 1) if (combi-view and scr-dir-entry(ws-ptr)) move blue-x to ws-line-fg else move cyan-x to ws-line-fg end-if else move "underline" to ws-line-ctrl end-if if ws-line < ws-scr-start-line move ws-scr-start-line to ws-line end-if perform x11-display-line . s5-get-extension section. * Get the extension from the filename perform varying ws-fname-ptr from length ws-fname by -1 until ws-fname-ptr < 1 or ws-fname(ws-fname-ptr:1) = "." end-perform if ws-fname-ptr > zero move function upper-case(ws-fname(ws-fname-ptr + 1:)) to ws-extension else move spaces to ws-extension end-if . s7-change-dir section. * Change directory to that specified in ws-path-name if ws-path-name = spaces exit section end-if perform varying ws-path-ptr from length ws-path-name by -1 until ws-path-name(ws-path-ptr:1) not = space end-perform if path-name-quoted move ws-path-name to ws-path-name-temp(2:) add 2 to ws-path-ptr move '"' to ws-path-name-temp(1:1) ws-path-name-temp(ws-path-ptr:1) move ws-path-name-temp to ws-path-name end-if if ws-path-ptr = 1 or ws-path-name(ws-path-ptr:1) not = "/" add 1 to ws-path-ptr end-if move x'00' to ws-path-name(ws-path-ptr:1) move spaces to ws-path-name(ws-path-ptr + 1:) call "CBL_CHANGE_DIR" using by reference ws-path-name if return-code zero exit section end-if * Something has gone wrong move return-code to ws-file-status move spaces to ws-msg if ws-file-status-1 = "9" move ws-file-status-2-num to ws-file-status-2-disp string "Cannot cd to " ws-path-name(1:ws-path-ptr - 1) " - error 9/" ws-file-status-2-disp delimited by size into ws-msg else string "Cannot cd to " ws-path-name(1:ws-path-ptr - 1) " - error " ws-file-status-disp delimited by size into ws-msg end-if set ask-question to false perform x5-display-message . s9-push-dir-stack section. * Push the current directory onto the stack if ws-dir-stack-ptr > zero and ws-dir-stack-name(ws-dir-stack-ptr) = ws-pwd exit section end-if * Save the current view so we can use it when we come back if ws-dir-stack-ptr > zero move ws-view to ws-dir-stack-view(ws-dir-stack-ptr) move ws-saved-from to ws-dir-stack-from(ws-dir-stack-ptr) move ws-line to ws-dir-stack-line(ws-dir-stack-ptr) end-if * If we're at the limit for the stack, lose the first entry if ws-dir-stack-ptr < c-max-dir-stack add 1 to ws-dir-stack-ptr else perform varying ws-dir-stack-ptr from 2 by 1 until ws-dir-stack-ptr > c-max-dir-stack move ws-dir-stack-entry(ws-dir-stack-ptr) to ws-dir-stack-entry (ws-dir-stack-ptr - 1) end-perform move c-max-dir-stack to ws-dir-stack-ptr end-if * Current working directory goes onto the stack move ws-pwd to ws-dir-stack-name(ws-dir-stack-ptr) move ws-pwd-quoted-ind to ws-dir-stack-quoted-ind (ws-dir-stack-ptr) * As this is a new venture up the stack, remove any existing entry * from above us so "next" won't go there if ws-dir-stack-ptr < c-max-dir-stack move spaces to ws-dir-stack-entry (ws-dir-stack-ptr + 1) end-if . s11-set-view section. * Set the correct values in control fields to display the directory * and file view tabs move spaces to ws-dir-ctrl ws-file-ctrl if dir-view if colour-ok string "foreground-color " cyan-x delimited by size into ws-dir-ctrl else move "underline" to ws-dir-ctrl end-if else set file-view to true if colour-ok if not combi-view string "foreground-color " cyan-x delimited by size into ws-file-ctrl end-if else move "underline" to ws-file-ctrl end-if end-if . s13-evaluate-next-field section. * Where do we go to next? evaluate true also true when ADIS-key also cursor-left when ADIS-key also cursor-up if ws-field > 1 subtract 1 from ws-field end-if when ADIS-key also cursor-right when ADIS-key also cursor-down when ADIS-key also Tab-key when ADIS-key also Enter-key-ADIS when Accept-terminated also Enter-key if ws-field < ws-last-field add 1 to ws-field end-if when ADIS-key also Home-key move 1 to ws-field when ADIS-key also End-key move ws-last-field to ws-field when other if ws-field < ws-last-field add 1 to ws-field end-if end-evaluate . s15-move-line section. if colour-ok if (combi-view and scr-dir-entry(ws-l)) move green-x to ws-line-fg else move white-x to ws-line-fg end-if else move "underline" to ws-line-ctrl end-if perform x11-display-line add ws-line-increment to ws-line ws-l if colour-ok if (combi-view and scr-dir-entry(ws-l)) move blue-x to ws-line-fg else move cyan-x to ws-line-fg end-if else move "underline" to ws-line-ctrl end-if perform x11-display-line . t1-get-files section. * Note on date - year is (year - 1900) and month is (month - 1) * Allow wildcards and escaping using "!" move 3 to ws-search-flags * Search for either files (if separate views) or files & dir * (if combi view) call "CBL_DIR_SCAN_START" using by reference ws-handle ws-pattern by value ws-search-attr ws-search-flags returning ws-call-status perform until ws-call-status not zero or ws-last-line(1) not < c-max-files initialize ws-entry move length ws-entry-name to ws-max-len call "CBL_DIR_SCAN_READ" using by reference ws-handle ws-entry returning ws-call-status if ws-call-status not zero exit perform end-if add 1 to ws-last-line(1) ws-last-file * If entry contains space, it is surrounded by quotes * Entry starts "./" so get rid of that if ws-entry-name(1:3) = '"./' move ws-entry-name(4:) to ws-file-name(ws-last-file) perform varying ws-ptr from length ws-file-name by -1 until ws-file-name(ws-last-file)(ws-ptr:1) = '"' end-perform move space to ws-file-name(ws-last-file)(ws-ptr:1) compute ws-file-name-len(ws-last-file) = ws-ptr - 1 set file-name-quoted(ws-last-file) to true else move ws-entry-name(3:) to ws-file-name(ws-last-file) perform varying ws-ptr from length ws-file-name by -1 until ws-file-name(ws-last-file)(ws-ptr:1) not = space end-perform move ws-ptr to ws-file-name-len(ws-last-file) set file-name-quoted(ws-last-file) to false end-if move function upper-case(ws-file-name(ws-last-file)) to ws-file-name-uc(ws-last-file) perform varying ws-ptr from ws-ptr by -1 until ws-file-name(ws-last-file)(ws-ptr:1) = "/" or "." end-perform if ws-file-name(ws-last-file)(ws-ptr:1) = "." and ws-ptr > 1 *> Watch out for hidden files! move ws-file-name(ws-last-file)(ws-ptr + 1:) to ws-file-ext(ws-last-file) end-if move function upper-case(ws-file-ext(ws-last-file)) to ws-file-ext-uc(ws-last-file) compute ws-file-date(ws-last-file) = ((ws-year + 1900) * 10000) + ((ws-month + 1) * 100) + ws-day compute ws-file-time(ws-last-file) = (ws-hour * 100) + ws-minute move ws-size to ws-file-size(ws-last-file) move 1 to ws-and-value call "CBL_AND" using by reference ws-attribute ws-and-value by value length ws-attribute if ws-and-value = 1 set file-entry(ws-last-file) to true else set dir-entry(ws-last-file) to true add 1 to ws-last-dir end-if move ws-last-file to ws-file-orig-line(ws-last-file) end-perform if ws-call-status zero move "Maximum number of files hit" to ws-msg set ask-question to false perform x5-display-message end-if call "CBL_DIR_SCAN_END" using by reference ws-handle returning ws-call-status . t3-get-dirs section. * Now get all the directories in the current directory move "*" to ws-dir-pattern-content move 1 to ws-dir-pattern-len * Allow wildcards and escaping using "!" move 3 to ws-search-flags * Search for directories move 2 to ws-search-attr call "CBL_DIR_SCAN_START" using by reference ws-handle ws-dir-pattern by value ws-search-attr ws-search-flags returning ws-call-status perform until ws-call-status not zero or ws-last-line(2) not < c-max-dirs initialize ws-entry move length ws-entry-name to ws-max-len call "CBL_DIR_SCAN_READ" using by reference ws-handle ws-entry returning ws-call-status if ws-call-status not zero exit perform end-if add 1 to ws-last-line(2) ws-last-dir * If entry contains space, it is surrounded by quotes * Entry starts "./" so get rid of that if ws-entry-name(1:3) = '"./' move ws-entry-name(4:) to ws-dir-name(ws-last-dir) perform varying ws-ptr from length ws-dir-name by -1 until ws-dir-name(ws-last-dir)(ws-ptr:1) = '"' end-perform move space to ws-dir-name(ws-last-dir)(ws-ptr:1) compute ws-dir-name-len(ws-last-dir) = ws-ptr - 1 set dir-name-quoted(ws-last-dir) to true else move ws-entry-name(3:) to ws-dir-name(ws-last-dir) set dir-name-quoted(ws-last-dir) to false end-if move function upper-case(ws-dir-name(ws-last-dir)) to ws-dir-name-uc(ws-last-dir) compute ws-dir-date(ws-last-dir) = ((ws-year + 1900) * 10000) + ((ws-month + 1) * 100) + ws-day compute ws-dir-time(ws-last-dir) = (ws-hour * 100) + ws-minute end-perform if ws-call-status zero move "Maximum number of directories hit" to ws-msg set ask-question to false perform x5-display-message end-if call "CBL_DIR_SCAN_END" using by reference ws-handle returning ws-call-status . x1-intercept-cursor-keys section. * Set the cursor-moving ADIS keys to be intercepted by the program move "2" to ws-key-control-type move 1 to ws-key-setting move 3 to ws-first-key-num move 10 to ws-num-of-keys call x"AF" using ws-set-bit-pairs ws-key-control . x3-pass-cursor-keys section. * Set the cursor-moving ADIS keys to normal behaviour move "2" to ws-key-control-type move 2 to ws-key-setting move 3 to ws-first-key-num move 10 to ws-num-of-keys call x"AF" using ws-set-bit-pairs ws-key-control . x5-display-message section. perform varying ws-msg-len from length ws-msg by -1 until ws-msg(ws-msg-len:1) not = space end-perform move 12 to ws-msg-line compute ws-msg-col = (80 - ws-msg-len) / 2 subtract 3 from ws-msg-col move all "*" to ws-msg-disp(1:ws-msg-len + 4) display ws-msg-disp(1:ws-msg-len + 4) at ws-msg-linecol foreground-colour red background-colour cyan add 4 to ws-msg-line display ws-msg-disp(1:ws-msg-len + 4) at ws-msg-linecol background-colour cyan foreground-colour red move all spaces to ws-msg-disp(2:ws-msg-len + 2) subtract 3 from ws-msg-line display ws-msg-disp(1:ws-msg-len + 4) at ws-msg-linecol foreground-colour red background-colour cyan add 2 to ws-msg-line display ws-msg-disp(1:ws-msg-len + 4) at ws-msg-linecol foreground-colour red background-colour cyan move ws-msg(1:ws-msg-len) to ws-msg-disp(3:ws-msg-len) subtract 1 from ws-msg-line display ws-msg-disp(1:ws-msg-len + 4) at ws-msg-linecol foreground-colour red background-colour cyan compute ws-msg-col = ws-msg-col + ws-msg-len + 2 if ws-sleep not zero call "sleep" using by value ws-sleep move zero to ws-sleep move spaces to ws-msg ws-msg-disp set Accept-terminated to true *> Don't end if Esc pressed set ask-question to false exit section end-if move space to ws-keypress accept ws-keypress at ws-msg-linecol auto foreground-colour red background-colour cyan move function upper-case(ws-keypress) to ws-keypress if ask-question perform until (ask-y-or-n and (ws-keypress = "Y" or "N")) or (not ask-y-or-n and ws-keypress not = space) accept ws-keypress at ws-msg-linecol auto foreground-colour red background-colour cyan move function upper-case(ws-keypress) to ws-keypress end-perform end-if move spaces to ws-msg ws-msg-disp set Accept-terminated to true *> Don't end if Esc pressed set ask-question to false . x7-sort-dirs section. if ws-dir-sort-priority = spaces move "A" to ws-dir-name-priority end-if evaluate true when ws-dir-name-priority = "A" if ws-dir-sort-case-sens = "N" sort ws-dir-entry ascending ws-dir-name-uc else sort ws-dir-entry ascending ws-dir-name end-if when ws-dir-name-priority = "D" if ws-dir-sort-case-sens = "N" sort ws-dir-entry descending ws-dir-name-uc else sort ws-dir-entry descending ws-dir-name end-if when ws-dir-date-priority = "A" sort ws-dir-entry ascending ws-dir-date ascending ws-dir-time ascending ws-dir-name when ws-dir-date-priority = "D" sort ws-dir-entry descending ws-dir-date descending ws-dir-time ascending ws-dir-name end-evaluate . x8-sort-files section. if ws-file-sort-priority = spaces move "A" to ws-file-name-priority end-if if combi-view and dirs-first evaluate ws-file-name-priority when "A" sort ws-file-entry ascending ws-file-orig-line exit section when "D" sort ws-file-entry descending ws-file-orig-line exit section end-evaluate end-if evaluate true when ws-file-name-priority = "A" if ws-file-sort-case-sens = "N" sort ws-file-entry ascending ws-file-name-uc else sort ws-file-entry ascending ws-file-name end-if when ws-file-name-priority = "D" if ws-file-sort-case-sens = "N" sort ws-file-entry descending ws-file-name-uc else sort ws-file-entry descending ws-file-name end-if when ws-file-type-priority = "A" if ws-file-sort-case-sens = "N" sort ws-file-entry ascending ws-file-ext-uc ascending ws-file-name-uc else sort ws-file-entry ascending ws-file-ext ascending ws-file-name end-if when ws-file-type-priority = "D" if ws-file-sort-case-sens = "N" sort ws-file-entry descending ws-file-ext-uc descending ws-file-name-uc else sort ws-file-entry descending ws-file-ext descending ws-file-name end-if when ws-file-date-priority = "A" sort ws-file-entry ascending ws-file-date ascending ws-file-time ascending ws-file-name when ws-file-date-priority = "D" sort ws-file-entry descending ws-file-date descending ws-file-time ascending ws-file-name when ws-file-size-priority = "A" sort ws-file-entry ascending ws-file-size ascending ws-file-name when ws-file-size-priority = "D" sort ws-file-entry descending ws-file-size ascending ws-file-name end-evaluate . x9-centre-msg section. move spaces to ws-msg-disp if ws-msg = spaces exit section end-if perform varying ws-msg-len from length ws-msg by -1 until ws-msg(ws-msg-len:1) not = space end-perform compute ws-msg-ptr = (length ws-msg-disp - ws-msg-len) / 2 move ws-msg to ws-msg-disp(ws-msg-ptr:) . x11-display-line section. compute ws-disp-line = ws-line - (ws-scr-start-line - 1) display ws-scr-line(ws-disp-line) at ws-linecol mode block control ws-line-ctrl . end program filemanager.