| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Expand Up | @@ -1017,6 +1017,18 @@ the following methods and attributes: | |||||||||||||||||||
| Return the character at the given position in the window. The bottom 8 bits are | ||||||||||||||||||||
| the character proper, and upper bits are the attributes. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| .. note:: | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ``inch`` only works for ASCII characters. Use :meth:`in_wch` instead | ||||||||||||||||||||
| for unicode support. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| .. method:: window.in_wch([x, y]) | ||||||||||||||||||||
|
Comment thread
Comment on lines
+1024
to
+1025
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
We separate methods by 2 blank lines (just check that my suggestion is correct before committing it).
Sorry, something went wrong.
All reactions
Comment thread
Comment on lines
+1024
to
+1025
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
Sorry, something went wrong.
All reactions
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| Return the wide character at the given position in the window. The return | ||||||||||||||||||||
| value is a 3-tuple ``(character, attributes, color_pair)``. | ||||||||||||||||||||
|
Comment thread
Comment on lines
+1027
to
+1028
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
Sorry, something went wrong.
All reactions
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| .. versionadded:: 3.14 | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| .. method:: window.insch(ch[, attr]) | ||||||||||||||||||||
| window.insch(y, x, ch[, attr]) | ||||||||||||||||||||
| Expand Down | ||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -1107,6 +1107,39 @@ def test_issue6243(self): | |
| curses.ungetch(1025) | ||
| self.stdscr.getkey() | ||
|
|
||
| def test_in_wch(self): | ||
| stdscr = self.stdscr | ||
|
|
||
| if not hasattr(stdscr, 'in_wch'): | ||
| raise unittest.SkipTest('requires curses.window.in_wch') | ||
|
Comment thread
Comment on lines
+1113
to
+1114
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityDo you need this kind of check or can you use @requires_curses_window_meth('in_wch')?
Sorry, something went wrong.
All reactions
|
||
|
|
||
| if curses.has_colors(): | ||
| curses.init_pair(1, curses.COLOR_RED, 0) | ||
| expected_pair = 1 | ||
| color_attr = curses.color_pair(expected_pair) | ||
| else: | ||
| expected_pair = 0 | ||
| color_attr = 0 | ||
|
|
||
| def _norm(ch, attr, color): | ||
| # for some reason, curses returns some color bits here? | ||
| return ch, attr & ~curses.A_COLOR, color | ||
|
|
||
| for ch in ('a', '\xe9', '\u20ac', '\U0001f643'): | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI would use a subTest to locate failures if needed.
Sorry, something went wrong.
All reactions
|
||
| expected = (ch, curses.A_BOLD, expected_pair) | ||
|
|
||
| stdscr.insstr(0, 0, ch, color_attr | curses.A_BOLD) | ||
| self.assertEqual(_norm(*stdscr.in_wch()), expected) | ||
|
|
||
| stdscr.addstr(0, 0, ch, color_attr | curses.A_BOLD) | ||
| self.assertEqual(_norm(*stdscr.in_wch(0, 0)), expected) | ||
|
Comment thread
Comment on lines
+1131
to
+1135
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityCan we use something that is not at (0, 0) as well to check the ordering (y, x)?
Sorry, something went wrong.
All reactions
|
||
|
|
||
| # in_wch can return multiple characters in the case of zero width | ||
| # curses at max returns 5 characters in a cchar_t | ||
| stdscr.addstr(0, 0, 'a' + '\u200b' * 10) | ||
| expected = ('a\u200b\u200b\u200b\u200b', 0, 0) | ||
| self.assertEqual(stdscr.in_wch(0, 0), expected) | ||
|
|
||
| @requires_curses_func('unget_wch') | ||
| @unittest.skipIf(getattr(curses, 'ncurses_version', (99,)) < (5, 8), | ||
| "unget_wch is broken in ncurses 5.7 and earlier") | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1 @@ | ||||||||
| Add :func:`curses.window.in_wch` function - by Anthony Sottile. | ||||||||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
Sorry, something went wrong.
All reactions
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Expand Up | @@ -1736,6 +1736,54 @@ _curses_window_inch_impl(PyCursesWindowObject *self, int group_right_1, | |||||||||||||||||||||||||||||||||||||||||||||
| return rtn; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| #ifdef HAVE_NCURSESW | ||||||||||||||||||||||||||||||||||||||||||||||
| /*[clinic input] | ||||||||||||||||||||||||||||||||||||||||||||||
| _curses.window.in_wch | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| [ | ||||||||||||||||||||||||||||||||||||||||||||||
| y: int | ||||||||||||||||||||||||||||||||||||||||||||||
| Starting Y-coordinate. | ||||||||||||||||||||||||||||||||||||||||||||||
| x: int | ||||||||||||||||||||||||||||||||||||||||||||||
| Starting X-coordinate. | ||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment thread
Comment on lines
+1744
to
+1748
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
Let's use the same wording as for inch.
Sorry, something went wrong.
All reactions
|
||||||||||||||||||||||||||||||||||||||||||||||
| / | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Retrieve the wide character at the gven position in the window. | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityAh, wait, should we say wide character or Unicode character here (it's a wchar_t but we use it to indicate "Unicode" range so...)
Sorry, something went wrong.
All reactions
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| The return value is a 3-tuple of (character, attributes, color_pair). | ||||||||||||||||||||||||||||||||||||||||||||||
| [clinic start generated code]*/ | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| static PyObject * | ||||||||||||||||||||||||||||||||||||||||||||||
| _curses_window_in_wch_impl(PyCursesWindowObject *self, int group_right_1, | ||||||||||||||||||||||||||||||||||||||||||||||
| int y, int x) | ||||||||||||||||||||||||||||||||||||||||||||||
| /*[clinic end generated code: output=846ca8a82f2ecab4 input=5c20d96b592b0e0b]*/ | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| int ret; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityAh maybe I should have said it in the other review, but I think we use rtn in general and not ret.
Sorry, something went wrong.
All reactions
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| cchar_t wcval; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| wchar_t wstr[CCHARW_MAX + 1]; | ||||||||||||||||||||||||||||||||||||||||||||||
| attr_t attr; | ||||||||||||||||||||||||||||||||||||||||||||||
| short color_pair; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if (group_right_1) { | ||||||||||||||||||||||||||||||||||||||||||||||
| ret = mvwin_wch(self->win, y, x, &wcval); | ||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| ret = win_wch(self->win, &wcval); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| if (PyCursesCheckERR(ret, "in_wch") == NULL) { | ||||||||||||||||||||||||||||||||||||||||||||||
| return NULL; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment thread
Comment on lines
+1769
to
+1776
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
Sorry, something went wrong.
All reactions
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ret = getcchar(&wcval, wstr, &attr, &color_pair, NULL); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (PyCursesCheckERR(ret, "getcchar") == NULL) { | ||||||||||||||||||||||||||||||||||||||||||||||
| return NULL; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment thread
Comment on lines
+1779
to
+1781
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
Sorry, something went wrong.
All reactions
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| return Py_BuildValue("ukh", wstr, attr, color_pair); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /*[-clinic input] | ||||||||||||||||||||||||||||||||||||||||||||||
| _curses.window.instr | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Expand Down Expand Up | @@ -2530,6 +2578,7 @@ static PyMethodDef PyCursesWindow_Methods[] = { | |||||||||||||||||||||||||||||||||||||||||||||
| {"immedok", (PyCFunction)PyCursesWindow_immedok, METH_VARARGS}, | ||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||
| _CURSES_WINDOW_INCH_METHODDEF | ||||||||||||||||||||||||||||||||||||||||||||||
| _CURSES_WINDOW_IN_WCH_METHODDEF | ||||||||||||||||||||||||||||||||||||||||||||||
| _CURSES_WINDOW_INSCH_METHODDEF | ||||||||||||||||||||||||||||||||||||||||||||||
| {"insdelln", (PyCFunction)PyCursesWindow_winsdelln, METH_VARARGS}, | ||||||||||||||||||||||||||||||||||||||||||||||
| {"insertln", (PyCFunction)PyCursesWindow_winsertln, METH_NOARGS}, | ||||||||||||||||||||||||||||||||||||||||||||||
| Expand Down | ||||||||||||||||||||||||||||||||||||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualitySorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.