OSDN Git Service

Merge branch 'master' into feature/sightre-prefix feature/sightre-prefix
authormtsgi <oq@live.jp>
Tue, 12 Nov 2019 14:07:30 +0000 (23:07 +0900)
committerGitHub <noreply@github.com>
Tue, 12 Nov 2019 14:07:30 +0000 (23:07 +0900)
app/kish/README.md
app/kish/default.html
app/kish/define.json
app/kish/kish.css
app/kish/kish.js
app/kish/kish_config.json
app/kish/kishrc.json
system.js
system/icons/q.png [new file with mode: 0644]
system/system.css

index 50eff45..589cc56 100644 (file)
@@ -1,2 +1,10 @@
 # kish
 kish is Powerful Shell for kit.
+
+```sh
+install https://mtsgi.github.io/kish/
+```
+
+#### [Documentation](https://mtsgi.github.io/kish/docs)
+
+> Compatible with **kit apps framework v2**
index ce9f736..eb05706 100644 (file)
@@ -5,8 +5,10 @@
         </div>
     </div>
 </div>
+
 <div id="kish-form">
-        <input type="text" id="kish-input" class="kit-selectable" autocomplete="off">
-        <i class="fa fa-chevron-right" id="kish-indicator"></i>
+    <input type="text" id="kish-input" class="kit-selectable" autocomplete="off">
+    <i class="fa fa-chevron-right" id="kish-indicator"></i>
 </div>
-<span id="kish-curcmd">kish</span>
\ No newline at end of file
+
+<span id="kish-curcmd">kish</span>
index b2167d6..c8b6c93 100644 (file)
@@ -2,7 +2,7 @@
     "id": "kish",
     "name": "kish",
     "icon": "icon.png",
-    "version": "0.3.0",
+    "version": "0.4.0",
     "author": "kit",
 
     "size": {
@@ -19,4 +19,4 @@
     "view": "default.html",
     "script": "kish.js",
     "css": "kish.css"
-}
\ No newline at end of file
+}
index 925c85b..c6c6c0e 100644 (file)
@@ -1,7 +1,7 @@
 .winc-kish {
   padding: 0;
-  background: transparent;
-       backdrop-filter: blur(10px);
+  background: rgba(0,0,0,.5);
+  backdrop-filter: blur(10px);
 }
 
 #kish-form {
@@ -25,6 +25,7 @@
   text-shadow: 0 1px 3px #202020;
   background: rgba(0, 0, 0, .5);
   box-shadow: inset 0 0 0 0 transparent, inset 0 0 0 0 transparent;
+  z-index: 98;
 }
 
 #kish-input:focus {
   bottom: 13px;
   left: 10px;
   color: #f0f0f0;
+  z-index: 99;
 }
 
 #kish-wrapper {
-  overflow: scroll;
+  overflow: auto;
   background-image: url(bg.jpg);
   background-size: cover;
   background-attachment: fixed;
 .kish-highlight{
   padding: 0 5px;
   color: #ceffb8;
-}
\ No newline at end of file
+}
index d0b2397..4fa9086 100644 (file)
@@ -1,12 +1,12 @@
-((_pid) => {
+((_pid, _app) => {
 
-    $.getJSON( System.launchpath[_pid] + "/kish_config.json", (data) => {
+    $.getJSON(_app.getPath("kish_config.json"), (data) => {
         let props = ["background","font-family","font-size","font-weight","color","text-align","text-shadow","background-size","background-attachment","backdrop-filter"];
         KWS.resize(_pid, data.width || "", data.height || "");
         if( data.styles ) for( let i in data.styles ){
             if( props.includes(i) ){
-                S.dom( _pid, "#kish-wrapper" ).css( i, data.styles[i] );
-                if( i == "backdrop-filter" ) S.dom( _pid ).css( i, data.styles[i] );
+                _app.dom('#kish-wrapper').css( i, data.styles[i] );
+                if( i == "backdrop-filter" ) _app.dom().css( i, data.styles[i] );
             }
         }
     });
@@ -26,7 +26,7 @@
         this.clear = function(arg){
             let args = arg.split(" ");
             let num = Number(args[0]);
-            if( !num ) S.dom(_pid, "#kish-out").html("");
+            if( !num ) _app.dom('#kish-out').html('');
             return false;
         }
     
             kishHistory.unshift( arg );
             kishCur = -1;
             if( arg.indexOf(" ") != -1 ) args = arg.substring( arg.indexOf(" ") + 1 );
-            S.dom(_pid, "#kish-out").append( "<div class='kish-item'><i class='fa fa-dollar-sign'></i><span class='kish-highlight'>" + cmd + "</span>" + args + "</div>" );
+            _app.dom('#kish-out').append(`<div class='kish-item'><i class='fa fa-dollar-sign'></i><span class='kish-highlight'>${cmd}</span>${args}</div>`);
             if( !Kish[cmd] ){
-                S.dom(_pid, "#kish-out").append( "<div class='kish-item'><i class='fa fa-angle-double-right'></i> kishコマンドは存在しません: " + cmd + "</div>" );
+                _app.dom('#kish-out').append(`<div class='kish-item'><i class='fa fa-angle-double-right'></i> kishコマンドは存在しません:${cmd}</div>`);
                 return false;  
             }
-            let exec = "Kish." + cmd + "('" + args + "')";
+            let exec = `Kish.${cmd}('${args}')`;
             try {
                 let rtn = eval(exec)
                 if( typeof rtn == "object" ) rtn = JSON.stringify(rtn, null, 4);
-                if( rtn ) S.dom(_pid, "#kish-out").append( "<div class='kish-item'><span class='kish-from'>" +cmd+ "</span><i class='fa fa-angle-double-right'></i> " + rtn + "</div>" );            
+                if( rtn ) _app.dom('#kish-out').append(`<div class='kish-item'><span class='kish-from'>${cmd}</span><i class='fa fa-angle-double-right'></i>${rtn}</div>`);            
             }
             catch (error) {
-                S.dom(_pid, "#kish-out").append( "<div class='kish-item'><span class='kish-from'>" +cmd+ "</span><i class='fa fa-exclamation-triangle'></i> " + error + "</div>" );
+                _app.dom('#kish-out').append(`<div class='kish-item'><span class='kish-from'>${cmd}</span><i class='fa fa-exclamation-triangle'></i>${error}</div>`);
             }
-    
         }
 
-        this.exit = function(){
-            System.close(_pid);
-        }
+        this.exit = () => _app.close();
 
         this.install = function(arg){
             let args = arg.split(" ");
             return "Start installing...";
         }
     
-        this.kish = function(){
-            return "kish v0.3.0";
-        }
+        this.kish = () => 'kish v0.4.0';
 
         this.launch = function(arg){
             args = arg.split(" ");
-            System.launchpath[processID] = System.appdir + args[0];
+            System.launchpath[pid] = System.appdir + args[0];
             $.getJSON( "./app/" + args[0] + "/define.json", appData ).fail( function() {
-                System.launchpath[processID] = args[0];
+                System.launchpath[pid] = args[0];
                 $.getJSON( args[0] + "/define.json", appData ).fail( function() {
                     Kish.print("Faild to launch an App: " + args[0], "launch");
                 } );
         }
 
         this.ls = function(){
-            let _r = "<i>path ~</i><br>";
-            for( let i in System.userarea ){
-                _r += "- " + i + "<br>";
-            }
+            let _r = "<strong>/</strong><ul>";
+            for( let i in System.userarea ) _r += `<li>${i}</li>`;
+            _r += "</ul>";
             return _r;
         }
 
             return count + "app(s) was uninstalled from kit.";
         }
 
-        this.ver = function(){
-            return System.version;
-        }
+        this.ver = () => System.version;
     }
 
-    $.getJSON( System.launchpath[_pid] + "/kishrc.json", (data) => {
-        for( let i of data.rc ) Kish.exec(i);
-    });
-
-    S.dom(_pid, "#kish-input").on( "keypress keyup keydown", (e) => {
-        let input = S.dom(_pid, "#kish-input").val().split(" ");
+    _app.dom('#kish-input').on( "keypress keyup keydown", (e) => {
+        let input = _app.dom('#kish-input').val().split(' ');
 
         if( typeof Kish[ input[0] ] == "function" ){
-            S.dom(_pid, "#kish-curcmd").show().text( input[0] );
-        }
-        else S.dom(_pid, "#kish-curcmd").hide();
-
-        if( e.keyCode == 13 && S.dom(_pid, "#kish-input").val() ){
-            Kish.exec( S.dom(_pid, "#kish-input").val() );
-            S.dom(_pid, "#kish-input").val("");
+            _app.dom('#kish-curcmd').show().text( input[0] );
         }
+        else _app.dom('#kish-curcmd').hide();
     } );
 
-    S.dom(_pid, "#kish-input").on( "keydown", (e) => {
-        if( e.keyCode == 38 ){
+    _app.dom('#kish-input').on('keydown keypress', (e) => {
+        if( e.keyCode == 13 && _app.dom('#kish-input').val() ){
+            Kish.exec( _app.qs('#kish-input')[0].value );
+            _app.dom('#kish-input').val('');
+        }
+        else if( e.keyCode == 38 ){
             if( kishCur < kishHistory.length - 1 ){
                 kishCur ++;
-                S.dom(_pid, "#kish-input").val( kishHistory[kishCur] );
+                _app.dom('#kish-input').val( kishHistory[kishCur] );
             }
         }
         else if( e.keyCode == 40 ){
             if( kishCur > 0 ){
                 kishCur --;
-                S.dom(_pid, "#kish-input").val( kishHistory[kishCur] );
+                _app.dom('#kish-input').val( kishHistory[kishCur] );
             }
             else if( kishCur == 0 ){
                 kishCur = -1;
-                S.dom(_pid, "#kish-input").val( "" );
+                _app.dom('#kish-input').val('');
             }
         }
     });
 
-    KWS.changeWindowTitle(_pid, "(kish)"+ System.username);
-    App.changeWindowTitle(_pid, "(kish)"+ System.username);
-})(pid);
\ No newline at end of file
+    $.getJSON( _app.getPath("kishrc.json"), (data) => {
+        for( let i of data.rc ) Kish.exec(i);
+    });
+
+    if( _app.args && _app.args['rc'] ){
+        for( let i of _app.args['rc'] ) Kish.exec(i);
+    }
+
+    _app.changeWindowTitle(`(kish) ${System.username}`);
+})(pid, app);
index 9326791..1d557b5 100644 (file)
@@ -13,4 +13,4 @@
         "text-align": "",
         "text-shadow": ""
     }
-}
\ No newline at end of file
+}
index 1021376..bbedc4b 100644 (file)
@@ -1,4 +1,4 @@
 {
     "rc": [
     ]
-}
\ No newline at end of file
+}
index f2aa088..24b128e 100644 (file)
--- a/system.js
+++ b/system.js
@@ -232,14 +232,7 @@ function kit() {
                 S.alert("", "<div style='text-align:left;'> _    _ _ <br>| | _(_) |_ <br>| |/ / | __|<br>|   〈| | |_ <br>|_|\_ \ _\__|</div><hr>", S.version);
                 return;
             }
-            let _args = null;
-            try {
-                if( _word.split(",")[1] ) _args = JSON.parse( _word.split(",").slice(1).join().trim() );
-            }
-            catch(error) {
-                Notification.push("引数の解釈に失敗", error, "system");
-            }
-            launch( _word.split(",")[0], _args );
+            $('.kit-sightre-result.-first').click();
             sightrePrevWord = '';
             $('#kit-sightre-form').val('');
             $('#kit-sightre-results').html('');
@@ -253,6 +246,52 @@ function kit() {
             $('#kit-sightre-results').html('');
             if( !_word ) return;
             sightrePrevWord = _word;
+            if( _word.indexOf('kish ') == 0 || _word.indexOf('🥧 ') == 0 ){
+                let _cmd = _word.substring( _word.indexOf(" ") + 1 );
+                if( _cmd ){
+                    $(`<div class='kit-sightre-result -first'>
+                            <img class='--icon' src='app/kish/icon.png'/>
+                            <div class='--info'>
+                                <div class='--name'>${_cmd}</div>
+                                <div class='--desc'>kishでコマンドを実行</div>
+                            </div>
+                            <div class='--open fa fa-arrow-right'></div>
+                        </div>`).appendTo('#kit-sightre-results').on('click', () => {
+                            launch('kish', { 'rc': [ _cmd ] });
+                    });
+                }
+            }
+            else if( _word.indexOf('http://') == 0 || _word.indexOf('https://') == 0 || _word.indexOf('localhost') == 0 ){
+                $(`<div class='kit-sightre-result -first'>
+                        <img class='--icon' src='app/browser/icon.png'/>
+                        <div class='--info'>
+                            <div class='--name'>${_word}</div>
+                            <div class='--desc'>ブラウザでURLを開く</div>
+                        </div>
+                        <div class='--open fa fa-arrow-right'></div>
+                    </div>`).appendTo('#kit-sightre-results').on('click', () => {
+                        launch( localStorage.getItem( "kit-default-browser" ), { "url" : _word } );
+                });
+            }
+            else {
+                $(`<div class='kit-sightre-result -first'>
+                        <img class='--icon' src='system/icons/q.png'/>
+                        <div class='--info'>
+                            <div class='--name'>${_word}</div>
+                            <div class='--desc'>アプリを起動する</div>
+                        </div>
+                        <div class='--open fa fa-arrow-right'></div>
+                    </div>`).appendTo('#kit-sightre-results').on('click', () => {
+                        let _args = null;
+                        try {
+                            if( _word.split(",")[1] ) _args = JSON.parse( _word.split(",").slice(1).join().trim() );
+                        }
+                        catch(error) {
+                            Notification.push("引数の解釈に失敗", error, "system");
+                        }
+                        launch( _word.split(",")[0], _args );
+                });
+            }
             for( let i in System.apps ){
                 if( i.indexOf(_word) == 0 || S.apps[i].name.indexOf(_word) == 0 ){
                     $(`<div class='kit-sightre-result -app'>
diff --git a/system/icons/q.png b/system/icons/q.png
new file mode 100644 (file)
index 0000000..bbcf1b4
Binary files /dev/null and b/system/icons/q.png differ
index 22683e5..669719c 100644 (file)
   border-left: 5px solid dodgerblue;
 }
 
+.kit-sightre-result.-first {
+  border-left: 5px solid crimson;
+}
+
 .kit-sightre-result .--open {
   opacity: 0;
   font-size: 24px;