Closed Zorgatone closed 8 years ago
@tapio after further investigation I noticed that when in that position the CMD scrolls down its buffer.
Any way to fix this? Is it a problem with the engine, or shold I just move again to (1, 1) after writing to that position?
EDIT: when I do that and move to (1, 1) again, I can see the CMD quickly scrolling up and down
Maybe we can use a function that can add a character without advancing the cursor?
We could add a function like ncurses
addch
?
Can confirm (bug(?))
@nabijaczleweli if you're on windows you can clone the repo and test. I don't know if OS X or Linux have the same issue or not
Hrmmm, apparently my message wasn't clear enough. I meant, that I can confirm it (the issue), but am not sure, whether it is a bug.
Oh, ok thanks
Is it possible to modify/print a character on a given position(x, y) without moving the cursor? That will help a lot to solve this.
Something similar to ncurses' addch()
.
Try the one wevuse in cls()
to fill the screen with ' '
, maybe?
@nabijaczleweli commented on 17 nov 2015, 14:44 CET:
Try the one wevuse in
cls()
to fill the screen with' '
, maybe?
I don't get what you're trying to say. I don't want to clear the screen :stuck_out_tongue_winking_eye:
I meant the FillConsoleOutputCharacter()
WinAPI function (or the like)
That won't be of any use if I don't want to fill the entire screen with the same character.
That's not what is causing the problem with the player being in the low-right corner
WriteConsoleOutputCharacter()
sounds like something we could use
How should the function (in rlutil
) be called?
I'm used to use ncurses' "addch(char)" and "mvaddch(row,col,char)". I don't know if those names would fit for rlutil though.
Maybe a simpler name would be cool
I'm gonna hold off starting work on this, because my other PRs (#17 and #19) explode the codebase quite a lot already (i.e. merging it will be a PITA).
Ok, cool
@Zorgatone I was aiming for a different name, because the arguments are in a different order and it will be quite confusing
Yeah ok. What about this?
/* return_type */ setChar(int ch);
/* return_type */ setCharAt(int ch, int row, int col);
// (returning void for nothing, or int for cursor's current position)
int
can't be used for cursor position, but, other than that, it looks alright
Also works on Linux now
How does one even print to an arbitrary position/save the cursor position on Linux (without <ESC>[6n
, which doesn't work)? Google just gives me shitposts and repeated data on moving the cursor and querying terminal size.
I have absolutely no idea
teethgrind
Okay, this looks literally impossible, even using [n]curses
(like in https://github.com/nabijaczleweli/rlutil/commit/72f640699cb9108262590916812622cf26757a71) leaves off H1
on the end of each line and requires moving the cursor.
Still somehow world be good to prevent that CMD issue.
Maybe just moving the cursor home every time it goes beyond the maximum lines and maximum columns. Or just using some Windows API to set the buffer's number of rows just to the visible ones.
You can locate() to the last position and then setChar() there. Or, alternatively, use the setCharAt() implementation on my fork (on mobile rn, so no link).
Actually, we could just have setCharAt() with a working body on Windooze and an assert() (with an "if you know how to do it, plz show us" message, mebbe)/return an error code.
Oh you already have done those two functions? Nice
Well, setCharAt()
is a terrible failure on Linux, but it's trivial on Windows: https://github.com/tapio/rlutil/blob/72f640699cb9108262590916812622cf26757a71/rlutil.h
You could have that on windows, and on other platforms just save the old position, move to new position, print character normally, restore previous position.
That's a bit of an hack, but it should work at least for now :laughing:
setCharAt
and Test 12: Non-advancing character setting
worked on Mac OS X
Hrmmm, interesting. It leaves H1
after each line on an ssh
d-into Ubuntu 13.04 LTS Headless x86 on Windows 10 x86_64
@Zorgatone How about Test 13: Positioned character setting
?
No wait, nevermind.... On non-blocking input there are some random characters appearing:
Test 8: Non-blocking keyboard input
You should be able to move the '@' character with WASD keys.
Hit Space to continue to the next test.
Turn count: 71149d
w
@
Also this on arrow keys:
Test 9: Arrow keys
You should be able to move the '@' character with arrow keys.
Hit Escape to continue to the next test.
[C
^[[D @
[[C
^[[B
^[[A
^[[D
But the 12th test works, haven't seen a 13th though
Pull the positioned-character
branch on my fork
@Zorgatone Those weird results happen when invoked normally or when piping?
Same tests 8 and 9 (printing wasd and arrow characters from input), and this is test 13:
Press any key to continue...r setting
Next ASCII characters should appear rapidly after each other in a 15-width pattern.
!"#$%&'()*+,-./ remain blinking in the same position.
0123456789:;<=>
?@ABCDEFGHIJKLM
NOPQRSTUVWXYZ[\
]^_`abcdefghijk
lmnopqrstuvwxyz
{|}~
teethgrind Still OSX? ... Fuck OSX
lolol, it's not the non-standard iTerm
here... I don't really care about iTerm
at all.
It's the system default Terminal.app
I'm talking about, yes still OS X.
What are this two files?
Could we add those and the binaries to the .gitignore
and make clean
?
TR:rlutil tommaso$ cat Makefile
CC=gcc
CXX=g++
CFLAGS=-I. -g -O2 -Wall -Wextra
all: test example-c
test: rlutil.h test.cpp
$(CXX) $(CFLAGS) -lncurses -o test test.cpp
example-c: rlutil.h example.c
$(CC) $(CFLAGS) -o example-c example.c
.PHONY: clean
clean:
rm -f test example-c
TR:rlutil tommaso$ make clean
rm -f test example-c
TR:rlutil tommaso$ git status
On branch positioned-character
Untracked files:
(use "git add <file>..." to include in what will be committed)
example-c.dSYM/
test.dSYM/
nothing added to commit but untracked files present (use "git add" to track)
These files aren't.
No; they exist only in your head.
They appeared when I runned make
.
I've cloned the new repo removing all the old files first
s/runned/ran/
Remove them, rerun make
.
What toolchain?
TR:rlutil tommaso$ ls
Makefile docs rlutil.h
README.markdown example.c test.cpp
cross-compile.sh index.html
TR:rlutil tommaso$ make
g++ -I. -g -O2 -Wall -Wextra -lncurses -o test test.cpp
gcc -I. -g -O2 -Wall -Wextra -o example-c example.c
TR:rlutil tommaso$ which gcc; gcc -v; which g++; g++ -v
/usr/bin/gcc
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
/usr/bin/g++
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
TR:rlutil tommaso$ ls
Makefile example-c rlutil.h
README.markdown example-c.dSYM test
cross-compile.sh example.c test.cpp
docs index.html test.dSYM
TR:rlutil tommaso$
See the updated log, I forgot to paste it
W_h_ell, that's surprising. Works On My Machines:tm:, though
Also, Google it
We can just add an entry on .gitignore
and make clean
for any files with the dSYM
extension though.
Just to clean the crap out before pulling other changes.
Yeah I googled that XD
That's probably because my toolchain is logged in with my Apple Developer ID (OS X, iOS), and is generating those.
The issue wasn't what exactly are those files, but if we could just get rid of those doing make clean
, and ignoring them from the repo in .gitignore
.
If those aren't just when building your fork, I'll open a PR separately.
I have this sourcecode: Crook - Roguelike (
bug-wincmd
branch on filesrc/crook.c
, commit3e2e1ac
)I'm having a very weird issue on the windows' CMD prompt. I am saving the coordinates correctly (AFAICT), and I'm debugging the player position and the arrow pressed.
If you can test this, go to the lower-rightmost position in the terminal. Everytime
x == maxx && y == maxy
both the debug info and the player are printed one line above