qtcreator does not autocomplete when structure bindings is used? - for-loop

I seem to have an issue with qtcreator not autocompleting my code, which is getting pretty annoying.
Currently is it not able to autocomplete when i try to use structure bindings in for loops like this..
std::vector<pair<string,AudioFile<double>>> list_of_files;
// Some init of list_of_file
for (const auto& [name,file]: this->list_of_files) // red line under this.. does seem to like structure bindings?
{
file.printSummary(); // qtcreator don't offer any autocomplete options?
}
qtcreator basically complains about everything about the code posted above..
But when I write it like this:
for (int i = 0 ; i <list_of_file.size() ; i++) // No red lines under this..
{
list_of_files[i].second.printSummary() // Autocompletes without any problems.
}
qtcreator does not complain about this code, and seem to autocomplete it just fine.. So why is it causing so many problems with c++17 style?
Any fixes for this?

A temporary solution for this seem to be something like this - which autocompletions does not complain about, and seem to suit my definition of (readability):
for ( const auto &elements : this->list_of_files)
{
auto name = std::get<0>(elements);
auto file = std::get<1>(elements);
}

Related

VSCode keeps breaking small objects into multiple lines

I don't know what's causing this. I love having auto-format on save. But there is a rule that keeps making objects jump into multiple lines. When I type something like this:
const { promisify } = require("util");
VSCode formats it to:
const {
promisify
} = require("util");
It looks very ugly.
for html formatting:
"html.format.wrapAttributes": "force-aligned",
Nevermind I found it. It was the beautify plugin.

QTextImageFormat not exported to HTML

I have an QTextEdit with some images and i've changed their QTextImageFormat.
But QTextEdit::toHtml() does not export their styles (loading works).
Does anybody have an idea for a workaround?
WebKit is not an option, it's an ancient Project.
It is possible to convert the contents of QTextDocument to another format using QTextBlock. As the official documentation says,
QTextBlock provides read-only access to the block/paragraph structure of QTextDocuments. It is mainly of use <...> if you want to iterate over a document and write out the contents in your own custom format.
The iteration over the contents of QTextEdit's QTextDocument would look like this:
QTextEdit * editor = new QTextEdit;
<...> // fill the editor contents
QTextDocument * doc = editor->document();
for (QTextBlock currentBlock = doc->begin(); currentBlock != doc->end(); currentBlock = currentBlock.next())
{
<...> // optionally process the block itself somehow - look at its QTextBlockFormat, for example
for(QTextBlock::iterator it = currentBlock.begin(); !it.atEnd(); ++it)
{
QTextFragment currentFragment = it.fragment();
if (currentFragment.isValid()) {
processFragment(currentFragment);
}
}
}
See the documentation for QTextFragment to understand how you might implement processFragment from the above example.
On the other hand, you say that WebKit is not an option - OK but there's a replacement for it - Qt WebEngine. I have some experience of implementing a text editor with a few "advanced features" using Qt WebEngine as a backend and I can say it's much harder to achieve than with Qt WebKit but possible.

Is there any way to set options in beautify extension for Ace Editor?

I've found the beautify extension in Ace editor but I don't see any examples of how to use it. Is there a way to set any options?
Example what I have so far:
var beautiful = ace.require("ace/ext/beautify"); // get extension
var editor = ace.edit("editor"); // reference to our editor
editor.setValue(someCode); // add some code to the editor
beautiful.beautify(editor.session); // beautify the code
When I call this method the code is formatted but it is all unindented / outdented all the way to the left and some spaces are removed. It doesn't look quite right. So I want to know if there are any options. I looked at the code but it is minified. Which is why I'm asking this question here.
Before call:
After call:
UPDATE:
I found an unminifed copy of the extension. It looks like there are no options and it looks like it only works for PHP:
exports.beautify = function(session) {
var iterator = new TokenIterator(session, 0, 0);
var token = iterator.getCurrentToken();
var context = session.$modeId.split("/").pop();
var code = phpTransform(iterator, context);
session.doc.setValue(code);
};
I did not find any options in the beautify.js code for the beautify() method. I found a comment saying that it is not being worked on or supported any more. I do not have the source but it said it was not working and was then abandoned.
It might work alright for JavaScript but is not working well for ActionScript.

Is there any setting in Xcode to have all autocomplete code follow a different curly bracket style?

Per Wikipedia, Xcode defaults to using the K&R brace/indentation style. It looks like this:
- (void) someFunction {
if (condition) {
// do this
} else
// do that;
}
}
I've grown up with a strong preference for Allman style, which looks like this:
- (void) someFunction
{
if (condition)
{
// do this
}
else
{
// do that
}
}
It's not too much of a chore just to return the bracket of a code-completed statement to the next line, but if I could tell Xcode to do this for me, it would save me a lot of meticulous click-and-return'ing.
I don't think you can remove the K&R braced code snippets, but you could simply create your own Allman-style snippets and add them to the Xcode "Code Snippet Library". It's a cumbersome solution, but it works.
So, when writing your snippets, you can use the <# and #> to delimit your expressions. Thus:
if (<#condition#>)
{
<#statements-if-true#>
}
else
{
<#statements-if-false#>
}
Then drag and drop that onto your snippet library:
And give it a meaningful name and shortcut:
Now when you start typing, you'll leverage the new snippet:
Go ahead and give your snippet a unique completion shortcut if you want to make disambiguation even easier.
There are more effective uses of the snippet library, but it can be used to address your problem.

Column Indentation Guide on Textmate

I'd like to know if there's a bundle or a preference somewhere in Textmate to get Sublime's white dotted column delimiter. Look at the screenshots.
Look at this PHP function in Textmate
(source: darwinsantos.com)
Now look at it in Sublime.
(source: darwinsantos.com)
If you take a close look notice that in Sublime the beginning and ending curly brace are bound by a white dotted line that let's you know that both curly braces are aligned in the exact same column.
Is there a way to get this in Textmate?
Update (5/2016): TextMate has gotten indent guides! As of version 2.0-beta.9.2 View->Show Indent Guides. They're a work in progress, but they are available.
Update: If you're able to get this working and are willing to build your own textmate via the official instructions, then you might have a crack a building (and maybe even contributing to) my fold guides enabled version of TextMate2. There are no builds, and it is not ready to be introduced into TextMate2 yet as it lacks a setting to disable the guides.
This is a feature in development, when complete it will be significantly more intelligent than what I'm about to describe. The new version, when it eventually comes out, will respect the indentation rules of the language, rather than simply filling in pairs of spaces/tabs.
That said, I've used this to ensure countless lines of templates are perfect.
The method is updated, but otherwise the same as described for Textmate1 by Cocabits.
You will end up with something like this:
Note the second to last line, lacking the white space to trigger the lines. The new version will be much closer to Sublime's
First we are going to need to teach TextMate how to identify the tabs and spaces which we use before each line of code.
I have created a fold guides bundle however this is the first time I've given it out and I am terrified it just won't work for you, that said give it a try.
If it doesn't work, you will need to manually add these rules, I will show you how to make it its own bundle, but you could add it directly to any language you like.
Create a bundle from Bundles->Edit Bundles, then, File->New, select bundle and give it a name, then File->New and make a grammar. The grammar should have this code:
{ patterns = (
{ include = '#leading-spaces'; },
{ name = 'meta.leading-tabs';
begin = '^(?=\t)';
end = '(?=[^\t])';
patterns = (
{ match = '(\t)(\t)?';
captures = {
1 = { name = 'meta.odd-tab'; };
2 = { name = 'meta.even-tab'; };
};
},
);
},
);
repository = {
leading-spaces = {
begin = '^(?=\s\s)';
end = '(?=[^\s\s])';
patterns = (
{ match = '(\s\s)(\s\s)?';
captures = {
1 = { name = 'meta.odd-tab'; };
2 = { name = 'meta.even-tab'; };
};
},
);
};
};
}
And the inspector should look like this:
Now we just need a theme rule to match 'meta.even-tab' and or 'meta.odd-tab', so just add this to your current theme:
{name = 'Alternating Tabs';
scope = 'meta.even-tab';
settings = {
background = '#232323';
};
}

Resources