From 8033c6fa9ac756cc5bad052f1e774137d1789b5f Mon Sep 17 00:00:00 2001 From: Diogo Condeco Date: Tue, 31 Jan 2017 18:37:00 +0000 Subject: [PATCH] Eeschema one field dialog text selection. This patch selects the text in the dialog_one_field. For annotated symbols the number is selected. For unannotated symbols the ? is selected. All other cases the entire text is selected, including references in library editor. --- eeschema/dialogs/dialog_edit_one_field.cpp | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/eeschema/dialogs/dialog_edit_one_field.cpp b/eeschema/dialogs/dialog_edit_one_field.cpp index a02c957366..1f1189ec3e 100644 --- a/eeschema/dialogs/dialog_edit_one_field.cpp +++ b/eeschema/dialogs/dialog_edit_one_field.cpp @@ -168,6 +168,39 @@ bool DIALOG_EDIT_ONE_FIELD::TransferDataToWindow() wxLogDebug( "In DIALOG_EDIT_ONE_FIELD::TransferDataToWindow()" ); m_TextValue->SetValue( m_text ); + + if( m_fieldId == REFERENCE ) + { + if( m_text.find_first_of( '?' ) != m_text.npos ) + { + m_TextValue->SetSelection( m_text.find_first_of( '?' ), + m_text.find_last_of( '?' ) + 1 ); + } + else + { + wxString num = m_text; + + while( !num.IsEmpty() && ( !isdigit( num.Last() ) || + !isdigit( num.GetChar( 0 ) ) ) ) + { + if( !isdigit( num.Last() ) ) + num.RemoveLast(); + if( !isdigit( num.GetChar ( 0 ) ) ) + num = num.Right( num.Length() - 1); + } + + m_TextValue->SetSelection( m_text.Find( num ), + m_text.Find( num ) + num.Length() ); + + if( num.IsEmpty() ) + m_TextValue->SetSelection( -1, -1 ); + } + } + else + { + m_TextValue->SetSelection( -1, -1 ); + } + m_Orient->SetValue( m_orientation ); m_TextSize->SetValue( StringFromValue( g_UserUnit, m_size ) ); m_TextHJustificationOpt->SetSelection( m_horizontalJustification );