WEBVTT

00:00.450 --> 00:06.810
He saw last time that when we printed out tell the world that it printed out in the top left the screen

00:06.810 --> 00:18.000
much like cows outworks we even see the cursor as the outputs of your runs in the world and the cursor

00:18.000 --> 00:20.080
position here.

00:20.190 --> 00:28.920
So far nothing seems all that exciting but the most important part of curses output is that you can

00:28.920 --> 00:33.780
change the cursor position directly unlikes out.

00:33.840 --> 00:39.160
So close this and we say

00:41.560 --> 00:42.600
move

00:45.180 --> 00:50.220
Dean 10 k.

00:50.320 --> 00:56.420
So we move these moves change the cursor position position.

00:56.470 --> 01:03.320
So this changes cursor session.

01:03.470 --> 01:09.140
Initially the cursor position is at the top left of the screen.

01:09.440 --> 01:19.230
So in terms of coordinates the top left corner is at 0 0 and y goes down and X goes to the right.

01:19.580 --> 01:20.960
So we run this

01:26.670 --> 01:35.320
we see that we actually moved our Hello World string down 15.

01:35.370 --> 01:40.210
So this 15 here is actually the Y.

01:40.680 --> 01:49.810
And we moved it 10 over so 15 units down and 10 yards to the right.

01:49.880 --> 01:56.570
One thing to note about move is that the first argument is for the y direction and second argument is

01:56.570 --> 02:05.650
for the ruction love to keep that in mind since usually we think X first then why it's opposite here.

02:05.780 --> 02:15.980
Now whenever we draw we draw relative to the cursor position we just set K and see the new cursor position

02:15.980 --> 02:18.720
now is right here.

02:18.980 --> 02:27.450
So it went down and tend to write in however many characters this is over.

02:28.160 --> 02:32.180
So this makes trying very flexible.

02:32.990 --> 02:39.760
It's a little bit annoying to always call or move first and then call print w.

02:40.050 --> 02:49.280
So curses actually combine them into one nice shorthand function that we can use so instead of always

02:49.280 --> 03:06.110
calling move then branch we can instead do this say this is out you can say in the print you and just

03:06.110 --> 03:15.240
like before we can say 15 years change it 20 and 15 is a low

03:18.600 --> 03:21.420
that you're right and this

03:24.980 --> 03:29.340
C actually went down 20 and over 15.

03:29.930 --> 03:35.900
And so just like the move in print but in one call it makes it really nice.

03:36.340 --> 03:37.940
OK.

03:38.120 --> 03:45.830
So one thing to note about the strings that we're using are here is close this.

03:45.830 --> 03:50.870
So this string is actually not a C++ string.

03:50.870 --> 03:52.160
There are C strings.

03:52.240 --> 03:52.810
OK.

03:52.970 --> 03:57.190
So this is one of the reasons why I try to use the strings first.

03:57.260 --> 04:06.540
So if we're going to use our C++ string say this string is Cloudstreet here

04:09.460 --> 04:16.970
spring so if you want do you have a string.

04:17.510 --> 04:22.780
What do you call easy string variant.

04:23.020 --> 04:25.790
Hello string.

04:26.380 --> 04:29.560
Sorry stirrer.

04:29.790 --> 04:30.850
This.

04:32.590 --> 04:35.260
Nach gay

04:38.750 --> 04:39.270
like so

04:42.800 --> 04:55.040
that again say we wanted to draw in the direct middle of the screen and there are built in variables

04:55.040 --> 05:01.100
and curses that will tell us how many rows and how many columns the window it's OK.

05:01.170 --> 05:14.060
So if we want to directly draw this string in in the middle of the screen we could say this say lines

05:14.810 --> 05:26.940
which is the lines is number rows.

05:27.110 --> 05:30.810
Our day.

05:30.880 --> 05:35.930
And this is a built in variable that curses provides us.

05:35.940 --> 05:47.100
OK so that winds are two in this if you want to know how many columns we say columns this too.

05:47.120 --> 05:56.210
And if you want to be in the middle say hello string length or two

05:59.040 --> 06:01.610
ran this middle.

06:03.190 --> 06:04.170
It's pretty cool.

06:05.370 --> 06:16.940
And you should never set lines or columns directly because they are not really things we should be changing.

06:17.350 --> 06:22.240
So instead we should only ever read from them.

06:22.950 --> 06:30.520
And I want show you one more way we can actually get how many lines and columns window is or how big

06:30.520 --> 06:31.350
the window is.

06:31.350 --> 06:32.660
Right.

06:33.100 --> 06:38.170
And then through another cursus function call get Max x y.

06:38.260 --> 06:47.260
So we need two variables is a window next X is zero.

06:47.300 --> 06:55.140
Sarge window Max why is that zero.

06:56.260 --> 07:04.520
And we'll call a function so call get max y x.

07:05.320 --> 07:17.470
And we'll use this thing called standard screen and Stimme screen is provided to us by after we call

07:17.500 --> 07:18.160
and it's green.

07:18.160 --> 07:22.730
So that's one of the things the screen does is actually give us this kind of is.

07:23.080 --> 07:26.060
This is actually our window that we're drawing.

07:26.250 --> 07:33.370
And analysts say standard screen so we give it the window which is our default window that we're using

07:34.240 --> 07:35.870
and we see a window.

07:36.220 --> 08:01.810
Max why is it always y x x y we know x x K and then we can say window x y to an edge window x x.

08:02.640 --> 08:08.420
And this again c it's still in the middle of the screen.

08:10.210 --> 08:19.150
So there's one other kind of drawing function that we're going to need and that is to draw just a single

08:19.150 --> 08:30.310
character and we can do that by using a function called Ad character.

08:31.020 --> 08:39.730
And this just add a character acts like this or actions stop or.

08:39.860 --> 08:41.360
And if you're just

08:44.080 --> 08:48.350
see that it actually draws the character.

08:48.580 --> 09:00.950
And just like with the print W function there's also the kind of move variant or add character in do

09:00.950 --> 09:04.850
that by saying in the character

09:07.540 --> 09:21.300
15 in the y in tune x influence see that it moved down 15 and 10 to the right way.

09:24.790 --> 09:27.650
The most that still there is this cursor.

09:27.670 --> 09:34.720
It's kind of annoying to see especially if we want a game so you can actually get rid of it by saying

09:35.410 --> 09:47.030
curse and set you set that false actually makes the cursor invisible.

09:47.260 --> 09:49.190
OK so if you were on this

09:57.080 --> 10:02.210
this see that there's no more cursor.

10:02.840 --> 10:04.800
So it's really nice for games.

10:05.840 --> 10:10.350
Says close this and there's one other.

10:10.390 --> 10:19.930
One last thing we did one single need and that is if you remember that we had a clear screen function

10:19.930 --> 10:30.100
before all curses also has a clear spring function and it's called clear that and clear will actually

10:30.100 --> 10:32.530
clear the entire screen.

10:32.560 --> 10:36.840
So if we run this again we should see that

10:40.210 --> 10:46.440
see that nothing more ANCs cleared the actual character that we were drawn.

10:46.780 --> 10:52.230
So that's kind of it for output from you know in the next lecture.

10:52.240 --> 10:54.690
I want to go over some input.
