change the [Processing] messages into dots (#14418)
* change the [Processing] messages into dots * better implementation * maybe I should work on something else...
This commit is contained in:
parent
063229a301
commit
ddee8a362a
5 changed files with 38 additions and 10 deletions
|
|
@ -277,6 +277,11 @@ type
|
|||
msgSkipHook ## skip message hook even if it is present
|
||||
MsgFlags* = set[MsgFlag]
|
||||
|
||||
template flushDot(stdorr) =
|
||||
if conf.lastMsgWasDot:
|
||||
write(stdorr, "\n")
|
||||
conf.lastMsgWasDot = false
|
||||
|
||||
proc msgWriteln*(conf: ConfigRef; s: string, flags: MsgFlags = {}) =
|
||||
## Writes given message string to stderr by default.
|
||||
## If ``--stdout`` option is given, writes to stdout instead. If message hook
|
||||
|
|
@ -286,15 +291,16 @@ proc msgWriteln*(conf: ConfigRef; s: string, flags: MsgFlags = {}) =
|
|||
## This is used for 'nim dump' etc. where we don't have nimsuggest
|
||||
## support.
|
||||
#if conf.cmd == cmdIdeTools and optCDebug notin gGlobalOptions: return
|
||||
|
||||
if not isNil(conf.writelnHook) and msgSkipHook notin flags:
|
||||
conf.writelnHook(s)
|
||||
elif optStdout in conf.globalOptions or msgStdout in flags:
|
||||
if eStdOut in conf.m.errorOutputs:
|
||||
flushDot(stdout)
|
||||
writeLine(stdout, s)
|
||||
flushFile(stdout)
|
||||
else:
|
||||
if eStdErr in conf.m.errorOutputs:
|
||||
flushDot(stderr)
|
||||
writeLine(stderr, s)
|
||||
# On Windows stderr is fully-buffered when piped, regardless of C std.
|
||||
when defined(windows):
|
||||
|
|
@ -330,15 +336,27 @@ macro callStyledWriteLineStderr(args: varargs[typed]): untyped =
|
|||
template callWritelnHook(args: varargs[string, `$`]) =
|
||||
conf.writelnHook concat(args)
|
||||
|
||||
proc msgWrite(conf: ConfigRef; s: string) =
|
||||
if conf.m.errorOutputs != {}:
|
||||
let stdOrr =
|
||||
if optStdout in conf.globalOptions:
|
||||
stdout
|
||||
else:
|
||||
stderr
|
||||
write(stdOrr, s)
|
||||
flushFile(stdOrr)
|
||||
|
||||
template styledMsgWriteln*(args: varargs[typed]) =
|
||||
if not isNil(conf.writelnHook):
|
||||
callIgnoringStyle(callWritelnHook, nil, args)
|
||||
elif optStdout in conf.globalOptions:
|
||||
if eStdOut in conf.m.errorOutputs:
|
||||
flushDot(stdout)
|
||||
callIgnoringStyle(writeLine, stdout, args)
|
||||
flushFile(stdout)
|
||||
else:
|
||||
if eStdErr in conf.m.errorOutputs:
|
||||
flushDot(stderr)
|
||||
if optUseColors in conf.globalOptions:
|
||||
callStyledWriteLineStderr(args)
|
||||
else:
|
||||
|
|
@ -450,11 +468,18 @@ proc rawMessage*(conf: ConfigRef; msg: TMsgKind, args: openArray[string]) =
|
|||
s & (if kind.len > 0: KindFormat % kind else: ""), sev)
|
||||
|
||||
if not ignoreMsgBecauseOfIdeTools(conf, msg):
|
||||
if kind.len > 0:
|
||||
styledMsgWriteln(color, title, resetStyle, s,
|
||||
KindColor, `%`(KindFormat, kind))
|
||||
if msg == hintProcessing:
|
||||
msgWrite(conf, ".")
|
||||
conf.lastMsgWasDot = true
|
||||
else:
|
||||
styledMsgWriteln(color, title, resetStyle, s)
|
||||
if conf.lastMsgWasDot:
|
||||
msgWrite(conf, "\n")
|
||||
conf.lastMsgWasDot = false
|
||||
if kind.len > 0:
|
||||
styledMsgWriteln(color, title, resetStyle, s,
|
||||
KindColor, `%`(KindFormat, kind))
|
||||
else:
|
||||
styledMsgWriteln(color, title, resetStyle, s)
|
||||
handleError(conf, msg, doAbort, s)
|
||||
|
||||
proc rawMessage*(conf: ConfigRef; msg: TMsgKind, arg: string) =
|
||||
|
|
@ -539,7 +564,10 @@ proc liMessage(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string,
|
|||
if conf.hasHint(hintSource):
|
||||
conf.writeSurroundingSrc(info)
|
||||
if conf.hasHint(hintMsgOrigin):
|
||||
styledMsgWriteln(styleBright, toFileLineCol(info2), resetStyle, " compiler msg initiated here", KindColor, KindFormat % HintsToStr[ord(hintMsgOrigin) - ord(hintMin)], resetStyle)
|
||||
styledMsgWriteln(styleBright, toFileLineCol(info2), resetStyle,
|
||||
" compiler msg initiated here", KindColor,
|
||||
KindFormat % HintsToStr[ord(hintMsgOrigin) - ord(hintMin)],
|
||||
resetStyle)
|
||||
|
||||
handleError(conf, msg, eh, s)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue