25#include <wx/datetime.h>
27#include <wx/listctrl.h>
29#include <wx/splitter.h>
47 if( !lock.owns_lock() )
56 std::sort( aBranches.begin(), aBranches.end(),
59 if( aLeft.isCurrent != aRight.isCurrent )
60 return aLeft.isCurrent;
62 if( aLeft.isRemote != aRight.isRemote )
63 return !aLeft.isRemote;
65 if( aLeft.when.IsValid() != aRight.when.IsValid() )
66 return aLeft.when.IsValid();
68 if( aLeft.when.IsValid() && aLeft.when != aRight.when )
69 return aLeft.when > aRight.when;
71 return aLeft.name < aRight.name;
78 if( !aWhen.IsValid() )
81 wxTimeSpan diff = wxDateTime::Now() - aWhen;
83 if( diff.GetSeconds() < 60 )
84 return _(
"just now" );
86 if( diff.GetMinutes() < 60 )
87 return wxString::Format(
_(
"%d minutes ago" ),
static_cast<int>( diff.GetMinutes() ) );
89 if( diff.GetHours() < 24 )
90 return wxString::Format(
_(
"%d hours ago" ),
static_cast<int>( diff.GetHours() ) );
92 if( diff.GetDays() < 30 )
93 return wxString::Format(
_(
"%d days ago" ),
static_cast<int>( diff.GetDays() ) );
95 return aWhen.FormatISODate();
101 if( !aSplitter->IsSplit() )
104 aSashPos = aSplitter->GetSashPosition();
105 aSplitter->Unsplit( aPane );
116 aButton->SetLabelMarkup( wxString::Format( wxS(
"<span foreground='%s'>%s</span>" ),
117 colour.GetAsString( wxC2S_HTML_SYNTAX ), aButton->GetLabel() ) );
125 const size_t at = aEmail.find(
'@' );
127 if( at == wxString::npos || at == 0 || aEmail.find(
'@', at + 1 ) != wxString::npos )
130 const wxString domain = aEmail.Mid( at + 1 );
131 const size_t dot = domain.find(
'.' );
133 if( dot == wxString::npos || dot == 0 || dot + 1 == domain.length() )
136 for(
const wxUniChar& c : aEmail )
148 wxString
name = aName;
150 if(
name.Trim(
true ).Trim(
false ).IsEmpty() )
152 aError =
_(
"Enter your name. It is recorded as the author of your commits." );
158 aError =
_(
"Enter a valid email address. It is recorded as the author of your commits." );
168 long sel = aList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
171 return wxEmptyString;
173 return aList->GetItemText( sel, aColumn );
wxColour ToColour() const
The project's git session.
std::unique_lock< std::mutex > TryLockAction()
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
This file is part of the common library.
static bool looksLikeAnEmailAddress(const wxString &aEmail)
void SortBranchesForDisplay(std::vector< KIGIT_BRANCH_INFO > &aBranches)
Put the current branch first, then local and remote branches with the newest tips first.
wxString BusyMessage()
What every caller says when it finds the session already busy.
void UnsplitKeepingSash(wxSplitterWindow *aSplitter, wxWindow *aPane, int &aSashPos)
Close a splitter's second pane, keeping the sash where the user left it for next time.
void ShowBusyMessage(wxWindow *aParent)
Show a busy message for a user action. UI thread only.
std::unique_lock< std::mutex > TryLockAction(KIGIT_COMMON &aCommon, wxWindow *aParent)
Try the action lock and show a busy message if it is unavailable.
bool ValidateIdentity(const wxString &aName, const wxString &aEmail, wxString &aError)
Check a name and email for recording commits. False leaves the reason in aError.
wxString SelectedText(wxListCtrl *aList, int aColumn)
The text of the selected row in a report list, or empty when nothing is selected.
wxString RelativeDate(const wxDateTime &aWhen)
"just now", "3 hours ago", or the ISO date once it is more than a month old.
void MarkDestructive(wxButton *aButton)
Paint a button's text the diff's red, for one that throws something away.
Diff colors with defaults for light backgrounds.
static DIFF_COLOR_THEME ForText(bool aDarkTheme)
Resolve change colors for UI text. Pass the desktop theme captured on the UI thread.