Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita6fe713

Browse files
committed
Turn off readline for background F# interactive
turn off readline by default for F# interactive when run as abackground process (e.g. emacs)
1 parent3772c7d commita6fe713

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

‎src/fsharp/fsi/fsi.fs‎

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ type FsiCommandLineOptions(argv: string[], tcConfigB, fsiConsoleOutput: FsiConso
438438
// Mono on Win32 doesn't implement correct console processing
439439
not(runningOnMono&& System.Environment.OSVersion.Platform= System.PlatformID.Win32NT)
440440
#if MONO
441-
let mutablegui=false// override via "--gui",on by default
441+
let mutablegui=false// override via "--gui",off by default
442442
#else
443443
let mutablegui=true// override via "--gui", on by default
444444
#endif
@@ -458,7 +458,11 @@ type FsiCommandLineOptions(argv: string[], tcConfigB, fsiConsoleOutput: FsiConso
458458

459459
// internal options
460460
let mutableprobeToSeeIfConsoleWorks=true
461+
#if MONO
462+
let mutablepeekAheadOnConsoleToPermitTyping=false
463+
#else
461464
let mutablepeekAheadOnConsoleToPermitTyping=true
465+
#endif
462466

463467
letisInteractiveServer()= fsiServerName<>""
464468
letrecordExplicitArg arg= explicitArgs<- explicitArgs@[arg]
@@ -726,13 +730,17 @@ type FsiConsoleInput(fsiOptions: FsiCommandLineOptions, inReader: TextReader, ou
726730
#else
727731
letconsoleLooksOperational()=
728732
if fsiOptions.ProbeToSeeIfConsoleWorksthen
733+
if!progressthen fprintfn outWriter"probing to see if console works..."
729734
try
730735
// Probe to see if the console looks functional on this version of .NET
731736
let_= Console.KeyAvailable
732-
let_= Console.ForegroundColor
737+
letc1= Console.ForegroundColor
738+
letc2= Console.BackgroundColor
733739
let_= Console.CursorLeft<- Console.CursorLeft
734-
true
740+
if!progressthen fprintfn outWriter"probe succeeded, we might have a console, comparing foreground (%A) and background (%A) colors, if they are the same then we're running in emacs or VS on unix and we turn off readline by default..." c1 c2
741+
c1<> c2
735742
with_->
743+
if!progressthen fprintfn outWriter"probe failed, we have no console..."
736744
(* warning(Failure("Note: there was a problem setting up custom readline console support. Consider starting fsi.exe with the --no-readline option"));*)
737745
false
738746
else
@@ -780,6 +788,7 @@ type FsiConsoleInput(fsiOptions: FsiCommandLineOptions, inReader: TextReader, ou
780788
)).Start()
781789
else
782790
#endif
791+
if!progressthen fprintfn outWriter"first-line-reader-thread not in use."
783792
consoleReaderStartupDone.Set()|> ignore
784793

785794
/// Try to get the first line, if we snarfed it while probing.
@@ -1548,6 +1557,7 @@ type FsiStdinLexerProvider(tcConfigB, fsiStdinSyphon,
15481557
letLexbufFromLineReader(fsiStdinSyphon:FsiStdinSyphon)readf=
15491558
UnicodeLexing.FunctionAsLexbuf
15501559
(fun(buf: char[],start,len)->
1560+
if!progressthen printfn"calling readf..."
15511561
//fprintf fsiConsoleOutput.Out "Calling ReadLine\n";
15521562
letinputOption=try Some(readf())with:? EndOfStreamException-> None
15531563
inputOption|> Option.iter(fun t-> fsiStdinSyphon.Add(t+"\n"));
@@ -1596,9 +1606,14 @@ type FsiStdinLexerProvider(tcConfigB, fsiStdinSyphon,
15961606
LexbufFromLineReader fsiStdinSyphon(fun()->
15971607
match fsiConsoleInput.TryGetFirstLine()with
15981608
| Some firstLine-> firstLine
1599-
| None-> console.ReadLine())
1609+
| None->
1610+
if!progressthen printfn"have console... calling ReadLine..."
1611+
console.ReadLine())
16001612
|_->
1601-
LexbufFromLineReader fsiStdinSyphon(fun()-> fsiConsoleInput.In.ReadLine()|> removeZeroCharsFromString)
1613+
1614+
LexbufFromLineReader fsiStdinSyphon(fun()->
1615+
if!progressthen printfn"no console... calling ReadLine..."
1616+
fsiConsoleInput.In.ReadLine()|> removeZeroCharsFromString)
16021617
#endif
16031618

16041619
fsiStdinSyphon.Reset();
@@ -1667,6 +1682,7 @@ type FsiInteractionProcessor(tcConfigB,
16671682
Parser.interaction lexerWhichSavesLastToken tokenizer.LexBuffer)
16681683
Some input
16691684
with e->
1685+
if!progressthen fprintfn fsiConsoleOutput.Out"Error in ParseInteraction:%s"(e.ToString())
16701686
// On error, consume tokens until to ;; or EOF.
16711687
// Caveat: Unless the error parse ended on ;; - so check the lastToken returned by the lexer function.
16721688
// Caveat: What if this was a look-ahead? That's fine! Since we need to skip to the ;; anyway.
@@ -2409,8 +2425,10 @@ type internal FsiEvaluationSession (argv:string[], inReader:TextReader, outWrite
24092425

24102426
DriveFsiEventLoop fsiConsoleOutput
24112427
#else
2428+
progress:= condition"FSHARP_INTERACTIVE_PROGRESS"
24122429
// Update the console completion function now we've got an initial type checking state.
24132430
// This means completion doesn't work until the initial type checking state has finished loading - fair enough!
2431+
if!progressthen fprintfn fsiConsoleOutput.Out"Run: Calling TryGetConsole"
24142432
match fsiConsoleInput.TryGetConsole()with
24152433
| Some consolewhen fsiOptions.EnableConsoleKeyProcessing->
24162434
console.SetCompletionFunction(fun(s1,s2)-> fsiIntellisenseProvider.CompletionsForPartialLID!istateRef(match s1with| Some s-> s+"."+ s2| None-> s2)|> Seq.ofList)
@@ -2430,7 +2448,10 @@ type internal FsiEvaluationSession (argv:string[], inReader:TextReader, outWrite
24302448
errorLogger.AbortOnError()
24312449
)
24322450

2451+
24332452
if fsiOptions.Interactthen
2453+
2454+
if!progressthen fprintfn fsiConsoleOutput.Out"Run: Interact..."
24342455
// page in the type check env
24352456
istateRef:= fsiInteractionProcessor.LoadDummyInteraction!istateRef
24362457
if!progressthen fprintfn fsiConsoleOutput.Out"MAIN: InstallKillThread!";
@@ -2479,7 +2500,9 @@ type internal FsiEvaluationSession (argv:string[], inReader:TextReader, outWrite
24792500
DriveFsiEventLoop fsiConsoleOutput
24802501

24812502
else// not interact
2503+
if!progressthen fprintfn fsiConsoleOutput.Out"Run: not interact, loading intitial files..."
24822504
istateRef:= fsiInteractionProcessor.LoadInitialFiles(false,!istateRef)
2505+
if!progressthen fprintfn fsiConsoleOutput.Out"Run: done..."
24832506
exit(min errorLogger.ErrorCount1)
24842507

24852508
// The Ctrl-C exception handler that we've passed to native code has

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp