[haiku-commits] haiku: hrev49504 - src/apps/terminal

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 3 Aug 2015 13:15:44 +0200 (CEST)

hrev49504 adds 1 changeset to branch 'master'
old head: 7771139cdf652d3712c0b96b8e9e2dda6db6191e
new head: 52100b0c0e79c475267b510420f1f1da133005ca
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=52100b0c0e79+%5E7771139cdf65

----------------------------------------------------------------------------

52100b0c0e79: Terminal: Support paths starting with '~' in hyperlink mode

Implements #12282.

[ Ingo Weinhold <ingo_weinhold@xxxxxx> ]

----------------------------------------------------------------------------

Revision: hrev49504
Commit: 52100b0c0e79c475267b510420f1f1da133005ca
URL: http://cgit.haiku-os.org/haiku/commit/?id=52100b0c0e79
Author: Ingo Weinhold <ingo_weinhold@xxxxxx>
Date: Mon Aug 3 11:15:59 2015 UTC

Ticket: https://dev.haiku-os.org/ticket/12282

----------------------------------------------------------------------------

1 file changed, 13 insertions(+), 2 deletions(-)
src/apps/terminal/TermViewStates.cpp | 15 +++++++++++++--

----------------------------------------------------------------------------

diff --git a/src/apps/terminal/TermViewStates.cpp
b/src/apps/terminal/TermViewStates.cpp
index ed366b2..e24fa8d 100644
--- a/src/apps/terminal/TermViewStates.cpp
+++ b/src/apps/terminal/TermViewStates.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2013, Haiku, Inc.
+ * Copyright 2001-2015, Haiku, Inc.
* Copyright 2003-2004 Kian Duffy, myob@xxxxxxxxxxxxxxxxxxxxx
* Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai.
* All rights reserved. Distributed under the terms of the MIT license.
@@ -23,8 +23,10 @@
#include <Catalog.h>
#include <Clipboard.h>
#include <Cursor.h>
+#include <FindDirectory.h>
#include <LayoutBuilder.h>
#include <MessageRunner.h>
+#include <Path.h>
#include <PopUpMenu.h>
#include <ScrollBar.h>
#include <UTF8.h>
@@ -896,7 +898,8 @@ TermView::HyperLinkState::_GetHyperLinkAt(BPoint where,
bool pathPrefixOnly,
path.Truncate(colonIndex);
if (_EntryExists(path, actualPath)) {
BString address = path == actualPath
- ? text :
BString(fCurrentDirectory) << '/' << text;
+ ? text
+ : BString(actualPath) <<
(text.String() + colonIndex);
_link = HyperLink(text, address,
i == 0
?
HyperLink::TYPE_PATH_WITH_LINE
@@ -920,6 +923,14 @@ TermView::HyperLinkState::_EntryExists(const BString& path,

if (path[0] == '/' || fCurrentDirectory.IsEmpty()) {
_actualPath = path;
+ } else if (path == "~" || path.StartsWith("~/")) {
+ // Replace '~' with the user's home directory. We don't handle
"~user"
+ // here yet.
+ BPath homeDirectory;
+ if (find_directory(B_USER_DIRECTORY, &homeDirectory) != B_OK)
+ return false;
+ _actualPath = homeDirectory.Path();
+ _actualPath << path.String() + 1;
} else {
_actualPath.Truncate(0);
_actualPath << fCurrentDirectory << '/' << path;


Other related posts:

  • » [haiku-commits] haiku: hrev49504 - src/apps/terminal - ingo_weinhold