svaante / dape

Debug Adapter Protocol for Emacs
GNU General Public License v3.0
448 stars 25 forks source link

Enhance Debug Line Indicator with overlay-arrow-variable-list #117

Closed luluman closed 2 months ago

luluman commented 2 months ago

The overlay-arrow-variable-list is preferred for showing the debug line indicator used by gud.el and realgud/fringe.el. The built-in display-line-numbers-mode works well with overlay-arrow-variable-list, displaying debug information effectively.

Here is my configuration with symbol "▶"

image

We can configure the face and symbols used for display with 'overlay-arrow-string, which allows for customization. However, the current implementation uses overlays, which do not work well within a terminal. This might work better in a GUI, though I haven't tested it.

image

I hope we can modify this implementation to use overlay-arrow-variable-list. I'm not proficient in Elisp and, while I've tried some demos, I cannot propose a solid solution.

(defcustom dape-stack-position-string overlay-arrow-string
  "String to display location of source file in line-number."
  :type 'string)

(defvar dape--stack-position nil
  "Dape stack position overlay for arrow.")
(put 'dape--stack-position
     'overlay-arrow-string
     (propertize dape-stack-position-string
                 'face 'dape-stack-trace-face))
(add-to-list 'overlay-arrow-variable-list 'dape--stack-position)

I noticed that the function dape--inlay-hint-add uses the overlay of dape--stack-position, but fixing this compatibility issue is beyond my expertise.

svaante commented 2 months ago

Hey! I am not really sure what you issue you are highlighting,

dape used to use overlay-arrow-variable-list to show stack pointer, but moved away for more control on how fringe bitmaps are displayed as to better indicate that an line has an breakpoint and is the current stack pointer.

As shown in the following screen dumps:

bild

When stack pointer moves to the line of the breakpoint the fringe bitmap is displayed with the same face as an break point to indicate that current line contains an breakpoint.

bild

As for display-line-numbers-mode and terminal dape works fine:

bild

If your looking for more customization options dape uses the value of overlay-arrow-string to display stack pointer when fringe is not available (terminal or fringe style no-fringesor right-only)

It might be worth while to take another crack at overlay-arrow-variable-list to see if there is any way to ensure the fringe "Z" order.

luluman commented 2 months ago

Thank you for your prompt response and for providing more context.

Here's my proposal:

The current implementation using overlays cannot use the line-number margin to display the "=>" indicator. This results in overlap with the code text if it is improperly formatted.

Xnip2024-06-13_10-55-58

On the other hand, overlay-arrow-variable-list can utilize the line-number margin and leave the left margin (reserved for breakpoints) untouched.

Xnip2024-06-13_10-54-29

However, when line-number mode is disabled, it also covers the text. In scenarios where there is no line-number space, both solutions are equally problematic.

This is using overlay-arrow-variable-list. Xnip2024-06-13_10-54-08

This is using overlay. Xnip2024-06-13_10-56-20

I prefer using overlay-arrow-variable-list in terminal mode as it can use line-number space to clearly distinguish between breakpoints and the current-line indicator.

svaante commented 2 months ago

@luluman I was able to recreate the wanted features with overlay-arrow-variable-list on master.

Please get back to me if it solves this issue.

luluman commented 2 months ago

@svaante Thank you for your modification. It has been very helpful, providing more configuration options and working well within the terminal. Now I can customize my DAPE appearance like this, and it looks great:

(use-package dape
  :custom
  (dape-buffer-window-arrangement 'right) ;; Info buffers to the right
  (dape-breakpoint-margin-string "●") ;; ◯
  :config
  (put 'dape--overlay-arrow-position
       'overlay-arrow-string   ;; ▶ →
       (propertize "▶" 'face 'dape-stack-trace-face)))