Added sign column for breakpoints in source view

Author Mitja Felicijan <mitja.felicijan@gmail.com> 2026-01-17 01:33:51 +0100
Committer Mitja Felicijan <mitja.felicijan@gmail.com> 2026-01-17 01:33:51 +0100
Commit 01c6bfb9994aeb811c7b3a2b2ec8ede30d041ef8 (patch)
-rw-r--r-- tdbg.cpp 45
1 files changed, 40 insertions, 5 deletions
diff --git a/tdbg.cpp b/tdbg.cpp
...
22
const int BREAKPOINTS_WINDOW_HEIGHT = 10;
22
const int BREAKPOINTS_WINDOW_HEIGHT = 10;
23
const int SIDEBAR_WIDTH = 50;
23
const int SIDEBAR_WIDTH = 50;
24
  
24
  
25
// https://unicodeplus.com/U+2593
25
// https://unicodeplus.com
26
const uint32_t SCROLLBAR_THUMB = 0x2593; // Dark shade
26
const uint32_t SCROLLBAR_THUMB = 0x2593; // Dark shade
27
const uint32_t SCROLLBAR_LINE = 0x2502;  // Vertical line
27
const uint32_t SCROLLBAR_LINE = 0x2502;  // Vertical line
  
28
const uint32_t BREAKPOINT_CIRCLE = 0x25B6; // Filled triangle
28
  
29
  
29
enum InputMode {
30
enum InputMode {
30
	INPUT_MODE_NORMAL,
31
	INPUT_MODE_NORMAL,
...
376
		return;
377
		return;
377
	}
378
	}
378
  
379
  
  
380
	// Get breakpoints for this file
  
381
	std::vector<uint32_t> bp_lines;
  
382
	uint32_t num_breakpoints = target.GetNumBreakpoints();
  
383
	for (uint32_t i = 0; i < num_breakpoints; ++i) {
  
384
		SBBreakpoint bp = target.GetBreakpointAtIndex(i);
  
385
		uint32_t num_locs = bp.GetNumLocations();
  
386
		for (uint32_t j = 0; j < num_locs; ++j) {
  
387
			SBBreakpointLocation loc = bp.GetLocationAtIndex(j);
  
388
			SBLineEntry le = loc.GetAddress().GetLineEntry();
  
389
			if (le.IsValid()) {
  
390
				SBFileSpec fs = le.GetFileSpec();
  
391
				if (fs.IsValid()) {
  
392
					std::string bp_path;
  
393
					if (fs.GetDirectory()) {
  
394
						bp_path = std::string(fs.GetDirectory()) + "/" + fs.GetFilename();
  
395
					} else {
  
396
						bp_path = fs.GetFilename();
  
397
					}
  
398
					if (bp_path == fullpath) {
  
399
						bp_lines.push_back(le.GetLine());
  
400
					}
  
401
				}
  
402
			}
  
403
		}
  
404
	}
  
405
  
379
	int total_lines = (int)lines.size();
406
	int total_lines = (int)lines.size();
380
	int current_line = line_entry.GetLine();
407
	int current_line = line_entry.GetLine();
381
	for (int i = 0; i < ch; ++i) {
408
	for (int i = 0; i < ch; ++i) {
...
392
		src = expanded;
419
		src = expanded;
393
  
420
  
394
		bool is_current = (line_idx == current_line);
421
		bool is_current = (line_idx == current_line);
  
422
		bool has_breakpoint = std::find(bp_lines.begin(), bp_lines.end(), (uint32_t)line_idx) != bp_lines.end();
395
  
423
  
396
		char buf[32];
424
		char buf[32];
397
		snprintf(buf, sizeof(buf), "%4d ", line_idx);
425
		snprintf(buf, sizeof(buf), "%4d ", line_idx);
...
400
		uint16_t bg = is_current ? TB_BLUE : TB_DEFAULT;
428
		uint16_t bg = is_current ? TB_BLUE : TB_DEFAULT;
401
		uint16_t fg = is_current ? TB_WHITE | TB_BOLD : TB_DEFAULT;
429
		uint16_t fg = is_current ? TB_WHITE | TB_BOLD : TB_DEFAULT;
402
  
430
  
403
		draw_text(cx, cy + i, fg, bg, num_str);
431
		// Draw breakpoint indicator
  
432
		if (has_breakpoint) {
  
433
			tb_set_cell(cx, cy + i, BREAKPOINT_CIRCLE, TB_RED | TB_BOLD, bg);
  
434
		} else {
  
435
			tb_set_cell(cx, cy + i, ' ', fg, bg);
  
436
		}
  
437
  
  
438
		draw_text(cx + 1, cy + i, fg, bg, num_str);
404
  
439
  
405
		int src_max_len = cw - (int)num_str.length();
440
		int src_max_len = cw - (int)num_str.length() - 1;
406
		if ((int)src.length() > src_max_len) {
441
		if ((int)src.length() > src_max_len) {
407
			src = src.substr(0, src_max_len);
442
			src = src.substr(0, src_max_len);
408
		}
443
		}
409
		draw_text(cx + num_str.length(), cy + i, fg, bg, src);
444
		draw_text(cx + 1 + num_str.length(), cy + i, fg, bg, src);
410
  
445
  
411
		if (is_current) {
446
		if (is_current) {
412
			for (int k = cx + num_str.length() + src.length(); k < cx + cw; ++k) {
447
			for (int k = cx + 1 + num_str.length() + src.length(); k < cx + cw; ++k) {
413
				tb_set_cell(k, cy + i, ' ', fg, bg);
448
				tb_set_cell(k, cy + i, ' ', fg, bg);
414
			}
449
			}
415
		}
450
		}
...