Recent Posts

Pages: 1 2 3 4 [5] 6 7 8 9 10
41
General (but related to Code::Blocks) / Re: Welcome Newcomers - PLEASE READ!!!
« Last post by tonyaimer1 on March 22, 2024, 07:50:16 am »
I am here from Johannesburg.

I want to get into numerical methods and C GUI programming - huge task I know.

The ecosysyem is massive.

I take heart from Eskil Steenberg who had a you tube video called "How I program in C"
who suggested we should embrace complexity and not be afraid of it - the beginning
that's where I am.

Tony
42
Please create a ticket and post the information there.

@RadicalInquisition:
Please mention the OS version, the CB version and revision,
attach any .RPT in the CodeBlocks executable folder.
And, if possible, some code to recreate the problem.

This looks suspiciously like a problem that has already been fixed in an (almost) recent commit.
43
Please create a ticket and post the information there.
44
Using Code::Blocks / Re: C::B Workspace/project to cmake or premake?
« Last post by Miguel Gimenez on March 21, 2024, 02:12:42 pm »
Spam reported to moderator.
45
Using Code::Blocks / Re: C::B Workspace/project to cmake or premake?
« Last post by lopuna3 on March 21, 2024, 12:56:22 pm »

They do exist, I have one installed under Kubuntu 22.04
https://github.com/chris-be/premake-codeblocks battleship game

These days I just use Code::Blocks.
And can this thing turn this cmakelist.txt into a Code::Blocks? Does it only work on Linux and only with this clang?

If you have a CMakeLists.txt file, you can generate Code::Blocks project files using CMake. However, the specific toolchain and compiler settings may vary depending on your platform.
46
Plugins development / Re: Code completion using LSP and clangd
« Last post by Pecan on March 20, 2024, 08:33:50 pm »
Hi Pecan,

I found two issues with applying fix in my setup. I'm using clangd version 18.0.0
1. "fixes available" along with "fix available"
2. Multi line fixes, eg: unused header warnings.

Below modification helped to apply these fixes.
Code
diff --git a/src/plugins/contrib/clangd_client/src/LSPclient/lspdiagresultslog.cpp b/src/plugins/contrib/clangd_client/src/LSPclient/lspdiagresultslog.cpp
index b64e7d760..425268724 100644
--- a/src/plugins/contrib/clangd_client/src/LSPclient/lspdiagresultslog.cpp
+++ b/src/plugins/contrib/clangd_client/src/LSPclient/lspdiagresultslog.cpp
@@ -256,7 +256,7 @@ void LSPDiagnosticsResultsLog::OnApplyFixIfAvailable(wxCommandEvent& event) //(p
     {
         // Got the selected item index
         selectedLineText = GetItemAsText(itemIndex);
-        if (not selectedLineText.Contains(" (fix available) "))
+        if (not (selectedLineText.Contains(" (fix available) ") or (selectedLineText.Contains("(fixes available)"))))
         {
             wxString msg = wxString::Format(_("No Fix available for logLine(%d)"), int(itemIndex) );
             InfoWindow::Display(_("NO fix"), msg);
diff --git a/src/plugins/contrib/clangd_client/src/codecompletion/parser/parser.cpp b/src/plugins/contrib/clangd_client/src/codecompletion/parser/parser.cpp
index b97e46a30..2ef369352 100644
--- a/src/plugins/contrib/clangd_client/src/codecompletion/parser/parser.cpp
+++ b/src/plugins/contrib/clangd_client/src/codecompletion/parser/parser.cpp
@@ -3688,15 +3688,17 @@ void Parser::OnRequestCodeActionApply(wxCommandEvent& event) //(ph 2024/02/12)
         int startLine; // 1 origin; needs to be changed to zero origin
         int lineStartCol;
         int lineEndCol;
+        int endLine;
 
         codeActionStr  = FixesFound[ii];
         try {
             // std::string testData = "{\"newText\":\"int\",\"range\":{\"end\":{\"character\":8,\"line\":275},\"start\":{\"character\":4,\"line\":275}}}"; // **Debugging**
             nlohmann::json jCodeAction = nlohmann::json::parse(codeActionStr.ToStdString());
             newText      = jCodeAction["newText"].get<std::string>();
-            startLine    = lineNumInt; // it's already 1 origin
+            startLine    = jCodeAction["range"]["start"]["line"] ;
             lineStartCol = jCodeAction["range"]["start"]["character"] ;
             lineEndCol   = jCodeAction["range"]["end"]["character"] ;
+            endLine      = jCodeAction["range"]["end"]["line"] ;
         }
         catch(std::exception &err)
         {
@@ -3708,9 +3710,12 @@ void Parser::OnRequestCodeActionApply(wxCommandEvent& event) //(ph 2024/02/12)
         // pEd contains the cbEditor ptr from above
         cbStyledTextCtrl* pControl = pEd->GetControl();
          // Replace text; note that the startLine is from the log msg line, so it's 1 origin
-        int linePosn = pControl->PositionFromLine(startLine-1); // use zero origin for line
-        pControl->SetTargetStart(linePosn + lineStartCol);
-        pControl->SetTargetEnd(linePosn + lineEndCol );
+        int linePosn = pControl->PositionFromLine(startLine); // use zero origin for line
+        int targetStart = linePosn + lineStartCol;
+        pControl->SetTargetStart(targetStart);
+        int lineEndPosn = pControl->PositionFromLine(endLine);
+        int targetEnd = lineEndPosn + lineEndCol;
+        pControl->SetTargetEnd(targetEnd);
         pControl->ReplaceTarget(newText);
     }//endfor FixesFound
 

Thanks, Christo

@ christo
Thanks for your work on this.
When there are multiple extraneous #includes in the same file, the patch is taking out the wrong lines after the first one is successful.

So I'll hold onto this until I have time to find out why.

47
There goes the next new Code Blocks-related issue.  :)
A sudden crash when I type in the parenthesis of a function-like macro in a pre-processor conditional.

I also recorded a video (It is unlisted):
https://www.youtube.com/watch?v=ItL7eMKh7F4&ab_channel=CodeBlocksFails

I haven't looked into it, but it might be the parser-provided syntax complete (which is also quite bad per se).
48
Development / new idea: smart copy of the code snippet with [code] tag around
« Last post by ollydbg on March 20, 2024, 05:15:26 am »
Under my web browser, I have an addon named: Link Text and Location Copier

With this add on, I can copy the link with many kinds of format, such as: wikipedia link format, or makdown link format or phpBB link format.

I think we can have a similar function, when you copy a piece of the code in the editor, we can got the result like:

Code
In the source file: xxxx/yyyy.cpp
code tag begin

The code content.

code tag end

Any ideas? Or maybe we already have this feature?
49
Development / Re: new idea: context menu to open the image in doxygen style comment
« Last post by ollydbg on March 20, 2024, 03:04:06 am »
For another issue:

I see a lot of "\" (the escape) in the regular expression pattern string.

For example, in cbeditor.cpp, there are some patter string like below

Code
        wxRegEx reUrl(wxT("***:("
                                "((ht|f)tp(s?)\\:\\/\\/)"
                                "|(www\\.)"
                              ")"
                              "("
                                "([\\w\\-]+(\\.[\\w\\-]+)+)"
                                "|localhost"
                              ")"
                              "(\\/?)([\\w\\-\\.\\?\\,\\'\\/\\\\\\+&amp;%\\$#]*)?"
                              "([\\d\\w\\.\\/\\%\\+\\-\\=\\&amp;\\?\\:\\\\\\&quot;\\'\\,\\|\\~\\;]*)"));

Can we use the C++ raw string? Which we can remove a lot of "\".

Any ideas?

50
Plugins development / Re: Code completion using LSP and clangd
« Last post by christo on March 19, 2024, 06:21:49 pm »
Hi Pecan,

I found two issues with applying fix in my setup. I'm using clangd version 18.0.0
1. "fixes available" along with "fix available"
2. Multi line fixes, eg: unused header warnings.

Below modification helped to apply these fixes.
Code
diff --git a/src/plugins/contrib/clangd_client/src/LSPclient/lspdiagresultslog.cpp b/src/plugins/contrib/clangd_client/src/LSPclient/lspdiagresultslog.cpp
index b64e7d760..425268724 100644
--- a/src/plugins/contrib/clangd_client/src/LSPclient/lspdiagresultslog.cpp
+++ b/src/plugins/contrib/clangd_client/src/LSPclient/lspdiagresultslog.cpp
@@ -256,7 +256,7 @@ void LSPDiagnosticsResultsLog::OnApplyFixIfAvailable(wxCommandEvent& event) //(p
     {
         // Got the selected item index
         selectedLineText = GetItemAsText(itemIndex);
-        if (not selectedLineText.Contains(" (fix available) "))
+        if (not (selectedLineText.Contains(" (fix available) ") or (selectedLineText.Contains("(fixes available)"))))
         {
             wxString msg = wxString::Format(_("No Fix available for logLine(%d)"), int(itemIndex) );
             InfoWindow::Display(_("NO fix"), msg);
diff --git a/src/plugins/contrib/clangd_client/src/codecompletion/parser/parser.cpp b/src/plugins/contrib/clangd_client/src/codecompletion/parser/parser.cpp
index b97e46a30..2ef369352 100644
--- a/src/plugins/contrib/clangd_client/src/codecompletion/parser/parser.cpp
+++ b/src/plugins/contrib/clangd_client/src/codecompletion/parser/parser.cpp
@@ -3688,15 +3688,17 @@ void Parser::OnRequestCodeActionApply(wxCommandEvent& event) //(ph 2024/02/12)
         int startLine; // 1 origin; needs to be changed to zero origin
         int lineStartCol;
         int lineEndCol;
+        int endLine;
 
         codeActionStr  = FixesFound[ii];
         try {
             // std::string testData = "{\"newText\":\"int\",\"range\":{\"end\":{\"character\":8,\"line\":275},\"start\":{\"character\":4,\"line\":275}}}"; // **Debugging**
             nlohmann::json jCodeAction = nlohmann::json::parse(codeActionStr.ToStdString());
             newText      = jCodeAction["newText"].get<std::string>();
-            startLine    = lineNumInt; // it's already 1 origin
+            startLine    = jCodeAction["range"]["start"]["line"] ;
             lineStartCol = jCodeAction["range"]["start"]["character"] ;
             lineEndCol   = jCodeAction["range"]["end"]["character"] ;
+            endLine      = jCodeAction["range"]["end"]["line"] ;
         }
         catch(std::exception &err)
         {
@@ -3708,9 +3710,12 @@ void Parser::OnRequestCodeActionApply(wxCommandEvent& event) //(ph 2024/02/12)
         // pEd contains the cbEditor ptr from above
         cbStyledTextCtrl* pControl = pEd->GetControl();
          // Replace text; note that the startLine is from the log msg line, so it's 1 origin
-        int linePosn = pControl->PositionFromLine(startLine-1); // use zero origin for line
-        pControl->SetTargetStart(linePosn + lineStartCol);
-        pControl->SetTargetEnd(linePosn + lineEndCol );
+        int linePosn = pControl->PositionFromLine(startLine); // use zero origin for line
+        int targetStart = linePosn + lineStartCol;
+        pControl->SetTargetStart(targetStart);
+        int lineEndPosn = pControl->PositionFromLine(endLine);
+        int targetEnd = lineEndPosn + lineEndCol;
+        pControl->SetTargetEnd(targetEnd);
         pControl->ReplaceTarget(newText);
     }//endfor FixesFound
 

Thanks, Christo
Pages: 1 2 3 4 [5] 6 7 8 9 10