MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / GetCommandPrompt

Method GetCommandPrompt

internal/users/userrecord.prompt.go:32–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30)
31
32func (u *UserRecord) GetCommandPrompt() string {
33
34 promptOut := ``
35
36 if u.activePrompt != nil {
37
38 if activeQuestion := u.activePrompt.GetNextQuestion(); activeQuestion != nil {
39 promptOut = activeQuestion.String()
40 }
41 }
42
43 goAhead := ``
44 if connections.GetClientSettings(u.ConnectionId()).SendTelnetGoAhead {
45 goAhead = term.TelnetGoAhead.String()
46 }
47
48 if len(promptOut) == 0 {
49
50 if promptDefaultCompiled == `` {
51 promptDefaultCompiled = util.ConvertColorShortTags(configs.GetTextFormatsConfig().Prompt.String())
52 }
53
54 var customPrompt any = nil
55 var inCombat bool = u.Character.Aggro != nil
56
57 if inCombat {
58 customPrompt = u.GetConfigOption(`fprompt-compiled`)
59 }
60
61 // No other custom prompts? try the default setting
62 if customPrompt == nil {
63 customPrompt = u.GetConfigOption(`prompt-compiled`)
64 }
65
66 if customPrompt != nil {
67 if ansiPrompt, ok := customPrompt.(string); ok {
68 promptOut = u.ProcessPromptString(ansiPrompt)
69 }
70 }
71
72 // Still nothing? Default to ... default
73 if len(promptOut) == 0 {
74 promptOut = u.ProcessPromptString(promptDefaultCompiled)
75 }
76
77 }
78
79 unsent, suggested := u.GetUnsentText()
80 if len(suggested) > 0 {
81 suggested = `<ansi fg="suggested-text">` + suggested + `</ansi>`
82 }
83 return term.AnsiMoveCursorColumn.String() + term.AnsiEraseLine.String() + promptOut + unsent + suggested + goAhead
84
85}
86
87func (u *UserRecord) ProcessPromptString(promptStr string) string {
88

Callers 5

handleTelnetConnectionFunction · 0.95
handleSSHConnectionFunction · 0.95
processInputMethod · 0.80
resumeRestoredConnectionFunction · 0.80
RedrawPrompt_SendRedrawFunction · 0.80

Calls 9

ConnectionIdMethod · 0.95
GetConfigOptionMethod · 0.95
ProcessPromptStringMethod · 0.95
GetUnsentTextMethod · 0.95
GetClientSettingsFunction · 0.92
ConvertColorShortTagsFunction · 0.92
GetTextFormatsConfigFunction · 0.92
GetNextQuestionMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected