runtime(termdebug): Change some variables to Enums

Problem:  The types of some script variables in Termdebug
          can be changed for readability
Solution: Change the type of some vars from string to `enum`
          (Yinzuo Jiang)

closes: #15068

Signed-off-by: Yinzuo Jiang <jiangyinzuo@foxmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
index a09accb..f87cabf 100644
--- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
+++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
@@ -4,7 +4,7 @@
 
 # Author: Bram Moolenaar
 # Copyright: Vim license applies, see ":help license"
-# Last Change: 2024 Jun 20
+# Last Change: 2024 Jun 22
 # Converted to Vim9: Ubaldo Tiberi <ubaldo.tiberi@gmail.com>
 
 # WORK IN PROGRESS - The basics works stable, more to come
@@ -58,9 +58,14 @@
 command -nargs=* -complete=file -bang Termdebug StartDebug(<bang>0, <f-args>)
 command -nargs=+ -complete=file -bang TermdebugCommand StartDebugCommand(<bang>0, <f-args>)
 
+enum Way
+  Prompt,
+  Terminal
+endenum
+
 # Script variables declaration. These variables are re-initialized at every
 # Termdebug instance
-var way: string
+var way: Way
 var err: string
 
 var pc_id: number
@@ -133,16 +138,15 @@
 var saved_plus_map: dict<any>
 var saved_minus_map: dict<any>
 
-
 def InitScriptVariables()
   if exists('g:termdebug_config') && has_key(g:termdebug_config, 'use_prompt')
-    way = g:termdebug_config['use_prompt'] ? 'prompt' : 'terminal'
+    way = g:termdebug_config['use_prompt'] ? Way.Prompt : Way.Terminal
   elseif exists('g:termdebug_use_prompt')
-    way = g:termdebug_use_prompt
+    way = g:termdebug_use_prompt ? Way.Prompt : Way.Terminal
   elseif has('terminal') && !has('win32')
-    way = 'terminal'
+    way = Way.Terminal
   else
-    way = 'prompt'
+    way = Way.Prompt
   endif
   err = ''
 
@@ -219,11 +223,11 @@
   var is_check_ok = true
   # Need either the +terminal feature or +channel and the prompt buffer.
   # The terminal feature does not work with gdb on win32.
-  if (way ==# 'prompt') && !has('channel')
+  if (way is Way.Prompt) && !has('channel')
     err = 'Cannot debug, +channel feature is not supported'
-  elseif way ==# 'prompt' && !exists('*prompt_setprompt')
+  elseif (way is Way.Prompt) && !exists('*prompt_setprompt')
     err = 'Cannot debug, missing prompt buffer support'
-  elseif way ==# 'prompt' && !empty(glob(gdb_cmd))
+  elseif (way is Way.Prompt) && !empty(glob(gdb_cmd))
     err = $"You have a file/folder named '{gdb_cmd}' in the current directory Termdebug may not work properly. Please exit and rename such a file/folder."
   elseif !empty(glob(asmbufname))
     err = $"You have a file/folder named '{asmbufname}' in the current directory Termdebug may not work properly. Please exit and rename such a file/folder."
@@ -305,6 +309,9 @@
     return
   endif
 
+  # Uncomment this line to write logging in "debuglog".
+  # call ch_logfile('debuglog', 'w')
+
   InitScriptVariables()
   if !SanityCheck()
     return
@@ -314,9 +321,6 @@
     doauto <nomodeline> User TermdebugStartPre
   endif
 
-  # Uncomment this line to write logging in "debuglog".
-  # call ch_logfile('debuglog', 'w')
-
   # Assume current window is the source code window
   sourcewin = win_getid()
   var wide = 0
@@ -338,7 +342,7 @@
     vvertical = false
   endif
 
-  if way == 'prompt'
+  if way is Way.Prompt
     StartDebug_prompt(dict)
   else
     StartDebug_term(dict)
@@ -699,7 +703,7 @@
 # Send a command to gdb.  "cmd" is the string without line terminator.
 def SendCommand(cmd: string)
   ch_log($'sending to gdb: {cmd}')
-  if way == 'prompt'
+  if way is Way.Prompt
     ch_sendraw(gdb_channel, $"{cmd}\n")
   else
     term_sendkeys(commbufnr, $"{cmd}\r")
@@ -708,7 +712,7 @@
 
 # Interrupt or stop the program
 def StopCommand()
-  if way == 'prompt'
+  if way is Way.Prompt
     PromptInterrupt()
   else
     SendCommand('-exec-interrupt')
@@ -717,7 +721,7 @@
 
 # Continue the program
 def ContinueCommand()
-  if way == 'prompt'
+  if way is Way.Prompt
     SendCommand('continue')
   else
     # using -exec-continue results in CTRL-C in the gdb window not working,
@@ -729,7 +733,7 @@
 
 # This is global so that a user can create their mappings with this.
 def g:TermDebugSendCommand(cmd: string)
-  if way == 'prompt'
+  if way is Way.Prompt
     ch_sendraw(gdb_channel, $"{cmd}\n")
   else
     var do_continue = false