From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id B9CC81F463 for ; Sun, 29 Dec 2019 19:32:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727070AbfL2TcR (ORCPT ); Sun, 29 Dec 2019 14:32:17 -0500 Received: from mail-ed1-f49.google.com ([209.85.208.49]:36170 "EHLO mail-ed1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726958AbfL2TcQ (ORCPT ); Sun, 29 Dec 2019 14:32:16 -0500 Received: by mail-ed1-f49.google.com with SMTP id j17so30781024edp.3 for ; Sun, 29 Dec 2019 11:32:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=fqWXxP3mtA+/I3LZAkzV5U14TPbzZZnJua/q1EQZFb0=; b=fsSO5fcLVRoUcSnw/rCj05qkRXou4KT+KUv2YpALSITwa1fXzcntAsT67f3UDs1gxa 5H9hN93YE8xWU5DktsBXo4IeyxxHXCI/CjqoP/RpLnX3G7YLrT/SqEEb2XiyICcjQFdk F7XLpwZEEa2M6bwQbuBbiGuAstMGZgOeAKhShHPnxZJEhOtsHmU03+jlDEJsoqUmXars LFohCW7bW94dNEp86k8CBB5G4/KL7OlA9OP+o55z4sr6HlwsqulPpNMUCNv+9di9Pgqb 1DjiXkCp4eJP1l51mS82ex/D8I6zB0beXzWmjlAenVMZzSehGEnqyuUnRLrsv/6HoadQ 6ReQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=fqWXxP3mtA+/I3LZAkzV5U14TPbzZZnJua/q1EQZFb0=; b=eNEdnC1UyE5O1B2Hc68V9gYiA3zUeH4cI19ZnGiEZg4EHLoF2mCWsKNKapqutP6P/L imD0hMyHidzQ/5EEYuMS4K6Xx7IKDEK6F8lJY++GMVIs84loMwAQD6XHULRnryoAtmHE 6xGhnBT+MZ2uuMJFnC4582SMhSaH38EjCegYey10hrA2xjmiSGgBmkqQFgQBVGA3of24 mH0Fs6xXd9GREFEFTijPK2Yisd3odHTdgL1S5yfDMulBSWSrN2djrsxcxQINZ5OpQy6J RDBB8zI9x0c+VzXC5S3U4IhpZHFwtpUDfEbQUnwj2oyI4+k17KzLI8tSEWGHJmQVFgu2 57Fw== X-Gm-Message-State: APjAAAXtvr6JtXoLY8M+7k7e2TuFsrfCYqdiN4M5vOURWUsdnS/0c5z2 WdGZcuI9FZDLrVHOKiOUazdFoNmq X-Google-Smtp-Source: APXvYqxslf6OhWV+iiftak+C2aYEFjqxAlT9ykxsiMDb+oreKDD2pZifdFglp2CsdaHZhi7K57adRA== X-Received: by 2002:a17:906:f286:: with SMTP id gu6mr65526092ejb.146.1577647931738; Sun, 29 Dec 2019 11:32:11 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id dn12sm5125224edb.89.2019.12.29.11.32.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Dec 2019 11:32:11 -0800 (PST) Message-Id: In-Reply-To: References: From: "Zoli =?UTF-8?Q?Szab=C3=B3?= via GitGitGadget" Date: Sun, 29 Dec 2019 19:32:09 +0000 Subject: [PATCH v2 0/1] git-gui: allow opening currently selected file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fcc: Sent To: git@vger.kernel.org Cc: Pratyush Yadav Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org ...in the default associated app (e.g. in a text editor / IDE). Many times there's the need to quickly open a source file (the one you're looking at in Git GUI) in the predefined text editor / IDE. Of course, the file can be searched for in your preferred file manager or directly in the text editor, but having the option to directly open the current file from Git GUI would be just faster. This change enables just that by: * clicking the diff header path (which is now highlighted as a hyperlink) * or diff header path context menu -> Open; Note: executable files will be run and not opened for editing. Signed-off-by: Zoli Szabó zoli.szabo@gmail.com [zoli.szabo@gmail.com] Zoli Szabó (1): git-gui: allow opening currently selected file git-gui.sh | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) base-commit: 23cbe427c44645a3ab0449919e55bade5eb264bc Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-499%2Fzoliszabo%2Fgit-gui%2Fopen-current-file-v2 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-499/zoliszabo/git-gui/open-current-file-v2 Pull-Request: https://github.com/gitgitgadget/git/pull/499 Range-diff vs v1: 1: fce80f1b95 ! 1: a6fde256f8 git-gui: add possibility to open currently selected file @@ -1,6 +1,6 @@ Author: Zoli Szabó - git-gui: add possibility to open currently selected file + git-gui: allow opening currently selected file ...in the default associated app (e.g. in a text editor / IDE). @@ -9,11 +9,10 @@ the file can be searched for in your preferred file manager or directly in the text editor, but having the option to directly open the current file from Git GUI would be just faster. This change enables just that by: - - Diff header path context menu -> Open; - - or double-clicking the diff header path. + - clicking the diff header path (which is now highlighted as a hyperlink) + - or diff header path context menu -> Open; - One "downside" of the approach is that executable files will be run - and not opened for editing. + Note: executable files will be run and not opened for editing. Signed-off-by: Zoli Szabó @@ -26,11 +25,12 @@ -proc do_explore {} { - global _gitworktree +- set explorer {} +# Get the system-specific explorer app/command. +proc get_explorer {} { - set explorer {} if {[is_Cygwin] || [is_Windows]} { set explorer "explorer.exe" + } elseif {[is_MacOSX]} { @@ # freedesktop.org-conforming system is our best shot set explorer "xdg-open" @@ -44,9 +44,7 @@ eval exec $explorer [list [file nativename $_gitworktree]] & } -+# Trigger opening a file (relative to the working tree) by the default -+# associated app of the OS (e.g. a text editor or IDE). -+# FIXME: What about executables (will be run, not opened for editing)? ++# Open file relative to the working tree by the default associated app. +proc do_file_open {file} { + global _gitworktree + set explorer [get_explorer] @@ -57,18 +55,30 @@ set is_quitting 0 set ret_code 1 +@@ + -justify left + tlabel .vpane.lower.diff.header.path \ + -background gold \ +- -foreground black \ ++ -foreground blue \ + -anchor w \ +- -justify left ++ -justify left \ ++ -font [eval font create [font configure font_ui] -underline 1] \ ++ -cursor hand2 + pack .vpane.lower.diff.header.status -side left + pack .vpane.lower.diff.header.file -side left + pack .vpane.lower.diff.header.path -fill x @@ -type STRING \ -- $current_diff_path } +$ctxm add command \ + -label [mc Open] \ -+ -command { -+ do_file_open $current_diff_path -+ } ++ -command {do_file_open $current_diff_path} lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state] bind_button3 .vpane.lower.diff.header.path "tk_popup $ctxm %X %Y" -+bind .vpane.lower.diff.header.path {do_file_open $current_diff_path} ++bind .vpane.lower.diff.header.path {do_file_open $current_diff_path} # -- Diff Body # -- gitgitgadget