You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When Notpad++ Interface Language is set to English, the following script is executed successfully.
notepad.runMenuCommand("View", "Word wrap")
However, I couldn't find a way to run that script if the Interface Language is set to Hebrew.
I've tried various ".decode('utf8')" commands, but to no avail.
Thanks for replying. I appreciate it.
And many thanks you for your work on this plugin. 👍
The command in Hebrew is notepad.runMenuCommand("תצוגה", "גלילת שורות").
It works from the console but not within a script.
I use NPP in Hebrew and the layout is RTL.
Two related request:
1) Could you set the console layout to LTR even if NPP layout is RTL?
Please see this discussion (the RTL part).
@ClaudiaFrank kindly found the relevant code (thanks again Claudia).
As I've mentioned in that thread, Dave uploaded PythonScript v1.1.1 without committing the changes.
Have you committed the fix included in v1.1.1?
2) Could you add Unicode support to the menu?
Hebrew file-names are displayed as gibberish.
Allow me two more questions:
1) Dave's latest official version is 1.0.8.0. Why did you start with 0.6.3.0?
2) I've downloaded your latest PythonScript_Full_1.0.9.0.zip and replaced the DLL and the lib folder. from ctypes import windll, byref, wintypes, WINFUNCTYPE, Structure, sizeof in startup.py triggers an error.
Why is that?
Thanks also for your contribution to ComparePlugin. :)
I'm using the DLL from the zip package.
I've replaced python27.dll and PythonScript.dll with the new ones.
I don't get the error now. It was certainly there a few hours ago.
However, NPP consistently hangs when I'm using the following script.
if RIGHT_CLICK_MODE:
console.hide()
editor.grabFocus()
else:
console.show()
With the following startup.py (thanks again :) ).
# The lines up to and including sys.stderr should always come first
# Then any errors that occur later get reported to the console
# If you'd prefer to report errors to a file, you can do that instead here.
import sys
from Npp import *
# Set the stderr to the normal console as early as possible, in case of early errors
sys.stderr = console
# Define a class for writing to the console in red
class ConsoleError:
def __init__(self):
global console
self._console = console;
def write(self, text):
self._console.writeError(text);
# Set the stderr to write errors in red
sys.stderr = ConsoleError()
# This imports the "normal" functions, including "help"
import site
# This sets the stdout to be the currently active document, so print "hello world",
# will insert "hello world" at the current cursor position of the current document
sys.stdout = editor
##################### Right-click mode and Change console output to LTR. #####################
# See https://notepad-plus-plus.org/community/topic/13510/python-lua-script-detect-if-a-modifier-is-pressed-when-running-a-script.
# console.write('parent:{}\n'.format(parent))
from ctypes import windll, byref, wintypes, WINFUNCTYPE, Structure, sizeof
WNDENUMPROC = WINFUNCTYPE(wintypes.BOOL,
wintypes.HWND,
wintypes.LPARAM)
WndProcType = WINFUNCTYPE(wintypes.LONG,
wintypes.HWND,
wintypes.UINT,
wintypes.WPARAM,
wintypes.LPARAM)
GWL_WNDPROC = -4
RIGHT_CLICK_MODE = False
GWL_EXSTYLE = -20
WS_EX_LAYOUTRTL = 0x00400000
class NPPchildWindows():
def EnumNPPCallback(self, hWnd, lParam):
curr_class = (wintypes.WCHAR * 256)()
windll.user32.GetClassNameW(hWnd, curr_class, 256)
if lParam == 0:
if curr_class.value.lower() == "toolbarwindow32":
self.toolbar_handle = hWnd
return False
else:
curr_name = (wintypes.WCHAR * 256)()
windll.user32.GetWindowTextW(hWnd, curr_name, 256)
if curr_name.value.lower() == "python script":
self.python_script_hwnd = hWnd
elif curr_class.value.lower() == "scintilla" and windll.user32.GetParent(hWnd) == self.python_script_hwnd:
self.python_script_sci_handle = hWnd
return False
return True
def __init__(self):
self.toolbar_handle = None
self.oldWndProc = None
self.python_script_hwnd = None
self.python_script_sci_handle = None
parent = windll.user32.FindWindowA("Notepad++", None)
windll.user32.EnumChildWindows(parent, WNDENUMPROC(self.EnumNPPCallback), 0)
console.show()
windll.user32.EnumChildWindows(parent, WNDENUMPROC(self.EnumNPPCallback), 1)
def registerRightClick(self):
if self.toolbar_handle:
self.new_wnd_proc = WndProcType(self.sciWndProc)
self.oldWndProc = windll.user32.SetWindowLongA(self.toolbar_handle, GWL_WNDPROC, self.new_wnd_proc)
console.write("Toolbar right-click mode registered.\n\n")
def sciWndProc(self, hWnd, msg, wParam, lParam):
global RIGHT_CLICK_MODE
if msg == 0x0204: # WM_RBUTTONDOWN.
windll.user32.mouse_event(0x0002, 0, 0, 0, 0) # Left down. WM_RBUTTONUP is sent although the right button is still down.
elif msg == 0x0205: # WM_RBUTTONUP.
if RIGHT_CLICK_MODE: # Another WM_RBUTTONUP is sent when the right button is released. Send "Left up" now.
windll.user32.mouse_event(0x0004, 0, 0, 0, 0) # Left up.
else: # The right button is still down.
RIGHT_CLICK_MODE = True
elif RIGHT_CLICK_MODE and msg == 0x0201: # WM_LBUTTONDOWN.
RIGHT_CLICK_MODE = False
return windll.user32.CallWindowProcA (self.oldWndProc, hWnd, msg, wParam, lParam)
def consoleToLTR(self):
if self.python_script_sci_handle:
exStyle = windll.user32.GetWindowLongA(self.python_script_sci_handle, GWL_EXSTYLE)
exStyle = exStyle ^ WS_EX_LAYOUTRTL
windll.user32.SetWindowLongA(self.python_script_sci_handle, GWL_EXSTYLE, exStyle);
console.write("Console output changed to LTR.\n\n")
_NPPchildWindows = NPPchildWindows()
_NPPchildWindows.registerRightClick()
_NPPchildWindows.consoleToLTR()
console.hide()
editor.grabFocus()
I've added several right/left toolbar buttons (using CustomizeToolbar; executing various scripts) and they all work properly except the Show/Hide one.
Actually, just using console.show() causes NPP to hang.
Reverting to the original startup.py, console.show() works as expected.
Replacing the new PythonScript.dll with the old one - the Show/Hide button works properly.
Why do you think 1.0.9.0 was created out from 0.6.3??
Don't think there is a diff between last or previous.
...
I don't have any opinion on Last vs. Previous - for me, both explain the same.
It's certainly not important but I think that Last is more commonly used in this context (e.g. Last Closed Tab).
As you understand.
Ellipses...
Well... I thought the rule was that any command/button opening a new window should have an ellipses.
The Registry Workshop developer is quite a perfectionist. An ellipses is added to both Settings and About in that app.
But reading this article you seem to be right: no ellipses for Settings and About.
This doesn't mean you should use an ellipsis whenever an action displays another window—only when additional information is required to perform the action. Consequently, any command button whose implicit verb is to "show another window" doesn't take an ellipsis, such as with the commands About, Advanced, Help (or any other command linking to a Help topic), Options, Properties, or Settings.
Allow me another minor comment:
I've just noticed the Configuration Dialog title is: Python Script Shortcut Configuration.
It contains other settings as well; so wouldn't Python Script Configuration be better? Or even better - Python Script Settings?
👍
Great.
Thank you. I appreciate your time and work.
Should notepad.runMenuCommand("תצוגה", "עטיפת מילים") be working now? - I still get an error.
It's actually not important as you can use notepad.menuCommand.
@Yaron10 In this case it was a misunderstanding from my side. Thought just the wrong name
גלילת שורות
instead of
עטיפת מילים
caused the problem. So I will have another look at that.
Are you using version 1.1? From my tests it looks ok from console and script I think.
Or is your expectation that also
notepad.runMenuCommand("View", "Word wrap")
should work in Hebrew mode?
Activity
Yaron10 commentedon Dec 20, 2014
notepad.menuCommand(MENUCOMMAND.VIEW_WRAP)
Works even if the Interface Language is set to Hebrew.
chcg commentedon Apr 22, 2018
@Yaron10 How is in case of Hebrew the command equivalent to
notepad.runMenuCommand("View", "Word wrap")
written and which direction do you use? RTL?
Yaron10 commentedon Apr 22, 2018
Hello @chcg,
Thanks for replying. I appreciate it.
And many thanks you for your work on this plugin. 👍
The command in Hebrew is
notepad.runMenuCommand("תצוגה", "גלילת שורות").It works from the console but not within a script.
I use NPP in Hebrew and the layout is RTL.
Two related request:
1) Could you set the console layout to LTR even if NPP layout is RTL?
Please see this discussion (the RTL part).
@ClaudiaFrank kindly found the relevant code (thanks again Claudia).
Have you committed the fix included in v1.1.1?
2) Could you add Unicode support to the menu?
Hebrew file-names are displayed as gibberish.
Allow me two more questions:
1) Dave's latest official version is 1.0.8.0. Why did you start with 0.6.3.0?
2) I've downloaded your latest
PythonScript_Full_1.0.9.0.zipand replaced the DLL and thelibfolder.from ctypes import windll, byref, wintypes, WINFUNCTYPE, Structure, sizeofinstartup.pytriggers an error.Why is that?
Thanks also for your contribution to ComparePlugin. :)
Best regards.
Yaron10 commentedon Apr 22, 2018
Hello Claudia,
Thanks for replying. I appreciate it.
I'm using the DLL from the zip package.
I've replaced
python27.dllandPythonScript.dllwith the new ones.I don't get the error now. It was certainly there a few hours ago.
However, NPP consistently hangs when I'm using the following script.
With the following
startup.py(thanks again :) ).I've added several right/left toolbar buttons (using CustomizeToolbar; executing various scripts) and they all work properly except the Show/Hide one.
Actually, just using
console.show()causes NPP to hang.Reverting to the original
startup.py,console.show()works as expected.Replacing the new
PythonScript.dllwith the old one - the Show/Hide button works properly.https://github.com/bruderstein/PythonScript/releases
0.6.3was released a few days ago and I was just wondering why those numbers were chosen when1.0.8.0was out a few years ago. Isn't that confusing?Best regards.
Yaron10 commentedon Apr 22, 2018
Great. 👍
Thank you very much.
Yaron10 commentedon Apr 22, 2018
Thanks.
Yaron10 commentedon Apr 22, 2018
Yes, it does.
I've tried those combinations. :)
Yaron10 commentedon Apr 22, 2018
The original zip.
Yaron10 commentedon Apr 22, 2018
And it also happens with the original NPP.
26 remaining items
Yaron10 commentedon May 25, 2018
👍
Very nice. Thank you for the quick fix.
It's certainly not important but I think that
Lastis more commonly used in this context (e.g.Last Closed Tab).As you understand.
Ellipses...
Well... I thought the rule was that any command/button opening a new window should have an ellipses.
The Registry Workshop developer is quite a perfectionist. An ellipses is added to both
SettingsandAboutin that app.But reading this article you seem to be right: no ellipses for
SettingsandAbout.Allow me another minor comment:
I've just noticed the Configuration Dialog title is:
Python Script Shortcut Configuration.It contains other settings as well; so wouldn't
Python Script Configurationbe better? Or even better -Python Script Settings?Yaron10 commentedon May 25, 2018
And
Set Iconshould certainly beSet Icon.... :)Yaron10 commentedon May 25, 2018
Great minds think alike.
I've ignored that too. :)
Yaron10 commentedon May 25, 2018
Well, MS VS uses
Options...andProperties.... :)And this seems to be the convention in most good apps.
Yaron10 commentedon May 25, 2018
Yes, it does.
OTOH, I'm not sure the convention should be completely ignored. It's somewhat like a "proper" language vs. a common language.
So we'll raise a toast to whatever @chcg decides to do. :)
chcg commentedon May 27, 2018
@Yaron10 See Version 1.1, if further issue arise or something from here is missing please create new ones
Yaron10 commentedon May 27, 2018
Hello @chcg and @ClaudiaFrank,
👍
Great.
Thank you. I appreciate your time and work.
Should
notepad.runMenuCommand("תצוגה", "עטיפת מילים")be working now? - I still get an error.It's actually not important as you can use
notepad.menuCommand.chcg commentedon May 27, 2018
@Yaron10 In this case it was a misunderstanding from my side. Thought just the wrong name
גלילת שורות
instead of
עטיפת מילים
caused the problem. So I will have another look at that.
Are you using version 1.1? From my tests it looks ok from console and script I think.
Or is your expectation that also
notepad.runMenuCommand("View", "Word wrap")
should work in Hebrew mode?
chcg commentedon May 27, 2018
From within a script the encoding info is needed:
Yaron10 commentedon May 27, 2018
Yes, I am.
No. :)
👍
That works like a charm.
Thank you very much.
see #20 bruderstein/PythonScript#20 (comment)