Text Input Dialogue + Player Notepad Compatibility Issue

Simply put: Even when popped into a fresh project, these two scripts:

and
don't play well together.
The problem seems to lie within Text Input Window [or CmdInp.js]. When the Player Notepad plugin is active, the Text Input Window doesn't allow use of the player's keyboard.

I have tried EVERY other plugin out there for inputting text to a variable with the keyboard. The only other one that worked was qInput, but unfortunately that one completely breaks Player Notepad and doesn't let IT use the keyboard. So, I'm stuck with these two.

Could anyone figure out a compatibility fix between these two plugins?

----------------
Side-problem, would anyone be able to fix the 'default header' text parameter in Text Input Window? It still requires you to put_underscores_between_your_words_in_the_plugin_command and the dev has stated they won't fix this.
I want to say there's just some sloppy scripting that could be cleaned up, but I'm not sure. 😛 That seems very fixable to just have a user-provided string in " " that could give the player a hint above their input window.

Thanks in advance for any help!

If I can't get these solved, I'll probably just request my own Text Input Window script, lmao.
Side-problem, would anyone be able to fix the 'default header' text parameter in Text Input Window? It still requires you to put_underscores_between_your_words_in_the_plugin_command and the dev has stated they won't fix this.
I want to say there's just some sloppy scripting that could be cleaned up, but I'm not sure. 😛
There's a pretty good reason for this, I'd say. If it's sloppy scripting, it's in the core RMMV engine itself. The engine automatically splits plugin commands into arguments based on spaces, so if you wanted to split it some other way you would have to recombine the arguments and re-parse it. Broadly speaking, parsing is hard.

Now, this is a relatively simple case of parsing though, so it's definitely possible to do. This code is untested, but I think it should work correctly if you put it in a plugin that loads right after Text Input Window. There could be some syntax errors, mind you.
JavaScript:
(function() {
    var old_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(cmd, args) {
        if(cmd === 'enter_text' && (args[2] === 'false' || args[2] === 'true')) {
            // Note: Here I'm accounting for the "use image" option even though based on the source code it looks like it will never work
            var i = JSON.parse(args[2]) ? 4 : 3;
            var prompt, input;
            if(args[i].startsWith('"')) {
                prompt = args[i].slice(1);
                for(var j = i + 1; j < args.length; j++) {
                    prompt += ' ';
                    if(args[j].endsWith('"')) {
                        prompt += args[j].slice(0, -1);
                        break;
                    } else prompt += args[j];
                }
                args.splice(i, i - j + 1, prompt + ' ');
            }
            i++;
            if(args[i].startsWith('"')) {
                input = args[i].slice(1);
                for(var j = i + 1; j < args.length; j++) {
                    input += ' ';
                    if(args[j].endsWith('"')) {
                        input += args[j].slice(0, -1);
                        break;
                    } else input += args[j];
                }
                args.splice(i, i - j + 1, input + ' ');
            }
        }
        old_pluginCommand.call(this, cmd, args);
    };
})();

What this does is reparse the arguments before Text Input Window even sees it, so although it'll still replace underscores with spaces, you can instead enclose the string in double quotes. Note that it with the quick-and-dirty way I've coded this, you do need at least a space before the opening quote and either a space or nothing at all after the closing quote.

(I glanced through the code of both plugins and couldn't see any clue as to why they don't play well together. When you have both enabled, do you get any errors in the F8 console?)
There's a pretty good reason for this, I'd say. If it's sloppy scripting, it's in the core RMMV engine itself. The engine automatically splits plugin commands into arguments based on spaces, so if you wanted to split it some other way you would have to recombine the arguments and re-parse it. Broadly speaking, parsing is hard.

Now, this is a relatively simple case of parsing though, so it's definitely possible to do. This code is untested, but I think it should work correctly if you put it in a plugin that loads right after Text Input Window. There could be some syntax errors, mind you.
JavaScript:
(function() {
    var old_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(cmd, args) {
        if(cmd === 'enter_text' && (args[2] === 'false' || args[2] === 'true')) {
            // Note: Here I'm accounting for the "use image" option even though based on the source code it looks like it will never work
            var i = JSON.parse(args[2]) ? 4 : 3;
            var prompt, input;
            if(args[i].startsWith('"')) {
                prompt = args[i].slice(1);
                for(var j = i + 1; j < args.length; j++) {
                    prompt += ' ';
                    if(args[j].endsWith('"')) {
                        prompt += args[j].slice(0, -1);
                        break;
                    } else prompt += args[j];
                }
                args.splice(i, i - j + 1, prompt + ' ');
            }
            i++;
            if(args[i].startsWith('"')) {
                input = args[i].slice(1);
                for(var j = i + 1; j < args.length; j++) {
                    input += ' ';
                    if(args[j].endsWith('"')) {
                        input += args[j].slice(0, -1);
                        break;
                    } else input += args[j];
                }
                args.splice(i, i - j + 1, input + ' ');
            }
        }
        old_pluginCommand.call(this, cmd, args);
    };
})();

What this does is reparse the arguments before Text Input Window even sees it, so although it'll still replace underscores with spaces, you can instead enclose the string in double quotes. Note that it with the quick-and-dirty way I've coded this, you do need at least a space before the opening quote and either a space or nothing at all after the closing quote.

(I glanced through the code of both plugins and couldn't see any clue as to why they don't play well together. When you have both enabled, do you get any errors in the F8 console?)

Stars, I tried to implement this and follow along, but it still doesn't seem to be fixing anything. That or I'm just a wee bit dumb. I saw that you took a look at my plugin request related to this- do you think it'd be easier to get a new plugin, or to fix this one?
Honestly, I'm not sure. I think it's reasonable to leave both possibilities open.

Note that the code I posted was only supposed to address the underscores_in_the_command, so you'd have to disable ALOE's notepad if testing that it actually works. In other words, it's only useful if the incompatibility can be found and addressed.

Original thread: https://forums.rpgmakerweb.com/threads/text-input-dialogue-player-notepad-compatibility-issue.123780/