Skip to content

Commit

Permalink
support for quoted OSC strings
Browse files Browse the repository at this point in the history
/osc=abc -> arg[0]=abc
/osc=abc,def -> arg[0]=abc arg[1]=def
/osc="abc,def" -> arg[0]=abc,def
/osc="abc,","def," -> arg[0]=abc, arg[1]=def,
/osc="""abc,def""" -> arg[0]="abc,def"
/osc="""abc,""","""def,""" -> arg[0]="abc," arg[1]="def,"
  • Loading branch information
MizPlusPlus committed Jan 10, 2019
1 parent 34d46fb commit 6bec54f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion OSCWidgets/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

////////////////////////////////////////////////////////////////////////////////

#define APP_VERSION "0.9"
#define APP_VERSION "0.10"

#define MIN_OPACITY 10

Expand Down
3 changes: 2 additions & 1 deletion OSCWidgets/ToyCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ FadeCmd::FadeCmd(QWidget *parent)

void FadeCmd::AutoSizeFont()
{
QFont fnt( font() );
QFont fnt("Monospace");
fnt.setStyleHint(QFont::TypeWriter);
fnt.setPixelSize( qMax(10,qRound(height()*0.6)) );
setFont(fnt);
}
Expand Down
36 changes: 18 additions & 18 deletions OSCWidgets/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,35 +69,35 @@ void Utils::GetItemsFromQuotedString(const QString &str, QStringList &items)
if(i>=len || (str[i]==QChar(',') && !quoted))
{
int itemLen = (i - index);
if(itemLen > 0)
{
QString item( str.mid(index,itemLen).trimmed() );

// remove quotes
if(item.startsWith('\"') && item.endsWith('\"'))
QString item;
item.reserve(itemLen);
for(int j=0; j<itemLen; ++j)
{
int itemIndex = (index + j);
if(str[itemIndex] == QChar('\"'))
{
itemLen = (item.size() - 2);
if(itemLen > 0)
item = item.mid(1, itemLen);
else
item.clear();
if((j+1)<itemLen && str[itemIndex+1]==QChar('\"'))
{
item.append(QChar('\"'));
++j;
}
}

// fix quoted quotes
item.replace("\"\"", "\"");

items.push_back(item);
else
item.append(str[itemIndex]);
}
else
items.push_back( QString() );

items.push_back(item.trimmed());

index = (i+1);
}
else if(str[i] == QChar('\"'))
{
if( !quoted )
quoted = true;
else if((i+1)>=len || str[i+1]!=QChar('\"'))
else if((i+1)<len && str[i+1]==QChar('\"'))
++i;
else
quoted = false;
}
}
Expand Down

0 comments on commit 6bec54f

Please sign in to comment.