home *** CD-ROM | disk | FTP | other *** search
- /*
- * File......: ATPROMPT.PRG
- * Author....: Ted Means
- * Date......: $Date: 15 Aug 1991 23:06:20 $
- * Revision..: $Revision: 1.3 $
- * Log file..: $Logfile: E:/nanfor/src/atprompt.prv $
- *
- * This is an original work by Ted Means and is placed in the
- * public domain.
- *
- * Modification history:
- * ---------------------
- *
- * $Log: E:/nanfor/src/atprompt.prv $
- *
- * Rev 1.3 15 Aug 1991 23:06:20 GLENN
- * Forest Belt proofread/edited/cleaned up doc
- *
- * Rev 1.2 14 Jun 1991 17:53:30 GLENN
- * Added support for "RB" color spec as well as "BR"
- *
- * Rev 1.1 10 May 1991 23:47:56 GLENN
- * Fixed documentation bug. The doc headers referred to the function as
- * ft_atprompt() when it is really ft_prompt().
- *
- * Rev 1.0 01 Apr 1991 01:00:38 GLENN
- * Nanforum Toolkit
- *
- */
-
- /* $DOC$
- * $FUNCNAME$
- * @...PROMPT
- * $CATEGORY$
- * Menus/Prompts
- * $ONELINER$
- * Define a menu item for use with MENU TO
- * $SYNTAX$
- * #include "FTMENUTO.CH"
- *
- * @ <nRow>, <nCol> PROMPT <cMenuItem> ;
- * [ PROMPTCOLOR <cPromptColor> ] ;
- * [ MESSAGE <cItemMessage> ] ;
- * [ MSGROW <nMessageRow> ] ;
- * [ MSGCOL <nMessageCol> ] ;
- * [ MSGCOLOR <cMsgColor> ] ;
- * [ HOTKEY <nHotKeyPosition> ] ;
- * [ HOTKEYCOLOR <cHotKeyColor> ] ;
- * [ BARCOLOR <cBarColor> ] ;
- * [ BARHOTKEYCOLOR <cBarHotKeyColor> ] ;
- * [ UP <nUp> ] ;
- * [ DOWN <nDown> ] ;
- * [ RIGHT <nRight> ] ;
- * [ LEFT <nLeft> ]
- * $ARGUMENTS$
- * <nRow> is the row at which the prompt is to appear.
- *
- * <nCol> is the column at which the prompt will appear.
- *
- * <cMenuItem> is the menu item to display.
- *
- * <cPromptColor> is optional and is the color attribute of the
- * prompt. If not specified, the default is the current
- * standard color as supplied by the SetColor() function.
- *
- * <cItemMessage> is optional and is the message associated with
- * the prompt. If not specified, then no message will be displayed.
- *
- * <nMessageRow> is optional and is the row at which the
- * message, if any, will appear. If not specified, the default
- * is the current setting of the SET MESSAGE TO command.
- *
- * <nMessageCol> is optional and is the column at which the
- * message, if any, will appear. If not specified, the default
- * is either zero or centered, depending on the current setting
- * of the CENTER option of the SET MESSAGE TO command.
- *
- * <cMsgColor> is optional and is the color attribute of
- * the message. If not specified, the default is the current
- * standard color as reported by the SetColor() function.
- *
- * <nHotKeyPosition> is optional and is the position within the
- * prompt string where the hotkey is located. If not
- * specified, the default is one.
- *
- * <cHotKeyColor> is optional and is the color attribute of the
- * hotkey character. If not specified, the default is the same
- * color as the rest of the prompt.
- *
- * <cBarColor> is optional and is the color attribute of
- * the light bar when it is positioned on this prompt. If not
- * specified, the default is the current enhanced color setting
- * as returned by the SetColor() function.
- *
- * <cBarHotKeyColor> is optional and is the color
- * attribute of the hotkey when the light bar is positioned on
- * this prompt. If not specified, the default is the same
- * color as the rest of the light bar.
- *
- * <nUp> is optional and specifies which prompt becomes active
- * when the up arrow key is pressed. If not specified, the
- * default is the previous prompt. The current setting of SET
- * WRAP TO is obeyed.
- *
- * <nDown> is optional and specifies which prompt becomes
- * active when the down arrow key is pressed. If not
- * specified, the default is the next prompt. The current
- * setting of SET WRAP TO is obeyed.
- *
- * <nRight> is optional and specifies which prompt becomes
- * active when the right arrow key is pressed. If not
- * specified, the default is the next prompt. The current
- * setting of SET WRAP TO is obeyed.
- *
- * <nLeft> is optional and specifies which prompt becomes
- * active when the left arrow is pressed. If not specified,
- * the default is the previous prompt. The current setting of
- * SET WRAP TO is obeyed.
- * $DESCRIPTION$
- * This enhanced version of @...PROMPT requires the inclusion of
- * the header file FTMENUTO.CH in any source file that uses it.
- * It is compatible with, and may be used in place of, the standard
- * Clipper @...PROMPT command.
- *
- * Clipper's @...PROMPT and MENU TO commands are fine as far as
- * they go. But many times you need more flexibility. As
- * you'll no doubt notice if you read the argument list, this
- * function is almost completely flexible. You can adjust
- * locations and colors for every part of the prompt and its
- * associated message. In addition, since you can control the
- * effect of the arrow keys, you can allow both horizontal and
- * vertical movement, or even disable certain arrow keys if you
- * so desire.
- *
- * Note that this command can also be called using function-style
- * syntax. See the entry for FT_PROMPT() for further details.
- *
- * Also note that this command calls an internal routine called
- * __FTPROMPT(). __FTPROMPT() was written in assembler. Check
- * the file TMENU.ASM if you're interested in seeing the
- * assembler source code.
- *
- * All the examples below use the command version. If you're
- * interested in seeing the function version, compile the
- * examples with the /P switch and then examine the resulting
- * .PPO file.
- * $EXAMPLES$
- * #include "FTMENUTO.CH"
- * // Simple prompt
- * @ 1, 1 PROMPT "Menu choice #1"
- *
- * // Prompt with color
- * @ 3, 1 PROMPT "Menu choice #2" PROMPTCOLOR W+/R
- *
- * // Prompt with a message
- * @ 5, 1 PROMPT "Menu choice #3" MESSAGE "Go to lunch"
- *
- * // Prompt with pinpoint message control
- * @ 7, 1 PROMPT "Menu choice #4" MESSAGE "Drop Dead" ;
- * MSGROW 22 MSGCOL 4 MSGCOLOR GR+/N
- *
- * // Prompt with a unique lightbar color
- * @ 9, 1 PROMPT "Menu choice #5" BARCOLOR BG+/W
- *
- * // Prompt with a hotkey ("#" character)
- * @11, 1 PROMPT "Menu choice #6" HOTKEY 13
- *
- * // Prompt with pinpoint hotkey control
- * @13, 1 PROMPT "Menu Choice #7" HOTKEY 13 ;
- * HOTKEYCOLOR R+/BG BARHOTKEYCOLOR G+/N
- *
- * // Prompt with right and left arrow keys disabled
- * @15, 1 PROMPT "Menu Choice #8" RIGHT 8 LEFT 8
- * $INCLUDE$
- * FTMENUTO.CH
- * $SEEALSO$
- * "MENU TO" FT_PROMPT() FT_MENUTO()
- * $END$
- */
-
-
- /* $DOC$
- * $FUNCNAME$
- * FT_PROMPT()
- * $CATEGORY$
- * Menus/Prompts
- * $ONELINER$
- * Define a menu item for use with FT_MENUTO()
- * $SYNTAX$
- * FT_PROMPT( <nPromptRow>, ;
- * <nPromptCol>, ;
- * <cPrompt>, ;
- * [ <cPromptColor> ], ;
- * [ <nMessageRow> ], ;
- * [ <nMessageCol> ], ;
- * [ <cMessage> ], ;
- * [ <cMessageColor> ], ;
- * [ <nHotKeyPosition> ], ;
- * [ <cHotKeyColor> ], ;
- * [ <cLightBarColor> ], ;
- * [ <cLightBarHotKeyColor> ], ;
- * [ <nUp> ], ;
- * [ <nDown> ], ;
- * [ <nRight> ], ;
- * [ <nLeft> ] ) -> NIL
- *
- * $ARGUMENTS$
- * <nPromptRow> is the row at which the prompt is to appear.
- *
- * <nPromptCol> is the column at which the prompt will appear.
- *
- * <cPrompt> is the prompt's text.
- *
- * <cPromptColor> is optional and is the color attribute of the
- * prompt. If not specified, the default is the current
- * standard color as supplied by the SetColor() function.
- *
- * <nMessageRow> is optional and is the row at which the
- * message, if any, will appear. If not specified, the default
- * is the current setting of the SET MESSAGE TO command.
- *
- * <nMessageCol> is optional and is the column at which the
- * message, if any, will appear. If not specified, the default
- * either zero or centered, depending on the current setting of
- * the CENTER option of the SET MESSAGE TO command.
- *
- * <cMessage> is optional and is the message associated with
- * the prompt. If not specified, then no message will be displayed.
- *
- * <cMessageColor> is optional and is the color attribute of
- * the message. If not specified, the default is the current
- * standard color as reported by the SetColor() function.
- *
- * <nHotKeyPosition> is optional and is the position within the
- * prompt string where the hotkey is located. If not
- * specified, the default is 1.
- *
- * <cHotKeyColor> is optional and is the color attribute of the
- * hotkey character. If not specified, the default is the same
- * color as the rest of the prompt.
- *
- * <cLightBarColor> is optional and is the color attribute of
- * the light bar when it is positioned on this prompt. If not
- * specified, the default is the current enhanced color setting
- * as returned by the SetColor() function.
- *
- * <cLightBarHotKeyColor> is optional and is the color
- * attribute of the hotkey when the light bar is positioned on
- * this prompt. If not specified, the default is the same
- * color as the rest of the light bar.
- *
- * <nUp> is optional and specifies which prompt becomes active
- * when the up arrow key is pressed. If not specified, the
- * default is the previous prompt. The current setting of SET
- * WRAP TO is obeyed.
- *
- * <nDown> is optional and specifies which prompt becomes
- * active when the down arrow key is pressed. If not
- * specified, the default is the next prompt. The current
- * setting of SET WRAP TO is obeyed.
- *
- * <nRight> is optional and specifies which prompt becomes
- * active when the right arrow key is pressed. If not
- * specified, the default is the next prompt. The current
- * setting of SET WRAP TO is obeyed.
- *
- * <nLeft> is optional and specifies which prompt becomes
- * active when the left arrow is pressed. If not specified,
- * the default is the previous prompt. The current setting of
- * SET WRAP TO is obeyed.
- * $RETURNS$
- * NIL
- * $DESCRIPTION$
- * This function is a replacement for Clipper's @...PROMPT
- * command. In fact, you may wish to consult FTMENUTO.CH, which
- * contains a user-defined command that closely adheres to
- * standard Clipper syntax and makes this function infinitely
- * easier to use. I strongly recommend using the command
- * version because the large number of possible arguments makes
- * the function version too prone to error.
- *
- * Clipper's @...PROMPT and MENU TO commands are fine as far as
- * they go. But many times you need more flexibility. As
- * you'll no doubt notice if you read the argument list, this
- * function is almost completely flexible. You can adjust
- * locations and colors for every part of the prompt and its
- * associated message. In addition, since you can control the
- * effect of the arrow keys, you can allow both horizontal and
- * vertical movement, or even disable certain arrow keys if you
- * so desire.
- *
- * Note that this function calls an internal routine called
- * __FTPROMPT(). __FTPROMPT() was written in assembler. Check
- * the file TMENU.ASM if you're interested in seeing the
- * assembler source code.
- *
- * All the examples below use the command version. If you're
- * interested in seeing the function version, compile the
- * examples with the /P switch and then examine the resulting
- * .PPO file.
- * $EXAMPLES$
- * #include "FTMENUTO.CH"
- * // Simple prompt
- * @ 1, 1 PROMPT "Menu choice #1"
- *
- * // Prompt with color
- * @ 3, 1 PROMPT "Menu choice #2" PROMPTCOLOR W+/R
- *
- * // Prompt with a message
- * @ 5, 1 PROMPT "Menu choice #3" MESSAGE "Go to lunch"
- *
- * // Prompt with pinpoint message control
- * @ 7, 1 PROMPT "Menu choice #4" MESSAGE "Drop Dead" ;
- * MSGROW 22 MSGCOL 4 MSGCOLOR GR+/N
- *
- * // Prompt with a unique lightbar color
- * @ 9, 1 PROMPT "Menu choice #5" BARCOLOR BG+/W
- *
- * // Prompt with a hotkey ("#" character)
- * @11, 1 PROMPT "Menu choice #6" HOTKEY 13
- *
- * // Prompt with pinpoint hotkey control
- * @13, 1 PROMPT "Menu Choice #7" HOTKEY 13 ;
- * HOTKEYCOLOR R+/BG BARHOTKEYCOLOR G+/N
- *
- * // Prompt with right and left arrow keys disabled
- * @15, 1 PROMPT "Menu Choice #8" RIGHT 8 LEFT 8
- * $SEEALSO$
- * "MENU TO" "@...PROMPT" FT_MENUTO()
- * $END$
- */
-
- #include "set.ch"
-
- function FT_Prompt( nPRow, nPCol, cPrompt, cPAttr, ;
- nMRow, nMCol, cMessage, cMAttr, ;
- nHKeyPos, cHKeyAttr, cLBarAttr, ;
- cLBHKAttr, nUp, nDown, nRight, ;
- nLeft )
-
- local nPLoc, nMLoc, nHKeyLoc, nPAttr, nMAttr, nHKeyAttr, nHKeyVal, nLBarAttr
- local nLBHKAttr
-
- local cCurColor := setcolor()
- local cStdColor := left(cCurColor, at(",", cCurColor) - 1)
- local cEnhColor := right(cCurColor, len(cCurColor) - len(cStdColor) - 1)
-
- cEnhColor := left(cEnhColor, at(",", cEnhColor) - 1)
-
- if valtype(nPRow) != "N"
- nPRow := 0
- endif
-
- if valtype(nPCol) != "N"
- nPCol := 0
- endif
-
- if valtype(cPrompt) != "C"
- cPrompt := ""
- endif
-
- if valtype(cPAttr) != "C"
- cPAttr := cStdColor
- endif
-
- if valtype(cMessage) != "C"
- cMessage := ""
- endif
-
- if valtype(nMRow) != "N"
- nMRow := set(_SET_MESSAGE)
- endif
-
- if valtype(nMCol) != "N"
- if set(_SET_MCENTER)
- nMCol := round( (maxcol() - len(cMessage)) / 2, 0 )
- else
- nMCol := 0
- endif
- endif
-
- if valtype(cMAttr) != "C"
- cMAttr := cStdColor
- endif
-
- if valtype(nHKeyPos) != "N" .or. nHKeyPos > len(cPrompt) .or. nHKeyPos < 1
- nHKeyPos := 1
- do while substr( cPrompt, nHKeyPos, 1 ) == " " .AND. nHKeyPos < Len(cPrompt)
- nHKeypos++
- enddo
- endif
-
- if valtype(cHKeyAttr) != "C"
- cHKeyAttr := cPAttr
- endif
-
- if valtype(cLBarAttr) != "C"
- cLBarAttr := cEnhColor
- endif
-
- if valtype(cLBHKAttr) != "C"
- cLBHKAttr := cLBarAttr
- endif
-
- if valtype(nUp) != "N"
- nUp := 0
- endif
-
- if valtype(nDown) != "N"
- nDown := 0
- endif
-
- if valtype(nRight) != "N"
- nRight := 0
- endif
-
- if valtype(nLeft) != "N"
- nLeft := 0
- endif
-
- nPLoc := ((nPRow * (MaxCol() + 1)) + nPCol) * 2
- nMLoc := ((nMRow * (MaxCol() + 1)) + nMCol) * 2
-
- nHKeyLoc := nPLoc + ((nHKeyPos - 1) * 2)
- nHKeyVal := asc(upper(substr(cPrompt, nHKeyPos, 1)))
-
- nPAttr := _ftNColor(cPAttr)
- nMAttr := _ftNColor(cMAttr)
-
- nHKeyAttr := _ftNColor(cHKeyAttr)
- nLBarAttr := _ftNColor(cLBarAttr)
- nLBHKAttr := _ftNColor(cLBHKAttr)
-
- __ftPrompt( nPLoc, cPrompt, nPAttr, nMLoc, cMessage, nMAttr, ;
- nHKeyAttr, nHKeyLoc, nHKeyVal, nLBarAttr, ;
- nLBHKAttr, nUp, nDown, nRight, nLeft )
-
- return NIL
-
-
-
- static function _ftNColor(cColor)
-
- local nAttr := 0
- local cColr := upper(cColor)
- local cFore := left(cColr, at("/", cColr) - 1)
- local cBack := right(cColr, len(cColr) - at("/", cColr))
-
- do case
- case "BG" $ cFore
- nAttr := 3
- case ( "BR" $ cFore ) .or. ( "RB" $ cFore )
- nAttr := 5
- case "GR" $ cFore
- nAttr := 6
- case "N" $ cFore .or. "I" $ cColr
- nAttr := 0
- case "B" $ cFore .or. "U" $ cColr
- nAttr := 1
- case "G" $ cFore
- nAttr := 2
- case "R" $ cFore
- nAttr := 4
- case "W" $ cFore
- nAttr := 7
- endcase
-
- do case
- case "BG" $ cBack
- nAttr += 48
- case ( "BR" $ cBack ) .or. ( "RB" $ cBack )
- nAttr += 80
- case "GR" $ cBack
- nAttr += 96
- case "N" $ cBack
- nAttr += 0
- case "B" $ cBack
- nAttr += 16
- case "G" $ cBack
- nAttr += 32
- case "R" $ cBack
- nAttr += 64
- case "W" $ cBack .or. "I" $ cColr
- nAttr += 112
- endcase
-
- if "+" $ cFore .or. substr(cColor, 1, 2) == "I+"
- nAttr += 8
- endif
-
- if "*" $ cFore .or. "+" $ cBack
- nAttr += 128
- endif
-
- return nAttr
-