diff --git a/commands/nano.json b/commands/nano.json
index cf01b75..3b66f9e 100644
--- a/commands/nano.json
+++ b/commands/nano.json
@@ -70,8 +70,9 @@
shell.editorkeypressed = this.editorkeypressed;
shell.confirmkey = this.confirmkey;
shell.bufferSave = this.bufferSave;
+ shell.firstKey = true; // Set when no key has been pressed yet
- shell.default_editor_status = "[^X Exit] [^O WriteOut] [^W Where Is]";
+ shell.default_editor_status = "[^X Exit] [^O WriteOut] [^F Where Is]";
if ( shell.perms )
{
@@ -107,7 +108,6 @@
editor.setAttribute ( 'class', 'editor_window' );
editor.setAttribute ( 'id', 'editor_window' );
editor.setAttribute ( 'onkeypress', 'shell.editorkeypressed ( event )' );
- editor.innerHTML = '';
has_content = false;
@@ -154,26 +154,16 @@
{
var evt = ( window.event ) ? window.event : e;
var key = ( evt.charCode ) ? evt.charCode : evt.keyCode;
- key = String.fromCharCode ( key );
- if ( !shell.file_changed )
+ if ( shell.firstKey && key == 13 )
{
- if ( shell.originalContent != shell.editor_window.value )
- {
- if ( shell.perms )
- {
- if ( shell.perms.write == false )
- {
- shell.default_editor_status += ' [read-only]';
- shell.editor_status.innerHTML += ' [read-only]';
- }
- }
-
- shell.editor_status.innerHTML += ' [modified]';
- shell.file_changed = true;
- }
+ evt.preventDefault();
+ shell.firstKey = false;
+ return false;
}
+ key = String.fromCharCode ( key );
+
if (( key == 'x' || key == 'X' ) && evt.ctrlKey )
{
evt.preventDefault();
@@ -208,6 +198,8 @@
shell.auto_prompt_refresh = true;
shell.refreshPrompt ( true );
}
+
+ return false;
} else if (( key == 'o' || key == 'O' ) && evt.ctrlKey ) {
evt.preventDefault();
@@ -230,14 +222,87 @@
shell.editor_status.innerHTML = shell.default_editor_status;
}
}
+
+ return false;
+ } else if (( key == 'f' || key == 'F' ) && evt.ctrlKey ) {
+ evt.preventDefault();
+
+ shell.editor_status.innerHTML = 'Text or regex to search: ' +
+ '';
+
+ document.getElementById ( 'editor_status_input' ).focus();
+ return false;
+ }
+
+ if ( !shell.file_changed )
+ {
+ if ( shell.originalContent != shell.editor_window.value )
+ {
+ if ( shell.perms )
+ {
+ if ( shell.perms.write == false )
+ {
+ shell.default_editor_status += ' [read-only]';
+ shell.editor_status.innerHTML += ' [read-only]';
+ }
+ }
+
+ shell.editor_status.innerHTML += ' [modified]';
+ shell.file_changed = true;
+ }
}
},
- "confirmkey" : function ( e )
+ "confirmkey" : function ( e, arg )
{
var can_write = false;
var evt = ( window.event ) ? window.event : e;
var key = ( evt.charCode ) ? evt.charCode : evt.keyCode;
+
+ if ( arg )
+ {
+ if ( arg == "find" )
+ {
+ var input = document.getElementById ( 'editor_status_input' );
+ var idx = -1;
+
+ if ( key == 13 )
+ {
+ shell.firstKey = true;
+
+ if ( input.value.length > 0 )
+ {
+ var matches = shell.editor_window.value.match ( new RegExp ( input.value ));
+
+ if ( matches )
+ {
+ idx = shell.editor_window.value.indexOf ( matches[0] );
+
+ }
+ }
+
+ shell.editor_status.innerHTML = shell.default_editor_status;
+ shell.editor_window.focus();
+
+ if ( idx > -1 )
+ {
+ if ( shell.editor_window.setSelectionRange )
+ {
+ shell.editor_window.setSelectionRange ( idx, idx + input.value.length );
+ }
+ } else {
+ shell.editor_status.innerHTML = 'No matches found';
+ setTimeout ( 'shell.editor_status.innerHTML = shell.default_editor_status', 1500 );
+ }
+
+ return false;
+ }
+ }
+
+ return false;
+ }
+
key = String.fromCharCode ( key );
if ( shell.perms )
@@ -266,6 +331,7 @@
case 'n':
case 'N':
evt.preventDefault();
+ shell.firstKey = true;
shell.auto_prompt_focus = true;
shell.auto_prompt_refresh = true;
shell.refreshPrompt ( true );
@@ -289,6 +355,7 @@
case 'y':
case 'Y':
evt.preventDefault();
+ shell.firstKey = true;
shell.auto_prompt_focus = true;
shell.auto_prompt_refresh = true;
shell.refreshPrompt ( true );
@@ -321,7 +388,7 @@
if ( http.responseText.length > 0 )
{
shell.editor_status.innerHTML = http.responseText;
- setTimeout ( 'shell.editor_status.innerHTML = shell.default_editor_status', 5000 );
+ setTimeout ( 'shell.editor_status.innerHTML = shell.default_editor_status', 1500 );
var files_config = window.location.href;
files_config = files_config.replace ( /\/([a-zA-Z\.]+)$/, '/modules/users/files.php' );
diff --git a/system/files_json.php b/system/files_json.php
index 2f5cadd..e61895b 100644
--- a/system/files_json.php
+++ b/system/files_json.php
@@ -32,7 +32,7 @@ $files_json = <<lol lol asd 'lol' <asd> 'asd'"}
+, {"path": "/home/blacklight/lol", "type": "file", "owner": "blacklight", "can_read": "@all", "can_write": "blacklight", "content": "#include <stdio.h>
int main () {
printf ( 'loln' );
}"}
]
JSON;