Merge remote-tracking branch 'haiku/master' into package-management

This commit is contained in:
Ingo Weinhold
2013-05-12 23:30:52 +02:00
8 changed files with 178 additions and 65 deletions
@@ -402,7 +402,7 @@ SSlider::SSlider(const char* name, const char* label,
const char* const char*
SSlider::UpdateText() const SSlider::UpdateText() const
{ {
snprintf(fStatusLabel, sizeof(fStatusLabel), "%ld", Value()); snprintf(fStatusLabel, sizeof(fStatusLabel), "%" B_PRId32, Value());
return fStatusLabel; return fStatusLabel;
} }
@@ -269,6 +269,7 @@ ThreadHandler::HandleThreadAction(uint32 action)
TRACE_CONTROL(" ip: %#" B_PRIx64 "\n", frame->InstructionPointer()); TRACE_CONTROL(" ip: %#" B_PRIx64 "\n", frame->InstructionPointer());
target_addr_t frameIP = frame->GetCpuState()->InstructionPointer();
// When the thread is in a syscall, do the same for all step kinds: Stop it // When the thread is in a syscall, do the same for all step kinds: Stop it
// when it returns by means of a breakpoint. // when it returns by means of a breakpoint.
if (frame->Type() == STACK_FRAME_TYPE_SYSCALL) { if (frame->Type() == STACK_FRAME_TYPE_SYSCALL) {
@@ -284,15 +285,14 @@ ThreadHandler::HandleThreadAction(uint32 action)
// The second issue is that the temporary breakpoint is probably not necessary // The second issue is that the temporary breakpoint is probably not necessary
// anymore, since single-stepping over "syscall" instructions should just work // anymore, since single-stepping over "syscall" instructions should just work
// as expected. // as expected.
status_t error = _InstallTemporaryBreakpoint( status_t error = _InstallTemporaryBreakpoint(frameIP);
frame->GetCpuState()->InstructionPointer());
if (error != B_OK) { if (error != B_OK) {
_StepFallback(); _StepFallback();
return; return;
} }
fStepMode = STEP_OUT; fStepMode = STEP_OUT;
_RunThread(frame->GetCpuState()->InstructionPointer()); _RunThread(frameIP);
return; return;
} }
@@ -303,9 +303,10 @@ ThreadHandler::HandleThreadAction(uint32 action)
_StepFallback(); _StepFallback();
return; return;
} }
fPreviousInstructionPointer = frameIP;
fPreviousFrameAddress = frame->FrameAddress(); fPreviousFrameAddress = frame->FrameAddress();
fStepMode = STEP_OUT; fStepMode = STEP_OUT;
_RunThread(frame->GetCpuState()->InstructionPointer()); _RunThread(frameIP);
return; return;
} }
@@ -324,7 +325,7 @@ ThreadHandler::HandleThreadAction(uint32 action)
if (action == MSG_THREAD_STEP_INTO) { if (action == MSG_THREAD_STEP_INTO) {
// step into // step into
fStepMode = STEP_INTO; fStepMode = STEP_INTO;
_SingleStepThread(frame->GetCpuState()->InstructionPointer()); _SingleStepThread(frameIP);
} else { } else {
fPreviousFrameAddress = frame->FrameAddress(); fPreviousFrameAddress = frame->FrameAddress();
// step over // step over
@@ -648,7 +649,7 @@ ThreadHandler::_HandleBreakpointHitStep(CpuState* cpuState)
" - step out adding return value\n", cpuState " - step out adding return value\n", cpuState
->StackFramePointer(), fPreviousFrameAddress); ->StackFramePointer(), fPreviousFrameAddress);
ReturnValueInfo* info = new(std::nothrow) ReturnValueInfo( ReturnValueInfo* info = new(std::nothrow) ReturnValueInfo(
cpuState->InstructionPointer(), cpuState); fPreviousInstructionPointer, cpuState);
if (info == NULL) if (info == NULL)
return false; return false;
BReference<ReturnValueInfo> infoReference(info, true); BReference<ReturnValueInfo> infoReference(info, true);
@@ -730,8 +731,8 @@ ThreadHandler::_HandleSingleStepStep(CpuState* cpuState)
TRACE_CONTROL("ThreadHandler::_HandleSingleStepStep() " TRACE_CONTROL("ThreadHandler::_HandleSingleStepStep() "
" - adding return value for STEP_OVER\n"); " - adding return value for STEP_OVER\n");
ReturnValueInfo* info = new(std::nothrow) ReturnValueInfo* info = new(std::nothrow)
ReturnValueInfo(cpuState->InstructionPointer(), ReturnValueInfo(fStepStatement
cpuState); ->CoveringAddressRange().Start(), cpuState);
if (info == NULL) if (info == NULL)
return false; return false;
BReference<ReturnValueInfo> infoReference(info, true); BReference<ReturnValueInfo> infoReference(info, true);
+11 -3
View File
@@ -20,11 +20,19 @@ HyperLink::HyperLink()
} }
HyperLink::HyperLink(const BString& address, Type type, HyperLink::HyperLink(const BString& address, Type type)
const BString& baseAddress)
: :
fText(address),
fAddress(address),
fType(type)
{
}
HyperLink::HyperLink(const BString& text, const BString& address, Type type)
:
fText(text),
fAddress(address), fAddress(address),
fBaseAddress(baseAddress.IsEmpty() ? address : baseAddress),
fType(type) fType(type)
{ {
} }
+5 -4
View File
@@ -20,20 +20,21 @@ public:
public: public:
HyperLink(); HyperLink();
HyperLink(const BString& address, Type type, HyperLink(const BString& address, Type type);
const BString& baseAddress = BString()); HyperLink(const BString& text,
const BString& address, Type type);
bool IsValid() const { return !fAddress.IsEmpty(); } bool IsValid() const { return !fAddress.IsEmpty(); }
const BString& Text() const { return fText; }
const BString& Address() const { return fAddress; } const BString& Address() const { return fAddress; }
const BString& BaseAddress() const { return fBaseAddress; }
Type GetType() const { return fType; } Type GetType() const { return fType; }
status_t Open(); status_t Open();
private: private:
BString fText;
BString fAddress; BString fAddress;
BString fBaseAddress;
Type fType; Type fType;
}; };
+125 -33
View File
@@ -30,6 +30,9 @@
#include <UTF8.h> #include <UTF8.h>
#include <Window.h> #include <Window.h>
#include <Array.h>
#include "ActiveProcessInfo.h"
#include "Shell.h" #include "Shell.h"
#include "TermConst.h" #include "TermConst.h"
#include "TerminalBuffer.h" #include "TerminalBuffer.h"
@@ -52,6 +55,7 @@ static const uint32 kAutoScroll = 'AScr';
static const uint32 kMessageOpenLink = 'OLnk'; static const uint32 kMessageOpenLink = 'OLnk';
static const uint32 kMessageCopyLink = 'CLnk'; static const uint32 kMessageCopyLink = 'CLnk';
static const uint32 kMessageCopyAbsolutePath = 'CAbs';
static const uint32 kMessageMenuClosed = 'MClo'; static const uint32 kMessageMenuClosed = 'MClo';
@@ -638,6 +642,7 @@ TermView::HyperLinkState::HyperLinkState(TermView* view)
fURLCharClassifier(kURLAdditionalWordCharacters), fURLCharClassifier(kURLAdditionalWordCharacters),
fPathComponentCharClassifier( fPathComponentCharClassifier(
BString(kDefaultAdditionalWordCharacters).RemoveFirst("/")), BString(kDefaultAdditionalWordCharacters).RemoveFirst("/")),
fCurrentDirectory(),
fHighlight(), fHighlight(),
fHighlightActive(false) fHighlightActive(false)
{ {
@@ -648,6 +653,12 @@ TermView::HyperLinkState::HyperLinkState(TermView* view)
void void
TermView::HyperLinkState::Entered() TermView::HyperLinkState::Entered()
{ {
ActiveProcessInfo activeProcessInfo;
if (fView->GetActiveProcessInfo(activeProcessInfo))
fCurrentDirectory = activeProcessInfo.CurrentDirectory();
else
fCurrentDirectory.Truncate(0);
_UpdateHighlight(); _UpdateHighlight();
} }
@@ -791,61 +802,134 @@ TermView::HyperLinkState::_GetHyperLinkAt(BPoint where, bool pathPrefixOnly,
if (text.IsEmpty()) if (text.IsEmpty())
return false; return false;
// Collect a list of colons in the string and their respective positions in
// the text buffer. We do this up-front so we can unlock the text buffer
// while we're doing all the entry existence tests.
typedef Array<CharPosition> ColonList;
ColonList colonPositions;
TermPos searchPos = _start;
for (int32 index = 0; (index = text.FindFirst(':', index)) >= 0;) {
TermPos foundStart;
TermPos foundEnd;
if (!textBuffer->Find(":", searchPos, true, true, false, foundStart,
foundEnd)) {
return false;
}
CharPosition colonPosition;
colonPosition.index = index;
colonPosition.position = foundStart;
if (!colonPositions.Add(colonPosition))
return false;
index++;
searchPos = foundEnd;
}
textBufferLocker.Unlock();
// Since we also want to consider ':' a potential path delimiter, in two
// nested loops we chop off components from the beginning respective the
// end.
BString originalText = text;
TermPos originalStart = _start;
TermPos originalEnd = _end;
int32 colonCount = colonPositions.Count();
for (int32 startColonIndex = -1; startColonIndex < colonCount;
startColonIndex++) {
int32 startIndex;
if (startColonIndex < 0) {
startIndex = 0;
_start = originalStart;
} else {
startIndex = colonPositions[startColonIndex].index + 1;
_start = colonPositions[startColonIndex].position;
if (_start >= pos)
break;
_start.x++;
// Note: This is potentially a non-normalized position (i.e.
// the end of a soft-wrapped line). While not that nice, it
// works anyway.
}
for (int32 endColonIndex = colonCount; endColonIndex > startColonIndex;
endColonIndex--) {
int32 endIndex;
if (endColonIndex == colonCount) {
endIndex = originalText.Length();
_end = originalEnd;
} else {
endIndex = colonPositions[endColonIndex].index;
_end = colonPositions[endColonIndex].position;
if (_end <= pos)
break;
}
originalText.CopyInto(text, startIndex, endIndex - startIndex);
if (text.IsEmpty())
continue;
// check, whether the file exists // check, whether the file exists
struct stat st; BString actualPath;
if (lstat(text, &st) == 0) { if (_EntryExists(text, actualPath)) {
_link = HyperLink(text, HyperLink::TYPE_PATH); _link = HyperLink(text, actualPath, HyperLink::TYPE_PATH);
return true; return true;
} }
// As such this isn't an existing path. Try a few common alternative cases: // As such this isn't an existing path. We also want to recognize:
// * "<path>:"
// * "<path>:<line>" // * "<path>:<line>"
// * "<path>:<line>:"
// * "<path>:<line>:<column>" // * "<path>:<line>:<column>"
// * "<path>:<line>:<column>:"
if (text.Length() <= 1)
return false;
if (text[text.Length() - 1] == ':') {
text.Truncate(text.Length() - 1);
if (!textBuffer->PreviousLinePos(_end))
return false;
if (lstat(text, &st) == 0) {
_link = HyperLink(text, HyperLink::TYPE_PATH);
return true;
}
}
BString path = text; BString path = text;
for (int32 i = 0; i < 2; i++) { for (int32 i = 0; i < 2; i++) {
int32 colonIndex = path.FindLast(':'); int32 colonIndex = path.FindLast(':');
if (colonIndex <= 0 || colonIndex == path.Length() - 1) if (colonIndex <= 0 || colonIndex == path.Length() - 1)
return false; break;
char* numberEnd; char* numberEnd;
strtol(path.String() + colonIndex + 1, &numberEnd, 0); strtol(path.String() + colonIndex + 1, &numberEnd, 0);
if (*numberEnd != '\0') if (*numberEnd != '\0')
return false; break;
path.Truncate(colonIndex); path.Truncate(colonIndex);
if (lstat(path, &st) == 0) { if (_EntryExists(path, actualPath)) {
_link = HyperLink(text, BString address = path == actualPath
? text : BString(fCurrentDirectory) << '/' << text;
_link = HyperLink(text, address,
i == 0 i == 0
? HyperLink::TYPE_PATH_WITH_LINE ? HyperLink::TYPE_PATH_WITH_LINE
: HyperLink::TYPE_PATH_WITH_LINE_AND_COLUMN, : HyperLink::TYPE_PATH_WITH_LINE_AND_COLUMN);
path);
return true; return true;
} }
} }
}
}
return false; return false;
} }
bool
TermView::HyperLinkState::_EntryExists(const BString& path,
BString& _actualPath) const
{
if (path.IsEmpty())
return false;
if (path[0] == '/' || fCurrentDirectory.IsEmpty()) {
_actualPath = path;
} else {
_actualPath.Truncate(0);
_actualPath << fCurrentDirectory << '/' << path;
}
struct stat st;
return lstat(_actualPath, &st) == 0;
}
void void
TermView::HyperLinkState::_UpdateHighlight() TermView::HyperLinkState::_UpdateHighlight()
{ {
@@ -948,9 +1032,12 @@ TermView::HyperLinkMenuState::Prepare(BPoint point, const HyperLink& link)
case HyperLink::TYPE_PATH: case HyperLink::TYPE_PATH:
case HyperLink::TYPE_PATH_WITH_LINE: case HyperLink::TYPE_PATH_WITH_LINE:
case HyperLink::TYPE_PATH_WITH_LINE_AND_COLUMN: case HyperLink::TYPE_PATH_WITH_LINE_AND_COLUMN:
menuBuilder menuBuilder.AddItem(B_TRANSLATE("Open path"), kMessageOpenLink);
.AddItem(B_TRANSLATE("Open path"), kMessageOpenLink) menuBuilder.AddItem(B_TRANSLATE("Copy path"), kMessageCopyLink);
.AddItem(B_TRANSLATE("Copy path"), kMessageCopyLink); if (fLink.Text() != fLink.Address()) {
menuBuilder.AddItem(B_TRANSLATE("Copy absolute path"),
kMessageCopyAbsolutePath);
}
break; break;
} }
menu->SetTargetForItems(fView); menu->SetTargetForItems(fView);
@@ -975,22 +1062,27 @@ TermView::HyperLinkMenuState::MessageReceived(BMessage* message)
return true; return true;
case kMessageCopyLink: case kMessageCopyLink:
case kMessageCopyAbsolutePath:
{
if (fLink.IsValid()) { if (fLink.IsValid()) {
BString toCopy = message->what == kMessageCopyLink
? fLink.Text() : fLink.Address();
if (!be_clipboard->Lock()) if (!be_clipboard->Lock())
return true; return true;
be_clipboard->Clear(); be_clipboard->Clear();
if (BMessage *data = be_clipboard->Data()) { if (BMessage *data = be_clipboard->Data()) {
data->AddData("text/plain", B_MIME_TYPE, data->AddData("text/plain", B_MIME_TYPE, toCopy.String(),
fLink.Address().String(), toCopy.Length());
fLink.Address().Length());
be_clipboard->Commit(); be_clipboard->Commit();
} }
be_clipboard->Unlock(); be_clipboard->Unlock();
} }
return true; return true;
}
case kMessageMenuClosed: case kMessageMenuClosed:
fView->_NextState(fView->fDefaultState); fView->_NextState(fView->fDefaultState);
+9
View File
@@ -128,10 +128,18 @@ private:
virtual rgb_color BackgroundColor(); virtual rgb_color BackgroundColor();
virtual uint32 AdjustTextAttributes(uint32 attributes); virtual uint32 AdjustTextAttributes(uint32 attributes);
private:
struct CharPosition {
int32 index;
TermPos position;
};
private: private:
bool _GetHyperLinkAt(BPoint where, bool _GetHyperLinkAt(BPoint where,
bool pathPrefixOnly, HyperLink& _link, bool pathPrefixOnly, HyperLink& _link,
TermPos& _start, TermPos& _end); TermPos& _start, TermPos& _end);
bool _EntryExists(const BString& path,
BString& _actualPath) const;
void _UpdateHighlight(); void _UpdateHighlight();
void _UpdateHighlight(BPoint where, int32 modifiers); void _UpdateHighlight(BPoint where, int32 modifiers);
@@ -142,6 +150,7 @@ private:
private: private:
DefaultCharClassifier fURLCharClassifier; DefaultCharClassifier fURLCharClassifier;
DefaultCharClassifier fPathComponentCharClassifier; DefaultCharClassifier fPathComponentCharClassifier;
BString fCurrentDirectory;
TermViewHighlight fHighlight; TermViewHighlight fHighlight;
bool fHighlightActive; bool fHighlightActive;
}; };
+1
View File
@@ -2704,6 +2704,7 @@ Desktop::WindowForClientLooperPort(port_id port)
WindowList& WindowList&
Desktop::_Windows(int32 index) Desktop::_Windows(int32 index)
{ {
ASSERT(index >= 0 && index < kMaxWorkspaces);
return fWorkspaces[index].Windows(); return fWorkspaces[index].Windows();
} }
@@ -92,8 +92,9 @@ class ObjectListView : public BListView {
virtual bool InitiateDrag(BPoint point, int32 itemIndex, bool wasSelected) virtual bool InitiateDrag(BPoint point, int32 itemIndex, bool wasSelected)
{ {
printf("InitiateDrag(BPoint(%.1f, %.1f), itemIndex: %ld, wasSelected: %d)\n", printf("InitiateDrag(BPoint(%.1f, %.1f), itemIndex: %" B_PRId32
point.x, point.y, itemIndex, wasSelected); ", wasSelected: %d)\n", point.x, point.y, itemIndex,
wasSelected);
SwapItems(itemIndex, itemIndex + 1); SwapItems(itemIndex, itemIndex + 1);
return true; return true;
} }