How to set crlf endings in QtCreator on linux - qt

I want to set QtCreator to use CRLF instead of LF in unix. Is there a way to do that?
PS: I know I can use dos2unix on the files however I don't want to do that.

The next QtCreator version will have the possibility to change the line endings for an open document from the toolbar.
Depending on the time I'll try to also try to make a default option into QtCreator settings for newly created files.

It is bug in QtCreator - https://bugreports.qt.io/browse/QTCREATORBUG-3590
May be some one reopen it again.

Some possibilities: 1. I notice once QtCreator opens a CRLF file in Linux, it treats it like a CRLF file, so you'd only have to run dos2unix once on the file. 2. 'diff --strip-trailing-cr ...' works. 3. As mentioned in the comments, most version control systems can be set to do local or fixed line endings, so you may chase the problem in your VCS tool instead of Creator.
I tried out various encodings under Tools->Options->Editor, but none seem to affect the line ending (and I'm surprised Creator doesn't seem to have a setting for this--but option 4 is you can always get Creator's source code...)

Related

How do I tell Vim to use any/all dictionary files that fit a filepath wildcard glob?

I am trying to set the dictionary option (to allow autocompletion of certain words of my choosing) using wildcards in a filename glob, as follows:
:set dict+=$VIM/dict/dict*.lst
The hope is that, with this line in the initially sourced .vimrc (or, in my case of Windows 10, _vimrc), I can add different dictionary files to my $VIM/dict directory later, and each new invocation of Vim will use those dictionary files, without me needing to modify my .vimrc settings.
However, an error message says that there is no such file. When I give a specific filename (as in :set dict+=$VIM/dict/dict01.lst ), then it works.
The thing is, I could swear that this used to work. I had this setting in my .vimrc files since I started using Vim 7.1, and I don't recall any such error message until recently. Now it shows up on my Linux laptop as well as my Windows 7 and Windows 10 laptops. I can't remember exactly when this started happening.
Yes, I tried using backslashes (as in :set dict+=$VIM\dict\dict*.lst ) in case it was a Windows compatibility issue, but that still doesn't work. (Also this is happening on my Linux laptop, too, and that doesn't use backslashes for filepaths.)
Am I going senile? Or is there some other mysterious force going on?
Assuming for now that it is a change in the latest version of Vim, is there some way to specify "use all the dictionary files that fit this glob"?
-- Edited 2021-02-14 06:17:07
I also checked to see if it was due to having more than one file that fits the wildcard glob. (I thought that if I had more than one file that fit the wildcard, the glob would turn into two filenames, equivalent to saying dict+=$VIM/dict/dict01.lst dict02.lst which would not be syntactically valid.) But it still did not working after removing extra files so that only one file fit my pathname of $VIM/dict/dict*.lst . (I had previously put another Addendum here happily explaining that this was how I solved my problem, but it turned out to be premature.)
You must expand wildcards before setting an option. Multiple file names must be separated by commas. For example,
let &dictionary = tr(expand("$VIM/dict/dict*.lst"), "\n", ",")
If adding a value to a non-empty option, don't forget to add comma too (let is more universal than set, so it's less forgiving):
let &dictionary .= "," . tr(expand(...)...)

Customizing Powerleve10k prompt

I just added the Powerlevel10k theme to my zsh and i'm trying to configure certain parts.
It currently looks like this:
The ~/.p10k.zsh has a lot of configurations done and I've been trying to change certain things but i'm not there yet.
I don't want to print the whole path on the left prompt, just the directory. Also, not sure what those numbers indicate in the git section. And the right prompt is displaying my ruby version, although I haven't used Ruby in ages and want to change it to a different setting.
I've tried adding a PS1=... to .zshrc but it seems to be overriden by the P10K config file.
Any suggestions?
Display only the last directory segment
Open ~/.p10k.zsh.
Search for POWERLEVEL9K_SHORTEN_STRATEGY.
Change the value of this parameter to truncate_to_last.
Alternatively, change the value of POWERLEVEL9K_DIR_MAX_LENGTH to 1. This will maximally shorten current directory while keeping the transformation reversible. You can restore the original directory by copy-pasting the shortened directory to the command line and pressing TAB.
Ruby version
Powerlevel10k has several prompt segments that can display Ruby version. By default only those are enabled that display Ruby version when it has been manually overridden by some tool (e.g., rbenv or asdf).
To remove Ruby version from prompt:
Open ~/.p10k.zsh.
Search for POWERLEVEL9K_RIGHT_PROMPT_SEGMENTS.
Remove or comment out the following elements: rbenv, rvm and asdf.
Alternatively (and perhaps preferably), find out which tool is overriding Ruby version for you and remove the override if you no longer need it.
shorten dir segment to show only deepest directory
To show only last n significant path segments, you can set following in your config .zshrc, e.g n=1 means show only last folder in present working directory:
POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
See https://stackoverflow.com/a/49027654
explain Git symbols
The question/exclamation mark in Git segment (vcs segment, next to path) means the number of files untracked (?) and unstaged (!). For detailed description see What do different symbols in Git status mean?
change version segment
You can change the version segment (on the right of prompt) to reflect another tool. For example to replace shown ruby version by python version replace the element within right promt elements in your config .zshrc:
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(rbenv)
by
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(pyenv)

GNAT Metric and RTL files

For running GNAT metric (for Windows, GPL 2017 or CE 2018) I'd like to include the RTL sources as well. There is a "-a" switch but it seems to be ineffective. When I'm forcing visibility of RTL sources, only ada.ads and system.ads are processed. Guessing it is a "crunched name" issue (RTL file names forced to 8 character names) I've tried other tricks without success.
My question is: is there a way to get the RTL source metrics (of the source files actually used) with GNAT Metric?
I'm using the command
gnatmetric -a -xs -nt -j0 -Pmyproj.gpr -U somemain.adb
TIA
In the meantime I've found a workaround by using the gnathtml.pl script.
I've customized the script a bit by removing the H1 headers.
The result is a few hundreds of HTML files with the sources of units actually used: the script does find all dependencies, recursively, through the .ali files - including the RTL.
Then I group the HTML files together, convert them back to text files, pass them through Adalog's Normalize tool for removing comments and empty lines, count lines with the wc command, and the job is done.

I always end up with mixed line-endings in Atom

I have a package installed (Line Ending Selector) which can tell me what line endings (LF or CRLF or Mixed) are used in a file.
By default it's LF (which is my preferred one), but during the editing procedure it sometimes becomes Mixed and then I always have to set it back to LF manually.
It's very annoying when I forget to set all line-endings back to LF, push a file onto Github with Mixed line endings, someone pulls it, pushes their changes, and half of that commit are just line-ending changes that their editor made to the file because it has automatic line-ending correction - not like mine.
Can Atom also have this functionality? Is there a way to ensure that (for example on save) all line endings of a file are set to LF?
You can make use of .gitattributes to deal with line-endings:
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h text
# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
Related: GitHub User Documentation: Dealing with line endings
Alternatively, you can use EditorConfig to achieve the same. It's especially useful to enforce consistent settings across teams or open-source contributors.
I've found a package (Force Line Endings) that does exactly what I need. I wonder why others are not having this same problem, and why this package has so few downloads.

console print w/o scrolling

I see console apps print colors and seen apps such as ffmpeg print text over itself instead of a new line. How do I print over an existing line? I want to display fps in my console app either at the very top or very bottom and have regular printfs go there and scroll normally.
I need this for windows, but this is meant to be cross platform, so I will eventually have a linux and mac implementation.
There is two simple possibilities which work on linux as well as windows, but only for one line:
printf("\b"); will return for one character, so you might count how many character you want to backspace and fire this in a loop, or you know that you only write n numbers and do it likeprintf("\b\b\b\b\b\b\b\b\b\b");
printf("text to be overwritten by next printf\r"); this will return the cursor to the beginning of the line, so any next printf will overwrite it. Make sure to write a string of same length or longer so you overwrite it entirely.
If you want to rewrite several lines, there is nothing so portable as ncurses, there is libs for it on practically every operating system, and you don't have to take care of the ANSI-differences.
edit: added link to ncurses wikipedia page, gives great overview and introduction, as well as link list and maybe a translation to your preferred language
Check out ncurses. It has bindings for most scripting languages.
You can use '\r' instead of '\n'.
The ASCII character number 8 (A.K.A. Ctrl-H, BS or Backspace) lets you back up one character. ASCII Character number 13 (A.K.A Ctrl-M, CR or Carriage Return) returns the cursor at the beggining of the line.
If you are working in C try putchar(8); and putchar(13);
The magic of the colors, cursor locating and bliking and so on are inside ANSI escape codes. Any text console capable of handling ANSI codes can use them just printing them out to console (i.e. by means of echo in a bash script or printf() function in C).
Unix terminals support ANSI escape sequences and Windows world used to support them back in old MS-DOS days, but the multibyte console support put an end to this. There is more information here. However there are other ways out of just ANSI sequences printing available on Windows. Moreover if you have Cygwin installed on your Windows maching ANSI codes work just as great as on any Unix terminal.
Many people mention Ncurses library that is the de-facto standard for any gui-like text based applications. What this library does is to hide all the terminal differences (Windows/Unix flavours) to represent the same information as identical as possible across all the platforms, though from my own experience I tell you this is not always true (i.e. typical text window frames change because the especial chars are not available under all character encodings). The counterpart of using ncurses is that it is a complete API and it is much harder to start out with it than simply writing out some ANSI escape sequences for simple things such as change the font color, cleaning screen or moving back the cursor to a random position.
For the sake of completeness I paste an example of use of ANSI sequence under Linux that changes the prompt to blue and shows the date:
PS1="\[\033[34m\][\$(date +%H%M)][\u#\h:\w]$ "
You can use Ncurses -
ncurses package is a subroutine library for terminal-independent screen-painting and input-event handling which presents a high level screen model to the programmer, hiding differences between terminal types and doing automatic optimization of output to change one screenfull of text into another
Depending on the platform which you are developing on there's probably a more powerful API which you could use, rather than old ASCII control codes.
e.g. If you are working on Win32 you can actually manipulate the console screen buffer directly.
A good place to start might be here
http://msdn.microsoft.com/en-us/library/ms683171(VS.85).aspx
I have been looking for similar functions/API which would allow me to access the console as something other than a stream of text for other platforms. Haven't found anything yet, but then again, I haven't been looking that hard.
Hope it helps.

Resources