Recent Posts

Pages: 1 2 3 4 [5] 6 7 8 9 10
41
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.
42
Please create a ticket and post the information there.
43
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.
44
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.
45
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.

46
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).
47
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?
48
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?

49
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
50
Development / Re: new idea: context menu to open the image in doxygen style comment
« Last post by ollydbg on March 19, 2024, 01:45:50 pm »
This is the patch file for this simple feature.

When you right click on a image filename in the comment, such as "a.jpg".

Suppose you are editing a file named: "c:/abc/def.cpp", and you will open the file in the default image file browser.

Code
diff --git a/src/sdk/cbeditor.cpp b/src/sdk/cbeditor.cpp
index 71622d79..2a76d8a9 100644
--- a/src/sdk/cbeditor.cpp
+++ b/src/sdk/cbeditor.cpp
@@ -393,7 +393,7 @@ struct cbEditorInternalData
         }
     }
 
-    wxString GetUrl()
+    wxString GetUrl(wxString filename = wxEmptyString)
     {
         cbStyledTextCtrl* control = m_pOwner->GetControl();
         if (!control)
@@ -409,6 +409,9 @@ struct cbEditorInternalData
                               ")"
                               "(\\/?)([\\w\\-\\.\\?\\,\\'\\/\\\\\\+&amp;%\\$#]*)?"
                               "([\\d\\w\\.\\/\\%\\+\\-\\=\\&amp;\\?\\:\\\\\\&quot;\\'\\,\\|\\~\\;]*)"));
+
+        wxRegEx reFile(R"raw([A-Za-z0-9]+\.(jpg|jpeg|png|gif|bmp|svg))raw");
+
         wxString url = control->GetSelectedText();
         // Is the URL selected?
         if (reUrl.Matches(url))
@@ -456,6 +459,31 @@ struct cbEditorInternalData
             else
                 url = wxEmptyString; // nope, too far from cursor, return invalid (empty)
         }
+        else if (reFile.Matches(url))
+        {
+            wxString match = reFile.GetMatch(url);
+            if ((url.Find(match) + startPos < control->GetCurrentPos()) &&
+                (url.Find(match) + startPos + (int)match.Length() > control->GetCurrentPos()))
+            {
+                // Translate short file path to absolute file path using the current source file path
+                // match is some string like "xyz.jpg" or "xyz.png"
+                if (match.IsEmpty())
+                {
+                    return wxT("file:///") + match;
+                }
+                else
+                {
+                    // suppose we are editing a file named : "c:/abc/def.cpp"
+                    // the file contains some piece of the comments which is "xyz.jpg"
+                    // we create an absolute file path of the image file named "c:/abc/xyz.jpg"
+                    wxFileName baseFilename(filename);
+                    wxFileName newFilename(baseFilename.GetPath(), match);
+                    return wxT("file:///") + newFilename.GetFullPath();
+                }
+            }
+            else
+                url = wxEmptyString; // nope, too far from cursor, return invalid (empty)
+        }
         else
             url = wxEmptyString; // nope, return invalid (empty)
 
@@ -3289,7 +3317,7 @@ void cbEditor::OnContextMenuEntry(wxCommandEvent& event)
     else if (id == idFoldingToggleCurrent)
         ToggleFoldBlockFromLine();
     else if (id == idOpenUrl)
-        wxLaunchDefaultBrowser(m_pData->GetUrl());
+        wxLaunchDefaultBrowser(m_pData->GetUrl(GetFilename()));
     else if (id == idSplitHorz)
         Split(stHorizontal);
     else if (id == idSplitVert)

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