Skip to content

Commit

Permalink
adapt time links to translation ref #11859
Browse files Browse the repository at this point in the history
Signed-off-by: m-kro <[email protected]>
  • Loading branch information
m-kro committed Nov 1, 2023
1 parent 842a2a1 commit f722bba
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/utils/gui/div/GUIMessageWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,21 @@ GUIMessageWindow::setCursorPos(FXint pos, FXbool notify) {
const int lookback = MIN2(pos, 20);
const int start = MAX2(lineStart(pos), pos - lookback);
const FXString candidate = text.mid(start, lineEnd(pos) - start);
FXint timePos = candidate.find(" time") + 6;
SUMOTime t = -1;
if (pos >= 0 && pos > start + timePos) {
t = getTimeString(candidate, timePos, 0, candidate.length());
if (t >= 0) {
t += myBreakPointOffset;
std::vector<SUMOTime> breakpoints = myMainWindow->retrieveBreakpoints();
if (std::find(breakpoints.begin(), breakpoints.end(), t) == breakpoints.end()) {
breakpoints.push_back(t);
std::sort(breakpoints.begin(), breakpoints.end());
myMainWindow->setBreakpoints(breakpoints);
myMainWindow->setStatusBarText("Set breakpoint at " + time2string(t));
FXint timePos = candidate.find(TL(" time"));
if (timePos > -1) {
timePos += 6;
SUMOTime t = -1;
if (pos >= 0 && pos > start + timePos) {
t = getTimeString(candidate, timePos, 0, candidate.length());
if (t >= 0) {
t += myBreakPointOffset;
std::vector<SUMOTime> breakpoints = myMainWindow->retrieveBreakpoints();
if (std::find(breakpoints.begin(), breakpoints.end(), t) == breakpoints.end()) {
breakpoints.push_back(t);
std::sort(breakpoints.begin(), breakpoints.end());
myMainWindow->setBreakpoints(breakpoints);
myMainWindow->setStatusBarText(TLF("Set breakpoint at %", time2string(t)));
}
}
}
}
Expand Down Expand Up @@ -237,7 +240,7 @@ GUIMessageWindow::appendMsg(GUIEventType eType, const std::string& msg) {
pos = text.find("'", pos + 1);
}
// find time links
pos = text.find(" time");
pos = text.find(TL(" time"));
SUMOTime t = -1;
if (pos >= 0) {
t = getTimeString(text, pos + 6, 0, text.length());
Expand Down

3 comments on commit f722bba

@behrisch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m-kro Shouldn't this check for the length of the translated string instead of always assuming 6?

@m-kro
Copy link
Contributor Author

@m-kro m-kro commented on f722bba Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolutely right...

@behrisch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #14041

Please sign in to comment.