1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 08:09:32 +02:00

Fix \n shenanigans in command output.

This commit is contained in:
James Crook 2018-02-11 09:00:23 +00:00 committed by Paul Licameli
parent 65c160212e
commit 510f68e9ad
4 changed files with 25 additions and 25 deletions

View File

@ -39,7 +39,7 @@ print( "-- File to read from has now been opened too\r\n" )
def sendCommand( command ) : def sendCommand( command ) :
print( "Send: >>> "+command ) print( "Send: >>> \n"+command )
tofile.write( command + EOL ) tofile.write( command + EOL )
tofile.flush() tofile.flush()
@ -55,7 +55,7 @@ def getResponse() :
def doCommand( command ) : def doCommand( command ) :
sendCommand( command ) sendCommand( command )
response = getResponse() response = getResponse()
print( "Rcvd: <<< " + response ) print( "Rcvd: <<< \n" + response )
return response return response
def do( command ) : def do( command ) :
@ -63,9 +63,6 @@ def do( command ) :
def quickTest() : def quickTest() :
do( 'Help: Command=Help' ) do( 'Help: Command=Help' )
do( 'Help: Command="SetTrackInfo"' )
do( 'SetPreference: Name=GUI/Theme Value=light Reload=false' )
def setup() : def setup() :
global path global path
@ -169,25 +166,20 @@ def image8() :
# Zoomed in to show points stem-plot # Zoomed in to show points stem-plot
def image9() : def image9() :
global path global path
do( 'SetPreference: Name=/GUI/SampleView Value=1 Reload=True')
makeMonoTracks(1) makeMonoTracks(1)
do( 'SelectTime: StartTime=0 EndTime=0.003' ) do( 'SelectTime: StartTime=0 EndTime=0.003' )
do( 'ZoomSel' ); do( 'ZoomSel' );
do( 'Amplify: Ratio=3.0' ) do( 'Amplify: Ratio=3.0' )
do( 'SetPreference: Name=/GUI/SampleView Value=1 Reload=1')
do( 'Screenshot: Path='+path+' CaptureWhat=First_Track' ) do( 'Screenshot: Path='+path+' CaptureWhat=First_Track' )
# Zoomed in to show points no stem plot # Zoomed in to show points no stem plot
def image10() : def image9and10() :
global path global path
do( 'SetPreference: Name=/GUI/SampleView Value=0 Reload=True') image9()
makeMonoTracks(1) do( 'SetPreference: Name=/GUI/SampleView Value=0 Reload=1')
do( 'SelectTime: StartTime=0 EndTime=0.003' )
do( 'ZoomSel' );
do( 'Amplify: Ratio=3.0' )
do( 'Screenshot: Path='+path+' CaptureWhat=First_Track' ) do( 'Screenshot: Path='+path+' CaptureWhat=First_Track' )
#quickTest() #quickTest()
setup() setup()
image1() image1()
@ -198,6 +190,5 @@ image5()
image6() image6()
image7() image7()
image8() image8()
image9() image9and10()
image10()

View File

@ -1,6 +1,6 @@
# pipe-test.py # pipe_test.py
# Tests the audacity pipe. Sends 3 commands. # Tests the audacity pipe. Sends 3 commands.
# Keep pipe-test.py short!! # Keep pipe_test.py short!!
# You can make more complicated longer tests to test other functionality # You can make more complicated longer tests to test other functionality
# or to generate screenshots etc in other scripts. # or to generate screenshots etc in other scripts.
@ -41,7 +41,7 @@ print( "-- File to read from has now been opened too\r\n" )
def sendCommand( command ) : def sendCommand( command ) :
print( "Send: >>> "+command ) print( "Send: >>> \n"+command )
tofile.write( command + EOL ) tofile.write( command + EOL )
tofile.flush() tofile.flush()
@ -57,7 +57,7 @@ def getResponse() :
def doCommand( command ) : def doCommand( command ) :
sendCommand( command ) sendCommand( command )
response = getResponse() response = getResponse()
print( "Rcvd: <<< " + response ) print( "Rcvd: <<< \n" + response )
return response return response
def do( command ) : def do( command ) :
@ -65,7 +65,7 @@ def do( command ) :
def quickTest() : def quickTest() :
do( 'Help: Command=Help' ) do( 'Help: Command=Help' )
do( 'Help: Command="SetTrackInfo"' ) #do( 'Help: Command="GetInfo"' )
do( 'SetPreference: Name=GUI/Theme Value=light Reload=false' ) do( 'SetPreference: Name=GUI/Theme Value=dark Reload=1' )
quickTest() quickTest()

View File

@ -149,7 +149,8 @@ bool ApplyAndSendResponse::Apply()
bool bResult = mCommand->Apply(*( mCtx.get())); bool bResult = mCommand->Apply(*( mCtx.get()));
return bResult; } return bResult; }
); );
wxString response = GetName(); wxString response = wxT( "\n" );
response += GetName();
// These three strings are deliberately not localised. // These three strings are deliberately not localised.
// They are used in script responses and always happen in English. // They are used in script responses and always happen in English.
response += wxT(" finished: "); response += wxT(" finished: ");

View File

@ -218,17 +218,25 @@ class ResponseQueueTarget final : public CommandMessageTarget
{ {
private: private:
ResponseQueue &mResponseQueue; ResponseQueue &mResponseQueue;
wxString mBuffer;
public: public:
ResponseQueueTarget(ResponseQueue &responseQueue) ResponseQueueTarget(ResponseQueue &responseQueue)
: mResponseQueue(responseQueue) : mResponseQueue(responseQueue),
mBuffer( wxEmptyString )
{ } { }
virtual ~ResponseQueueTarget() virtual ~ResponseQueueTarget()
{ {
if( mBuffer.StartsWith("\n" ) )
mBuffer = mBuffer.Mid( 1 );
mResponseQueue.AddResponse( mBuffer );
mResponseQueue.AddResponse(wxString(wxT("\n"))); mResponseQueue.AddResponse(wxString(wxT("\n")));
} }
void Update(const wxString &message) override void Update(const wxString &message) override
{ {
mResponseQueue.AddResponse(message); mBuffer += message;
#if 0
mResponseQueue.AddResponse(message);
#endif
} }
}; };