all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattias.engdegard@gmail.com>
To: "Gerd Möllmann" <gerd.moellmann@gmail.com>
Cc: 66604@debbugs.gnu.org
Subject: bug#66604: [PATCH] Gud LLDB completions
Date: Sat, 21 Oct 2023 12:37:12 +0200	[thread overview]
Message-ID: <012EA2B6-279A-4A83-8C63-00EDB44A14CF@gmail.com> (raw)
In-Reply-To: <m2h6mlyzi0.fsf@Pro.fritz.box>

[-- Attachment #1: Type: text/plain, Size: 579 bytes --]

20 okt. 2023 kl. 19.28 skrev Gerd Möllmann <gerd.moellmann@gmail.com>:

> Look at these escape sequences that suddenly appear when attaching to a
> process! I don't even know what "<esc>[1G" and "<esc>[8G" do.

Fascinating! We should probably look into the source code producing it (libedit probably) but I wrote the attached monstrosity and it... seems to work. (Proof of concept only.)

It attempts to edit out the part of strings jumped over by CHA (CSI G), and it also edits out ED (CSI J) which is in this case just used to do exactly that immediately after CHA.


[-- Attachment #2: lldb-filter-cha.diff --]
[-- Type: application/octet-stream, Size: 2227 bytes --]

diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index 8518738d09e..245600a2f94 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -3871,6 +3871,42 @@ gud-lldb-stop
 
 (defun gud-lldb-marker-filter (string)
   "Deduce interesting stuff from process output STRING."
+  (let ((ofs 0))
+    (while (string-match (rx (* (not (in "\n\e")))
+                             (group "\e[")
+                             (? (group (+ digit)))
+                             (group (in "GJ")))
+                         string ofs)
+      (let ((bol (match-beginning 0))
+            (seq-start (match-beginning 1))
+            (arg (and (match-beginning 2)
+                      (string-to-number (match-string 2 string))))
+            (op-char (aref string (match-beginning 3)))
+            (seq-end (match-end 0)))
+        (cond ((eq op-char ?G)
+               ;; Move to absolute column. Argument is 1-based.
+               (let* ((goal-col (1- (or arg 1)))
+                      (current-col (current-column))
+                      (prefix-len (- seq-start bol))
+                      (eff-col (+ current-col prefix-len))
+                      (rel-move-left (- eff-col goal-col))
+                      (del-prefix (max 0 (min prefix-len rel-move-left)))
+                      (elide-start (- seq-start del-prefix))
+                      (elide-end seq-end)
+                      (del-chars (- rel-move-left del-prefix)))
+                 ;; FIXME: insert extra spaces if we move beyond eff-col
+                 (when (> del-chars 0)
+                   (delete-char (- del-chars)))
+                 (setq string
+                       (concat (substring string 0 elide-start)
+                               (substring string elide-end)))
+                 (setq ofs (+ bol (- prefix-len del-prefix)))))
+              ((eq op-char ?J)
+               ;; Erase in display
+               ;; FIXME
+               (setq string (concat (substring string 0 seq-start)
+                                    (substring string seq-end)))
+               (setq ofs seq-start))))))
   (cond
    ;; gud-info: (function-name args...)
    ((string-match (rx line-start (0+ blank) "gud-info:" (0+ blank)

  parent reply	other threads:[~2023-10-21 10:37 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-18 11:25 bug#66604: [PATCH] Gud LLDB completions Gerd Möllmann
2023-10-18 13:37 ` Mattias Engdegård
2023-10-18 14:42   ` Gerd Möllmann
2023-10-18 15:14     ` Mattias Engdegård
2023-10-18 15:23       ` Gerd Möllmann
2023-10-18 16:05         ` Mattias Engdegård
2023-10-18 16:57           ` Gerd Möllmann
2023-10-18 18:55             ` Gerd Möllmann
2023-10-19 10:34               ` Mattias Engdegård
2023-10-19 10:48                 ` Gerd Möllmann
2023-10-19 11:36                   ` Mattias Engdegård
2023-10-19 11:50                     ` Gerd Möllmann
2023-10-19 12:29                       ` Mattias Engdegård
2023-10-19 13:08                         ` Gerd Möllmann
2023-10-19 13:22                           ` Mattias Engdegård
2023-10-20  6:04                             ` Gerd Möllmann
2023-10-20 10:42                               ` Mattias Engdegård
2023-10-20 11:12                                 ` Gerd Möllmann
2023-10-20 11:50                                   ` Mattias Engdegård
2023-10-20 11:59                                     ` Gerd Möllmann
2023-10-20 17:28                                       ` Gerd Möllmann
2023-10-20 17:47                                         ` Gerd Möllmann
2023-10-21 10:32                                           ` Gerd Möllmann
2023-10-21 10:51                                             ` Mattias Engdegård
2023-10-21 12:33                                               ` Gerd Möllmann
2023-10-21 10:37                                         ` Mattias Engdegård [this message]
2023-10-21 10:50                                           ` Gerd Möllmann
2023-10-23  5:31                                             ` Gerd Möllmann
2023-10-23 17:18                                               ` Mattias Engdegård
2023-10-23 17:57                                                 ` Gerd Möllmann
2023-10-23 20:51                                                   ` Mattias Engdegård
2023-10-24  4:35                                                     ` Gerd Möllmann
2023-10-24  8:47                                                       ` Mattias Engdegård
2023-10-24  8:52                                                         ` Gerd Möllmann
2023-10-24 10:00                                                           ` Mattias Engdegård
2023-10-24 10:27                                                             ` Gerd Möllmann
2023-10-24 18:12                                                               ` Mattias Engdegård
2023-10-25  4:29                                                                 ` Gerd Möllmann
2023-10-18 15:24       ` Gerd Möllmann
2023-10-19  6:31     ` Visuwesh
2023-10-19  6:56       ` Gerd Möllmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=012EA2B6-279A-4A83-8C63-00EDB44A14CF@gmail.com \
    --to=mattias.engdegard@gmail.com \
    --cc=66604@debbugs.gnu.org \
    --cc=gerd.moellmann@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.