* * CAPS.KEX * * Uppercase the first character of each word in the specified target area. * A "word" is controlled by the current setting of SET WORD. The only * targets supported are blocks, relative line targets, "*" and ALL. * * Works with: * * KEDIT for Windows 1.5 * KEDIT 5.0 for DOS * KEDIT 5.0 for OS/2 * * Note that word boundaries are spaces. When using a box block though, the * left edge of the block is also assumed to be a word boundary. * * Original author: Kent Downs, MSG 8/96 * parse upper arg target if target = "" then do 'emsg CAPS Error 1: No target specified...' exit 1 end if target \= "ALL" & target \= "*" & target \= "BLOCK" & datatype(target) \= "NUM" then do 'emsg CAPS Error 2: Invalid target specified "'target'"' exit 2 end "preserve" "set autosave off" "set wrap off" OldInsertMode = insertmode.1() "set insertmode off" call FirstLine * Process each line of the target area do while WithinTargetArea() * Capitalize each word in this line do while OnTargetLine() char = UppercaseChar() "text" char "cursor left" "sos tabword" end 'down 1' call FirstCharOfLine if datatype(target) = "NUM" then target = target - 1 end "restore" "set insertmode" OldInsertMode call RestorePosition exit 0 * Make the first line of the target area the focus line and place the cursor at * the left-most column FirstLine: ResetBlock = 0 if target = "BLOCK" then do if block.1() = "NONE" then do "emsg CAPS Error 3: No block is marked" exit 3 end if block.6() \= fileid.1() then do "emsg CAPS Error 4: Marked block is not in the current file" exit 4 end if block.1() = "STREAM" then do "emsg CAPS Error 5: Stream blocks are not supported" exit 5 end if version.1() = "KEDIT/WINDOWS" then do if block.7() = "SELECTION" then do * Need to make selections persistent blocks ResetBlock = 1 "mark persistent" end end end call SavePosition if target = "BLOCK" then "sos blockstart" if target = "ALL" then ":1" call FirstCharOfLine return * Place the cursor at the first column of the current line within the target * area FirstCharOfLine: if target = "*" | datatype(target) = "NUM" | target = "ALL" then do "clocate :1" return end if target = "BLOCK" then "clocate :"block.3() else "clocate :1" return * Return TRUE if the cursor is within the target area and to the left of * the last non-blank OnTargetLine: if target = "*" | datatype(target) = "NUM" | target = "ALL" then return \after() if target = "BLOCK" then do if after() then return 0 if block.1() = "BOX" & column.1() > block.5() then return 0 else return 1 end return \after() * Return the uppercased character at the cursor position UppercaseChar: char = field.2() if version.1() = "KEDIT/WINDOWS" then do if international.1() = "CASE" then char = ansiupper(char) else char = upper(char) end else char = upper(char) return char * Save the current line and cursor position and ensure that the cursor is * in the text area SavePosition: "sos save" OnCmdline = command() StartLine = line.1() if OnCmdline then do "sos current" return end "sos current" StartLine = line.1() return * Restore the current line and cursor position RestorePosition: "cursor cmdline" ":"StartLine if \OnCmdline then "sos current" "sos restore" return * Return 1 if the focusline is within the target area WithinTargetArea: if target = "*" | target = "ALL" then return \focuseof() if datatype(target) = "NUM" then return target > 0 return line.1() <= block.4()