Commit 2a864a27 authored by SJFrK's avatar SJFrK

Add read-only mode.

parent 4e384b94
......@@ -126,10 +126,16 @@ impl Editor {
}
},
Write { path } => {
self.status_bar.msg = match self.write(path) {
FileStatus::NotFound => format!("File {} could not be opened", path),
FileStatus::Ok => format!("File {} written", path),
FileStatus::Other => format!("Couldn't write {}", path),
if self.options.get("readonly") == Some(true) {
// TODO: add override (w!)
self.status_bar.msg = format!("File {} is opened in readonly mode", path)
}
else {
self.status_bar.msg = match self.write(path) {
FileStatus::NotFound => format!("File {} could not be opened", path),
FileStatus::Ok => format!("File {} written", path),
FileStatus::Other => format!("Couldn't write {}", path),
}
}
},
ListBuffers => {
......
......@@ -248,31 +248,32 @@ impl Editor {
break;
}
_ => {
let mut arg_chars = arg.chars();
if arg_chars.next() == Some('-') {
for ch in arg_chars {
match ch {
'R' => {
unimplemented!();
/*
match editor.options.set("readonly") {
Ok(_) => debugln!(editor, "Set readonly mode"),
Err(_) => println!("Could not set readonly mode")
{
let mut arg_chars = arg.chars();
if arg_chars.next() == Some('-') {
for ch in arg_chars {
match ch {
'R' => {
match editor.options.set("readonly") {
Ok(_) => debugln!(editor, "Set readonly mode"),
Err(_) => println!("Could not set readonly mode")
}
},
'h' => {
println!("{}", HELP);
return;
},
_ => {
unimplemented!();
}
*/
},
'h' => {
println!("{}", HELP);
return;
},
_ => {
unimplemented!();
}
}
continue;
}
}
files.push(arg.clone());
files.push(arg);
}
}
}
......
......@@ -20,7 +20,7 @@ impl Options {
debug: true, // TODO: Let this be `true` only in debug compilation cfg
highlight: true,
line_marker: true,
readonly: true, // TODO: actually implement read-only mode
readonly: false,
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment