summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-07 14:43:12 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-07 14:43:12 +0100
commit3ee0e82206c1bba2b65fc80221c44e9f7931f303 (patch)
tree8623aca5562196243b5bd16b171463cfb4c1f604
parentce35cddb1b762bb4c21e09cfd38e33ddcae4393a (diff)
downloadserenity-3ee0e82206c1bba2b65fc80221c44e9f7931f303.zip
FileManager: Open non-executable files in TextEditor by default.
-rw-r--r--Applications/FileManager/DirectoryTableModel.cpp8
-rw-r--r--Applications/TextEditor/main.cpp2
2 files changed, 9 insertions, 1 deletions
diff --git a/Applications/FileManager/DirectoryTableModel.cpp b/Applications/FileManager/DirectoryTableModel.cpp
index 138f55f99f..550ed4598e 100644
--- a/Applications/FileManager/DirectoryTableModel.cpp
+++ b/Applications/FileManager/DirectoryTableModel.cpp
@@ -219,4 +219,12 @@ void DirectoryTableModel::activate(const GModelIndex& index)
}
return;
}
+
+ if (fork() == 0) {
+ int rc = execl("/bin/TextEditor", "/bin/TextEditor", path.string().characters(), nullptr);
+ if (rc < 0)
+ perror("exec");
+ ASSERT_NOT_REACHED();
+ }
+ return;
}
diff --git a/Applications/TextEditor/main.cpp b/Applications/TextEditor/main.cpp
index 06fc62a950..2180e4db32 100644
--- a/Applications/TextEditor/main.cpp
+++ b/Applications/TextEditor/main.cpp
@@ -29,7 +29,7 @@ int main(int argc, char** argv)
statusbar->set_text(String::format("Line: %d, Column: %d", editor.cursor().line(), editor.cursor().column()));
};
- String path = "/home/anon/ReadMe.md";
+ String path = argc < 2 ? "/home/anon/ReadMe.md" : argv[1];
{
StringBuilder builder;
int fd = open(path.characters(), O_RDONLY);