Skip to content

Instantly share code, notes, and snippets.

@RolandHughes
Last active February 29, 2024 16:47
Show Gist options
  • Save RolandHughes/e3515220cbcd36c6ee3569139c2ef9a9 to your computer and use it in GitHub Desktop.
Save RolandHughes/e3515220cbcd36c6ee3569139c2ef9a9 to your computer and use it in GitHub Desktop.
Snippet from EdtBaseWidget called when [GOLD] 7 command of GIST issued
void EdtBaseWidget::handleSendToGitHubCommand( QString text )
{
QString rangeStr {text.mid( text.indexOf( ' ' ) ).trimmed()};
QString cmd {text.left( text.indexOf( ' ' ) ).trimmed()};
/*
* TODO:: Need to handle /PRI for private /PUB for public
* /NAM=somefile.nam
* /DESC="my description with spaces" or /DESC='my description with spaces'
*
* before range
*/
QString description {"my gist test"};
QString fileName {QDateTime::currentDateTime().toString( "yyyy-MM-dd_hhmmsszzz" ) + ".txt"};
bool publicGist { true};
sptr_t rangeStart {0};
sptr_t rangeEnd {0};
sptr_t startLineNo {0};
sptr_t endLineNo {0};
if ( calcTargetRange( rangeStr, rangeStart, rangeEnd, startLineNo, endLineNo ) )
{
QByteArray text {textRange( rangeStart, rangeEnd )};
sendToGist( text, description, fileName, publicGist );
}
else
{
QString msg = "Invalid range";
timedMessage( msg, STANDARD_MSG_TIME );
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment