7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-03-30 06:16:56 +00:00

Ease in a bit more fmt::format().

This commit is contained in:
Jeff Young 2025-03-11 10:08:04 +00:00
parent b569d919ea
commit b11b1a6f72
7 changed files with 30 additions and 37 deletions

View File

@ -327,40 +327,35 @@ bool DSNLEXER::IsSymbol( int aTok )
void DSNLEXER::Expecting( int aTok ) const
{
wxString errText = wxString::Format(
_( "Expecting %s" ), GetTokenString( aTok ) );
wxString errText = wxString::Format( _( "Expecting %s" ), GetTokenString( aTok ) );
THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
}
void DSNLEXER::Expecting( const char* text ) const
{
wxString errText = wxString::Format(
_( "Expecting '%s'" ), wxString::FromUTF8( text ) );
wxString errText = wxString::Format( _( "Expecting '%s'" ), wxString::FromUTF8( text ) );
THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
}
void DSNLEXER::Unexpected( int aTok ) const
{
wxString errText = wxString::Format(
_( "Unexpected %s" ), GetTokenString( aTok ) );
wxString errText = wxString::Format( _( "Unexpected %s" ), GetTokenString( aTok ) );
THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
}
void DSNLEXER::Duplicate( int aTok )
{
wxString errText = wxString::Format(
_("%s is a duplicate"), GetTokenString( aTok ).GetData() );
wxString errText = wxString::Format( _("%s is a duplicate"), GetTokenString( aTok ).GetData() );
THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
}
void DSNLEXER::Unexpected( const char* text ) const
{
wxString errText = wxString::Format(
_( "Unexpected '%s'" ), wxString::FromUTF8( text ) );
wxString errText = wxString::Format( _( "Unexpected '%s'" ), wxString::FromUTF8( text ) );
THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
}

View File

@ -26,6 +26,7 @@
#include <cstring>
#include <memory>
#include <wx/translation.h>
#include <fmt/format.h>
#include <ki_exception.h>
#include <macros.h> // TO_UTF8()
@ -276,8 +277,8 @@ bool LIB_ID::isLegalLibraryNameChar( unsigned aUniChar )
const wxString LIB_ID::GetFullLibraryName() const
{
wxString suffix = m_subLibraryName.wx_str().IsEmpty()
? wxString( wxS( "" ) )
: wxString::Format( wxT( " - %s" ), m_subLibraryName.wx_str() );
return wxString::Format( wxT( "%s%s" ), m_libraryName.wx_str(), suffix );
if( m_subLibraryName.empty() )
return m_libraryName.c_str();
return fmt::format( "{} - {}", m_libraryName.c_str(), m_subLibraryName.c_str() );
}

View File

@ -26,6 +26,7 @@
#include <wx/statusbr.h>
#include <wx/gauge.h>
#include <wx/stattext.h>
#include <fmt/format.h>
#include <array>
#include <widgets/kistatusbar.h>
#include <widgets/bitmap_button.h>
@ -214,9 +215,7 @@ void KISTATUSBAR::SetNotificationCount(int aCount)
wxString cnt = "";
if( aCount > 0 )
{
cnt = wxString::Format( "%d", aCount );
}
cnt = fmt::format( "{}", aCount );
m_notificationsButton->SetBadgeText( cnt );

View File

@ -23,7 +23,7 @@
#include <gal/color4d.h>
#include <widgets/number_badge.h>
#include <fmt/format.h>
#include <algorithm>
#include <kiplatform/ui.h>
@ -127,7 +127,7 @@ void NUMBER_BADGE::computeSize()
{
wxClientDC dc( this );
wxString test = wxString::Format( wxT( "%d" ), m_currentNumber );
wxString test = fmt::format( "{}", m_currentNumber );
int len = test.length();
// Determine the size using the string "m999{+}" where the 'm' on the front serves as a margin
@ -177,9 +177,9 @@ void NUMBER_BADGE::onPaint( wxPaintEvent& aEvt )
// Cap the number displayed and add the "+" to the end if required
if( m_currentNumber > m_maxNumber )
text = wxString::Format( wxT( "%d+" ), m_maxNumber );
text = fmt::format( "{}+", m_maxNumber );
else
text = wxString::Format( wxT( "%d" ), m_currentNumber );
text = fmt::format( "{}", m_currentNumber );
dc.SetFont( wxFont( m_textSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, BADGE_FONTWEIGHT ) );
dc.SetTextForeground( m_textColour );

View File

@ -27,6 +27,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fmt/format.h>
#include <pcb_base_frame.h>
#include <string_utils.h>
#include <widgets/msgpanel.h>
@ -86,7 +87,7 @@ void NETINFO_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANE
aList.emplace_back( _( "Net Name" ), UnescapeString( GetNetname() ) );
aList.emplace_back( _( "Net Code" ), wxString::Format( wxT( "%d" ), GetNetCode() ) );
aList.emplace_back( _( "Net Code" ), fmt::format( "{}", GetNetCode() ) );
// Warning: for netcode == NETINFO_LIST::ORPHANED, the parent or the board can be NULL
BOARD * board = m_parent ? m_parent->GetBoard() : nullptr;
@ -105,7 +106,7 @@ void NETINFO_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANE
}
}
aList.emplace_back( _( "Pads" ), wxString::Format( wxT( "%d" ), count ) );
aList.emplace_back( _( "Pads" ), fmt::format( "{}", count ) );
count = 0;
@ -120,7 +121,7 @@ void NETINFO_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANE
}
}
aList.emplace_back( _( "Vias" ), wxString::Format( wxT( "%d" ), count ) );
aList.emplace_back( _( "Vias" ), fmt::format( "{}", count ) );
if( startTrack )
{

View File

@ -52,6 +52,7 @@
#include <functional>
#include <memory>
#include <thread>
#include <fmt/format.h>
using namespace std::placeholders;
@ -712,11 +713,11 @@ void PCB_DRAW_PANEL_GAL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
}
}
aList.emplace_back( _( "Pads" ), wxString::Format( wxT( "%d" ), padCount ) );
aList.emplace_back( _( "Vias" ), wxString::Format( wxT( "%d" ), viaCount ) );
aList.emplace_back( _( "Track Segments" ), wxString::Format( wxT( "%d" ), trackSegmentCount ) );
aList.emplace_back( _( "Nets" ), wxString::Format( wxT( "%d" ), (int) netCodes.size() ) );
aList.emplace_back( _( "Unrouted" ), wxString::Format( wxT( "%d" ), unconnected ) );
aList.emplace_back( _( "Pads" ), fmt::format( "{}", padCount ) );
aList.emplace_back( _( "Vias" ), fmt::format( "{}", viaCount ) );
aList.emplace_back( _( "Track Segments" ), fmt::format( "{}", trackSegmentCount ) );
aList.emplace_back( _( "Nets" ), fmt::format( "{}", (int) netCodes.size() ) );
aList.emplace_back( _( "Unrouted" ), fmt::format( "{}", unconnected ) );
}

View File

@ -1814,16 +1814,12 @@ void PCB_TRACK::GetMsgPanelInfoBase_Common( EDA_DRAW_FRAME* aFrame,
#if 0 // Enable for debugging
if( GetBoard() )
aList.emplace_back( _( "NetCode" ), wxString::Format( wxT( "%d" ), GetNetCode() ) );
aList.emplace_back( _( "NetCode" ), fmt::format( "{}", GetNetCode() ) );
aList.emplace_back( wxT( "Flags" ), wxString::Format( wxT( "0x%08X" ), m_flags ) );
aList.emplace_back( wxT( "Flags" ), fmt::format( "#08X", m_flags ) );
aList.emplace_back( wxT( "Start pos" ), wxString::Format( wxT( "%d %d" ),
m_Start.x,
m_Start.y ) );
aList.emplace_back( wxT( "End pos" ), wxString::Format( wxT( "%d %d" ),
m_End.x,
m_End.y ) );
aList.emplace_back( wxT( "Start pos" ), fmt::format( "{} {}", m_Start.x, m_Start.y ) );
aList.emplace_back( wxT( "End pos" ), fmt::format( "{} {}", m_End.x, m_End.y ) );
#endif
if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )