* StyledEditWindow::_LoadFile() now traverses symlinks when opening a file.
This fixes bug #593. * No longer opens an empty document for every non existing path - it now only opens a new document if there is none yet. * No longer open an empty document for non existing files - instead, it just passes the ref to StyledEditApp::OpenDocument(). StyledEditWindow::_LoadFile() now treats those files gently as well, so that you can create new documents via StyledEdit as on BeOS without getting annoyed too much. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17699 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
7a9de5d194
commit
56a7c23d08
@ -66,6 +66,9 @@ uncascade()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
StyledEditApp::StyledEditApp()
|
StyledEditApp::StyledEditApp()
|
||||||
: BApplication(APP_SIGNATURE)
|
: BApplication(APP_SIGNATURE)
|
||||||
{
|
{
|
||||||
@ -216,15 +219,13 @@ StyledEditApp::ArgvReceived(int32 argc, const char* argv[], const char* cwd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
if (get_ref_for_path(path.Path(), &ref) != B_OK) {
|
status_t status = get_ref_for_path(path.Path(), &ref);
|
||||||
fprintf(stderr, "Entry not found: \"%s\".\n", path.Path());
|
if (status != B_OK) {
|
||||||
|
fprintf(stderr, "Could not open \"%s\": %s.\n", path.Path(), strerror(status));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BEntry entry(&ref);
|
|
||||||
if (entry.IsFile())
|
OpenDocument(&ref);
|
||||||
OpenDocument(&ref);
|
|
||||||
else if (fWindowCount == 0)
|
|
||||||
OpenDocument();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +242,6 @@ int32
|
|||||||
StyledEditApp::NumberOfWindows()
|
StyledEditApp::NumberOfWindows()
|
||||||
{
|
{
|
||||||
return fWindowCount;
|
return fWindowCount;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include <PrintJob.h>
|
#include <PrintJob.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <ScrollView.h>
|
#include <ScrollView.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
#include <TranslationUtils.h>
|
#include <TranslationUtils.h>
|
||||||
@ -35,12 +34,13 @@
|
|||||||
#include <CharacterSet.h>
|
#include <CharacterSet.h>
|
||||||
#include <CharacterSetRoster.h>
|
#include <CharacterSetRoster.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
|
|
||||||
|
|
||||||
StyledEditWindow::StyledEditWindow(BRect frame, int32 id, uint32 encoding)
|
StyledEditWindow::StyledEditWindow(BRect frame, int32 id, uint32 encoding)
|
||||||
: BWindow(frame,"untitled",B_DOCUMENT_WINDOW,0)
|
: BWindow(frame, "untitled", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS)
|
||||||
{
|
{
|
||||||
InitWindow(encoding);
|
InitWindow(encoding);
|
||||||
BString unTitled;
|
BString unTitled;
|
||||||
@ -54,7 +54,7 @@ StyledEditWindow::StyledEditWindow(BRect frame, int32 id, uint32 encoding)
|
|||||||
|
|
||||||
|
|
||||||
StyledEditWindow::StyledEditWindow(BRect frame, entry_ref *ref, uint32 encoding)
|
StyledEditWindow::StyledEditWindow(BRect frame, entry_ref *ref, uint32 encoding)
|
||||||
: BWindow(frame,"untitled",B_DOCUMENT_WINDOW,0)
|
: BWindow(frame, "untitled", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS)
|
||||||
{
|
{
|
||||||
InitWindow(encoding);
|
InitWindow(encoding);
|
||||||
OpenFile(ref);
|
OpenFile(ref);
|
||||||
@ -940,12 +940,27 @@ StyledEditWindow::SaveAs(BMessage *message)
|
|||||||
status_t
|
status_t
|
||||||
StyledEditWindow::_LoadFile(entry_ref* ref)
|
StyledEditWindow::_LoadFile(entry_ref* ref)
|
||||||
{
|
{
|
||||||
|
BEntry entry(ref, true);
|
||||||
|
// traverse an eventual link
|
||||||
|
|
||||||
|
status_t status = entry.InitCheck();
|
||||||
|
if (status == B_OK && entry.IsDirectory())
|
||||||
|
status = B_IS_A_DIRECTORY;
|
||||||
|
|
||||||
BFile file;
|
BFile file;
|
||||||
status_t status = file.SetTo(ref, B_READ_ONLY);
|
if (status == B_OK)
|
||||||
|
status = file.SetTo(&entry, B_READ_ONLY);
|
||||||
if (status == B_OK)
|
if (status == B_OK)
|
||||||
status = fTextView->GetStyledText(&file);
|
status = fTextView->GetStyledText(&file);
|
||||||
|
|
||||||
|
if (status == B_ENTRY_NOT_FOUND) {
|
||||||
|
// Treat non-existing files consideratley; we just want to get an
|
||||||
|
// empty window for them - to create this new document
|
||||||
|
status = B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
|
// If an error occured, bail out and tell the user what happened
|
||||||
BEntry entry(ref, true);
|
BEntry entry(ref, true);
|
||||||
char name[B_FILE_NAME_LENGTH];
|
char name[B_FILE_NAME_LENGTH];
|
||||||
if (entry.GetName(name) != B_OK)
|
if (entry.GetName(name) != B_OK)
|
||||||
|
Loading…
Reference in New Issue
Block a user