|
The Inseertobject does its job inserting a red bullet bitmap however it shifts over all the text by one byte as it puts a leading X'3F' I tried using ReplaceSel
shifting the text back one byte but upon display that line got duplicated
Thanks
|
|
|
|
|
You need to show the code and explain in more detail what you mean by "upon display that line got duplicated".
|
|
|
|
|
first off I am trying to write a front end to debugger sort of like visual studio I have a red bullet and the insert object works it places it in the first position of the buffer but the result is it shifts over the text in the rich buffer. The X'3F' seems to represent the red bullet bmp so I wrote code to shift everything over to the left 1 byte however seems like the lines get duplicated meaning
this is what in the rich edit before " STM R14,R12,12(R13) "
After the insertobject " LR R3,R15 "
" STM R14,R12,12(R13) "
" LR R3,R15
I cant cut and paste the rich edit display correctly but the insert object puts the bullet bmp where I want it, it just pushes the text to the right one byte thought if I wrote code to sh*t it over that would straighten it out but all did was display the STM line twice
This my code
myoleptr->InsertObject(&reobject);
int i;
RichListing->GetLine(RichListing->LineFromChar(-1), (LPTSTR)&buffer, 132);
for (i = 1; i < 132; i++)
buffer[i] = buffer[i + 1];
buffer before
0x00000004BEF4C2C0 3f 20 20 20 5f 20 20 20 20 20 20 20 32 33 20 20 20 20 20 20 20 20 30 30 30 30 30 30 20 20 20 20 ? _ 23 000000
0x00000004BEF4C2E0 20 20 20 20 20 20 20 20 20 53 54 4d 20 20 20 52 31 34 2c 52 31 32 2c 31 32 28 52 31 33 29 20 20 STM R14,R12,12(R13)
0x00000004BEF4C300 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0x00000004BEF4C320 20 20 20 20 20 20 20 20 30 30 30 32 31 30 35 31 0d 00 cc cc cc cc cc cc cc cc cc cc cc cc cc cc 00021051..ÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
0x00000004BEF4C340 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
0x00000004BEF4C360 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
0x00000004BEF4C380 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
0x00000004BEF4C3A0 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
buffer after
0x00000004BEF4C2C0 3f 20 20 5f 20 20 20 20 20 20 20 32 33 20 20 20 20 20 20 20 20 30 30 30 30 30 30 20 20 20 20 20 ? _ 23 000000
0x00000004BEF4C2E0 20 20 20 20 20 20 20 20 53 54 4d 20 20 20 52 31 34 2c 52 31 32 2c 31 32 28 52 31 33 29 20 20 20 STM R14,R12,12(R13)
0x00000004BEF4C300 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0x00000004BEF4C320 20 20 20 20 20 20 20 30 30 30 32 31 30 35 31 0d 00 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc 00021051..ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
0x00000004BEF4C340 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
0x00000004BEF4C360 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
|
|
|
|
|
I am not sure that I can see what is wrong with that. Anything inserted into the control will take space and thus move everything else along.
|
|
|
|
|
Richard
I think the selection range has to be in line with the number of characters that are in
LPCTSTR lpszNewText,
of the null terminated string parameter of ReplaceSel
When you InsertObject a bitmap that bitmap depending on its size takes up a certain amount of characters depending among other things the size of font of the
current selection and the size of the bitmap. I am not sure if there is a some way to calculate this i.e. if you have a string and you want to know how many pixels it takes you do GetTextExtent. the REOBJECT structure doesn't seem to have parameters for the size of the bitmap like BITBLT I just played around with the string and the selection size and got it to align
|
|
|
|
|
Most image files and types have the size encoded in them. I don't know how you are loading the bitmap into the reobject variable but presumably you can check the source file/object.
|
|
|
|
|
CASE SOLVED AND CLOSED
FYI
As I pointed out in my recent post, which apparently did no good, this has been brought up before.
I am guilty of not going back to the original post.
Being repeatedly told that I am not sharing my code is getting old.
So - no need to be bothered again , let's just chalk this for yet another loop-sided discussion blaming the problem on me.
Cheers
CASE CLOSED
Re: Unexpected sequence of cout / perror in console output - C / C++ / MFC Discussion Boards[^]
SOLVED
It is acceptable and normal to direct standard output and standard error to the same destination, such as the text terminal. Messages appear in the same order as the program writes them, unless buffering is involved. For example, in common situations the standard error stream is unbuffered but the standard output stream is line-buffered; in this case, text written to standard error later may appear on the terminal earlier, if the standard output stream buffer is not yet full.
This is NOT a dupe, just an attempt to analyse / concentrate on specific problem.
The attached code execution clearly shows that the code is NOT run in sequence coded.
See line numbers - they are OUT of sequence.
The lines start with 40 and end with line 49
This is superficial, but annoying problem I would like to resolve.
Or just identify the reason for this behaviour.
BTW - inserting sleep(1) at various places "solves the problem".
cerr is used to output (stderr) to console in red AND WORKS just fine.
Maybe cerr and cout have conflicting "priority" or "4 core processor " in use is an issue.
cout << " START test area " << __LINE__ << endl;
cout << " START test area " << __LINE__ << endl;
cerr << "Function: " << __FUNCTION__ << " @line " << dec << __LINE__
<< endl;
cerr << "TRACE TEST Function: " << __FUNCTION__ << " @line " << dec
<< __LINE__ << endl;
cout << "\tEND test area " << __LINE__ << endl;
cout << "\tEND test area " << __LINE__ << endl;
START test area 40
START test area 41
Function: END test area 48
END test area 49
main @line 42
TRACE TEST Function: main @line 47
modified 22-Dec-19 9:44am.
|
|
|
|
|
I still cannot get the output in the "wrong" order. As mentioned below, I think there is a key piece of information that you have not shared with us.
|
|
|
|
|
Vaclav_ wrote: Being repeatedly told that I am not sharing my code is getting old. And there is an easy way to prevent that ...
|
|
|
|
|
SOLVED CASE CLOSED
Thanks for all the help from the group.
It is much appreciated.
Ask Mrs Google for "Eclipse ANSI" .
The question remains why it works without the 3rd part plug in when the app is crosscompiled.
I hope it will not bother the group if I revisit this , now multiple issue.
1. The attached C++ code DOES NOT execute in expected sequence.
Both perror output in red, which is expected , but out of expected sequence.
2. The setw works as expected.
3. The cout "escape sequence " DOES NOT change color and also outputs the sequence as "control characters".
It works well in crosscomplied code.
The code fails using tools implementing "standard" "hello word" on local machine.
This SAME code works as expected running after the application is crosscompiled for
"remote" machine. And has been working well for few months of development.
As far as I can tell - implementing "control / escape " characters in cout does not require anything special - iostream should work .
cout << " START test area " << __LINE__ << endl;
cout << __FUNCTION__ << endl;
cout << " START test area " << __LINE__ << endl;
cout << __FUNCTION__ << endl;
perror("TEST perror ");
cout << setw(30) << "\033[1;31mbold red text\033[0m\n";
perror("TEST perror ");
while(1);
<pre lang="text">
TEST perror : Success printed in red
TEST perror : Invalid argument printed in red
START test area 334
main
START test area 336
main
[1;31mbold red text[0m shifted , but no color change
modified 24-Dec-19 10:59am.
|
|
|
|
|
With cout you can do it directly without the escape code
cout << ansi::foreground_red << "bold red text" << ansi::foreground_white << endl;
In vino veritas
|
|
|
|
|
OK, stupid follow-up question.
How / where I activate "ansi"?
|
|
|
|
|
I just tried your code after correcting it, and it worked fine printing "bold red text" in bold red. What is that while(1); statement supposed to be for?
Also, why are your results shown in a different order to the actual instructions in your code sample?
|
|
|
|
|
I suppose asking to share your solution is out of the question.
Since this is a TEST code , the while(1); purpose is to stop code flow.
|
|
|
|
|
It's nothing special, just print the start test line, then two samples of perror, the first with no error, and the second with error 5.
cout << "Function: " << __FUNCTION__ << endl;
cout << " START test area " << __LINE__ << endl;
errno = 0;
perror("\033[1;31mTEST perror "); cout << "\033[0m\n"; errno = 5;
perror("\033[1;31mTEST perror ");
cout << "\033[0m\n";
Quote: Since this is a TEST code , the while(1); purpose is to stop code flow. Not sure what that means as there is nothing to stop.
|
|
|
|
|
Unfortunately that is not a solution.
Edited
perror always prints in red - using stderr / cerr .
Maybe I should just switch from cout to cerr to output in red,
Please observe that escape codes, which are still ignored, are printed instead of being reacted on.
That is THE ISSUE, the usage of while is NOT related to the issue at all.
I believe this is related either to complier or operating system.
I am searching for a solution in that direction for now.
Any other suggestions are welcome.
cout << "Function: " << __FUNCTION__ << endl;
cout << " START test area " << __LINE__ << endl;
errno = 0;
perror("TEST perror "); perror("\033[1;31mTEST perror "); cout << "\033[0m\n"; errno = 5;
perror("\033[1;31mTEST perror ");
cout << "\033[0m\n";
printf("%c[%dmHELLO!\n", 0x1B, 32);
const std::string red("\033[0;31m");
cout << red << "red text" << endl;
system("Color 1A");
system("Color 1B");
std::cout << "\t\t\t Hello World" << std::endl;
cout << "Bluetooth client " << endl;
cout << " START test area " << dec << __LINE__ << endl;
cout << __FUNCTION__ << endl;
Function: main
START test area 39
[0m
[0m
[32mHELLO!
[0;31mred text
TEST perror : Success
[1;31mTEST perror : Invalid argument
[1;31mTEST perror : Input/output error
sh: 1: Color: not found
sh: 1: Hello World
Bluetooth client
START test area 58
main
set color @line [31m 443
set color @line [31m 449
PROGREESS TRACE START
modified 21-Dec-19 15:38pm.
|
|
|
|
|
Taking your code above and running it produces the following output:
C:\Users\rjmac\Documents\Code\C++>Test
Function: DoTest
START test area 17
TEST perror : No error --> in normal black
TEST perror : No error --> in bold red
TEST perror : Input/output error --> in bold red
HELLO! --> in green
red text --> everything from here in normal red
Hello World
Bluetooth client
START test area 36
DoTest
Which does not match with what you have produced. I can only conclude that there is something else going on in your system, or the actual code you run is different, that you are not telling us about.
|
|
|
|
|
Yet another "problem" got me stumped.
To verify "networking" I use system call such as
system("vim /etc/hosts");
It does the job, however, I cannot figure out how to close the file.
The standard "vim" way is "Esc :q!" , and it is unclear which character should be "send" via standard console and which ones after responses from vim.
Either manually (cin) or as a string starting with "Esc".
Cheers
|
|
|
|
|
What kind of verification does vim ?
I am asking such a question because, I believe, while it is not straightforward closing vim , there could be better alternatives to 'verify networking'.
|
|
|
|
|
I wondered about that too: if the point is just to verify that you can access a certain file across a network file path, then trying to open it with fstream::open() should do the job.
Whereas, emulating console input that is supposed to be passed into an external process would be kind of tricky, to say the least...
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
I am just looking to verify "hosts" names.
And I realize that using vim is asking for complications, especially when I actually need to use / select "name" for further processing.
vim is bad idea.
|
|
|
|
|
If vim is not in insert or append mode then you can close it by sending ZZ.
|
|
|
|
|
OK, I can do search and replace "cout<<" with "cout<< setw(offset)<< "
to shift the output start column to console at offset.
BUT
anybody has an idea / hack how to PRESET "cout" ?
<pre> int offset = 10;
setw(offset);
cout << setw(offset ) << "Test " << endl;
cout << setw(offset ) << "Test " << endl;
cout << setw(offset ) << "Test " << endl;
offset += 10;
cout << setw(offset ) << "Test " <<" space " << "Test " << endl;
cout << setw(offset ) << "Test " <<" space " << "Test " << endl;
cout << setw(offset ) << "Test " <<" space " << "Test " << endl;
cout << setw(offset ) << "Test " <<" space " << "Test " << endl;
|
|
|
|
|
No, The width feature affects the following item only. In the same way you cannot have a preset in printf.
|
|
|
|
|
Usually when doing that sort of thing its easier to swing to ANSI which is semi portable on Windows and Linux consoles and you can have colours. Still cant set it global pre calls.
An example
printf("\x1B[%d;%df\x1B[31;40mRed line at 10,20\n", 10, 20);
printf("\x1B[37;40m");
In vino veritas
|
|
|
|