From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.devel Subject: Re: gdb-ui, dedicated windows Date: Sat, 05 Jul 2008 10:11:06 -0600 Message-ID: References: <87zlowwyn1.fsf@localhorst.mine.nu> <18543.18102.11098.763936@kahikatea.snap.net.nz> Reply-To: Tom Tromey NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1215274318 21666 80.91.229.12 (5 Jul 2008 16:11:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 5 Jul 2008 16:11:58 +0000 (UTC) Cc: David Hansen , emacs-devel@gnu.org To: Nick Roberts Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jul 05 18:12:44 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KFANN-0005Sa-QP for ged-emacs-devel@m.gmane.org; Sat, 05 Jul 2008 18:12:42 +0200 Original-Received: from localhost ([127.0.0.1]:56049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KFAMW-0004s1-RD for ged-emacs-devel@m.gmane.org; Sat, 05 Jul 2008 12:11:48 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KFAM4-0004bJ-3V for emacs-devel@gnu.org; Sat, 05 Jul 2008 12:11:20 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KFAM2-0004a6-JH for emacs-devel@gnu.org; Sat, 05 Jul 2008 12:11:19 -0400 Original-Received: from [199.232.76.173] (port=38036 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KFAM2-0004Zt-43 for emacs-devel@gnu.org; Sat, 05 Jul 2008 12:11:18 -0400 Original-Received: from mx1.redhat.com ([66.187.233.31]:39764) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KFAM1-0005s0-6c for emacs-devel@gnu.org; Sat, 05 Jul 2008 12:11:17 -0400 Original-Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m65GB8X2030463; Sat, 5 Jul 2008 12:11:08 -0400 Original-Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m65GB7en003133; Sat, 5 Jul 2008 12:11:07 -0400 Original-Received: from opsy.redhat.com (vpn-10-25.bos.redhat.com [10.16.10.25]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m65GB6DF020785; Sat, 5 Jul 2008 12:11:07 -0400 Original-Received: by opsy.redhat.com (Postfix, from userid 500) id 485FC3781A8; Sat, 5 Jul 2008 10:11:06 -0600 (MDT) X-Attribution: Tom In-Reply-To: <18543.18102.11098.763936@kahikatea.snap.net.nz> (Nick Roberts's message of "Sat\, 5 Jul 2008 22\:02\:29 +1200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:100367 Archived-At: >> Another smaller annoyance: IMHO the separate IO buffer shouldn't be in a >> dedicated window even if `gdb-many-windows' is t. It just takes to much >> space and makes it hard to look at two source files at the same time. Nick> If it takes up too much room why use a separate buffer? If you need a Nick> separate buffer, why not put it in another frame? The effect I would like is to have a single, screen-filling "gdb UI" frame show up when I start debugging, and have it go away when I finish debugging. And, I'd like to be able to arrange the windows in this frame the way I like. The "one frame" approach is vaguely reminiscent of an Eclipse perspective. FWIW I think it is reasonable for some people to want multiple frames and some to want a single frame. To achieve this, a few changes are needed. First, Emacs needs a new way to maximize a frame so it doesn't overshadow the panel. Second, gdb-ui needs some window layout code. >> BTW, how about some key bindings to move around / display the gdb-ui >> windows? Nick> It would be nice to be able to move the buffers around like Nick> views in Eclipse but that would be a substantial task. Emacs 23 Nick> has tabs in the header line of some buffers. Do you have any Nick> concrete ideas? A while back I wrote the appended. It isn't perfect, but the idea is that you can rearrange the windows by hand, then save the state. Then, next time, M-x gdb-frame-restore-windows will use this window layout instead of the built-in one. A few unimplemented refinements: have gdb-ui do this automatically, save the window configuration, and allow multiple "source" windows w/ LRU replacement. Tom ;;; gdb-frame.el --- new frame for gdb ;; Copyright (C) 2007 Tom Tromey ;; Author: Tom Tromey ;; Created: 15 Sep 2007 ;; Version: 0.1 ;; Keywords: tools ;; This file is not (yet) part of GNU Emacs. ;; However, it is distributed under the same license. ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: ;;; Code: (defvar gdb-application-frame nil) (defun gdb-get-application-frame () (unless (frame-live-p gdb-application-frame) (setq gdb-application-frame (make-frame '((title . "Emacs - GDB") (tool-bar-lines . 1) (height . 55) (width . 183))))) (raise-frame gdb-application-frame) (select-frame-set-input-focus gdb-application-frame) gdb-application-frame) (defun tjt-gdba (command-line) (interactive (list (gud-query-cmdline 'gdba))) (when (and (eq window-system 'x) gdb-many-windows) (gdb-get-application-frame)) (gdba command-line)) (defvar gdb-frame-saved-windows nil) (defun gdb--restore-windows-mapper (window-symbol window) (if (eq window-symbol 'gdb-source-window) ;; Assumes just one source window in the tree. (setq gdb-source-window window) (set-window-buffer window (gdb-get-buffer window-symbol)))) (defun gdb--restore-windows (parent-window tree map-fn) (let* ((vertical (nth 0 tree)) (edges (nth 1 tree)) (window-spec (nthcdr 2 tree))) (while window-spec (let* ((elt (car window-spec)) next-window) (if (cdr window-spec) (setq next-window ;; 'elt' here works for both the vector children and ;; the list children. (split-window parent-window (elt elt 1) (not vertical)))) (if (vectorp elt) (funcall map-fn (elt elt 0) parent-window) (gdb--restore-windows parent-window elt map-fn)) (setq parent-window next-window) (setq window-spec (cdr window-spec)))))) (defun gdb-frame-restore-windows () (interactive) ;; Don't bother if we just had a single window. (delete-other-windows) (unless (symbolp gdb-frame-saved-windows) (gdb--restore-windows (selected-window) gdb-frame-saved-windows #'gdb--restore-windows-mapper))) (defun gdb--save-window-mapper (alist window) (if (eq window gdb-source-window) 'gdb-source-window (or (cdr (assq (window-buffer window) alist)) 'gdb-source-window))) (defun gdb--rewrite-window-tree (tree horizontal map-fn) (if (windowp tree) ;; Rewrite the window according to the mapper. ;; Also check for the source window. ;; If we don't understand what we have, assume it is the source. (let ((size (if horizontal (window-height tree) (window-width tree)))) (vector (funcall map-fn tree) size)) (append (list (nth 0 tree) (let ((sizes (nth 1 tree))) (if (nth 0 tree) (- (nth 2 sizes) (nth 0 sizes)) (- (nth 3 sizes) (nth 1 sizes))))) (mapcar (lambda (item) (gdb--rewrite-window-tree item (nth 0 tree) map-fn)) (nthcdr 2 tree))))) (defun gdb-frame-save-windows () (interactive) (let ((buffer-map ;; Map buffers to symbolic buffer names. (delq nil (mapcar (lambda (elt) (let ((buffer (gdb-get-buffer (car elt)))) (if buffer (cons buffer (car elt)) nil))) gdb-buffer-rules-assoc))) ;; Use 'car' to avoid the minibuffer window here. (tree (car (window-tree)))) (setq gdb-frame-saved-windows (gdb--rewrite-window-tree tree (if (consp tree) (nth 0 tree) nil) (lambda (window) (gdb--save-window-mapper buffer-map window)))))) ;;; gdb-frame.el ends here