summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-10-13 00:39:16 +0200
committerhut <hut@lavabit.com>2010-10-13 00:40:59 +0200
commita9046bfc42cb3b8e2d7276fea0fc3934caa9bbda (patch)
tree95fda59f64b7d7cab7efdfb7c71e9d7b6854372f /ranger
parentaa488bd940265362c530ec6f62033ceb2b56d10a (diff)
downloadranger-a9046bfc42cb3b8e2d7276fea0fc3934caa9bbda.tar.gz
core.actions: Fixed handling of scope.sh exit code 2
Diffstat (limited to 'ranger')
-rw-r--r--ranger/core/actions.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 3382b7b1..297de576 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -612,6 +612,8 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 					elif exit == 1:
 						data[(-1, -1)] = None
 						data['foundpreview'] = False
+					elif exit == 2:
+						data[(-1, -1)] = open(path, 'r').read(1024 * 32)
 					else:
 						data[(-1, -1)] = None
 					if self.env.cf.realpath == path:
/* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
function wrap(str, width) {
    let words = str.split(' ');
    let output = words.reduce((output, word) => {
        if (output.length === 0 || output[output.length - 1].length + word.length + 1 > width) {
            output.push(word);
        } else {
            output[output.length - 1] += ' ' + word;
        }
        return output;
    }, []).join('\n');
    return output;
}

function prettyItUp(string) {
    return string.charAt(0).toUpperCase() + string.slice(1) + "!";
}

fetch('corpus.txt')
    .then(response => response.text())
    .then(data => {
        let corpus = data;
        let words = corpus.toLowerCase().replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g,"").replace(/\n/g, " ").replace(/\s{2,}/g, " ").split(" ");

        let markovChain = new Map();

        for (let i = 0; i < words.length - 2; i++) {
            let pair = words[i] + ' ' + words[i + 1];
            if (!markovChain.has(pair)) {
                markovChain.set(pair, []);
            }
            markovChain.get(pair).push(words[i + 2]);
        }

        let pairs = Array.from(markovChain.keys());
        let randomPair = pairs[Math.floor(Math.random() * pairs.length)];
        let story = randomPair;
        const storyLength = 100;

        for (let i = 0; i < storyLength; i++) { 
            let nextWords = markovChain.get(randomPair);
            if (!nextWords) {
                break;
            }
            randomPair = randomPair.split(' ')[1] + ' ' + nextWords[Math.floor(Math.random() * nextWords.length)];
            story += ' ' + randomPair.split(' ')[1];
        }

        document.getElementById('beak').innerHTML = prettyItUp(story);
    });