Re: [Pharo-dev] bug in command line handler
On Friday 19 May 2017 05:40 PM, Damien Pollet wrote: I wouldn't want to sound sarcastic, but I'm not sure there is such a concept as "correct" in the context of ANSI escape sequences. Still, according to the legends, 97 is supposed to be high intensity white (for some subset of existing implementations). ;-). My context was command line usage in linux terminals. Anyway, attached is a patch for the annoying bug which fixed the problem for me. I would appreciate if anyone else using the command line can confirm if the patch works for them. E.g. $ ./pharo Pharo.image eval 'ProtoObject methodDict size\;^MProtoObject methodDict keys' Syntax Error on line 1: 'Variable or expression expected' = 1: ProtoObject methodDict size\; _^_ 2: ProtoObject methodDict keys $ ./pharo Pharo.image eval 'ProtoObject methodDict size.^MProtoObject methodDict keys;' Syntax Error on line 2: 'Message expected' == 1: ProtoObject methodDict size. 2: ProtoObject methodDict keys; _^_ $ Thanks .. Subbu 'From Pharo6.0 of 13 May 2016 [Latest update: #60473] on 19 May 2017 at 8:03:31.630191 pm'! "Change Set: resetcolor Date: 19 May 2017 Author: kks reset colors after printing error messages while parsing"! !STCommandLineHandler class methodsFor: 'printing' stamp: 'kks 5/19/2017 20:01'! printCompilerWarning: aSyntaxErrorNotification | stderr position contents errorLine errorMessage maxLineNumberSize lineNumber | "format the error" position := aSyntaxErrorNotification location. contents := aSyntaxErrorNotification errorCode. errorLine := contents lineNumberCorrespondingToIndex: position. stderr := VTermOutputDriver stderr. "first gather the error title to be able to underline it properly" errorMessage := String streamContents: [ :s| s nextPutAll: 'Syntax Error on line '; print: errorLine; nextPutAll: ': '; print: aSyntaxErrorNotification errorMessage]. stderr red; nextPutAll: errorMessage; lf; nextPutAll: ('' padLeftTo: errorMessage size with: $=); lf; clear. "print each source line and mark the found syntax error" maxLineNumberSize := contents lines size asString size. lineNumber := 0. contents lineIndicesDo: [:start :endWithoutDelimiters :end | lineNumber := lineNumber + 1. lineNumber == errorLine ifTrue: [ stderr errorColor ]. "0 pad the line numbers to the same size" stderr nextPutAll: (lineNumber asString padLeftTo: maxLineNumberSize with: $0); nextPutAll: ': '; nextPutAll: (contents copyFrom: start to: endWithoutDelimiters); lf. "print the marker under the error line" (lineNumber == errorLine) ifTrue: [ stderr nextPutAll:( '_^_' padLeftTo: position - start + maxLineNumberSize + 4); lf; clear] ]! ! !VTermOutputDriver methodsFor: 'coloring' stamp: 'kks 5/19/2017 19:58'! errorColor self red! !
Re: [Pharo-dev] bug in command line handler
I wouldn't want to sound sarcastic, but I'm not sure there is such a concept as "correct" in the context of ANSI escape sequences. Still, according to the legends, 97 is supposed to be high intensity white (for some subset of existing implementations). On 19 May 2017 at 12:52, K K Subbu wrote: > All, > > I found an annoying bug with Pharo's eval command line handler. When it > encounters a syntax error, the foreground color is set to red while > printing error message, but not restored after (see attachment). I have to > reset it every time using "echo -e \e[0m" :-(. > > I found > > STCommandLineHandler>>#printCompilerWarning: aSyntaxErrorNotification > ... > "print the marker under the error line" > (lineNumber == errorLine) ifTrue: [ > stderr red > nextPutAll:( '_^_' padLeftTo: position - > start + maxLineNumberSize + 4); > lf ]] > > The above code will leave the red color if the error happens on the last > line (as in eval handler), then the color is never restored. Can someone > confirm if this is indeed what is happening? I will file a case and post a > fix, if so. > > I also found VTermOutputDriver uses incorrect ANSI color codes (e.g. white > is 37 instead of 97). If the current terminal bg color happens to be > "stderr white", then the error text is unreadable. > > Regards .. Subbu > -- Damien Pollet type less, do more [ | ] http://people.untyped.org/damien.pollet
[Pharo-dev] bug in command line handler
All, I found an annoying bug with Pharo's eval command line handler. When it encounters a syntax error, the foreground color is set to red while printing error message, but not restored after (see attachment). I have to reset it every time using "echo -e \e[0m" :-(. I found STCommandLineHandler>>#printCompilerWarning: aSyntaxErrorNotification ... "print the marker under the error line" (lineNumber == errorLine) ifTrue: [ stderr red nextPutAll:( '_^_' padLeftTo: position - start + maxLineNumberSize + 4); lf ]] The above code will leave the red color if the error happens on the last line (as in eval handler), then the color is never restored. Can someone confirm if this is indeed what is happening? I will file a case and post a fix, if so. I also found VTermOutputDriver uses incorrect ANSI color codes (e.g. white is 37 instead of 97). If the current terminal bg color happens to be "stderr white", then the error text is unreadable. Regards .. Subbu