Skip to content
This repository was archived by the owner on Sep 23, 2022. It is now read-only.

Commit 096b2bf

Browse files
MAJOR revamp
1 parent 08043fb commit 096b2bf

26 files changed

+301
-316
lines changed

Makefile

+8-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
GPP = g++
2-
SFML_VERSION = 2.5.1
2+
SDL_VERSION = 2.0.0
33

4-
SFML_LIB = /usr/local/lib/SFML-$(SFML_VERSION)/lib
5-
SFML_HEADERS = /usr/local/lib/SFML-$(SFML_VERSION)/include
4+
FLAGS = -w
5+
LINKER_FLAGS = -lSDL2 -lSDL2_ttf
6+
EXEC = loop
67

7-
FLAGS = -Wall -L $(SFML_LIB) -I $(SFML_HEADERS)
8-
LIBS = -lsfml-graphics -lsfml-window -lsfml-system
9-
CPP = editor.cpp $(wildcard editor/*.cpp)
10-
BIN = loop
8+
CPP = main.cpp $(wildcard editor/*.cpp)
119

1210
.PHONY: all loop clean
13-
create:
14-
$(GPP) $(FLAGS) -o $(BIN) $(CPP) $(LIBS)
15-
./$(BIN)
16-
17-
remove:
18-
rm -r ./$(BIN)
11+
all :
12+
$(GPP) $(CPP) $(FLAGS) $(LINKER_FLAGS) -o $(EXEC)
13+
./$(EXEC)

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Simple Text Editor built using SFML and C++ for a College Project
3434
│ ├─ Window.cpp
3535
│ └─ Window.h
3636
├─ images
37-
│ ├─ Layer Diagram.svg
37+
│ ├─ Layer_diagram.svg
3838
│ └─ SDP_banner.png
3939
├─ Makefile
4040
├─ README.md

editor.cpp

-61
This file was deleted.

editor/Buffer.cpp

-77
This file was deleted.

editor/Buffer.h

-23
This file was deleted.

editor/Content.cpp

-5
This file was deleted.

editor/Content.h

-14
This file was deleted.

editor/Cursor.cpp

+46-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
1-
//
2-
// Created by op on 23/09/20.
3-
//
4-
51
#include "Cursor.h"
2+
3+
Cursor::Cursor(TTF_Font *font) {
4+
TTF_SizeText(font, "_", &charWidth, &height);
5+
}
6+
7+
void Cursor::fill(u32 *screen_pixels) {
8+
assert(screen_pixels);
9+
for (int row = this->y; row < this->y + this->height; row++) {
10+
for (int col = this->x; col < this->x + this->width; col++) {
11+
screen_pixels[(row * SCREEN_WIDTH) + col] = color;
12+
}
13+
}
14+
}
15+
16+
void Cursor::shiftLeft() {
17+
if (x > OFFSET_X) {
18+
this->x -= charWidth;
19+
this->charNumber -= 1;
20+
}
21+
}
22+
23+
void Cursor::shiftRight() {
24+
if(charNumber < LINE_LIMIT && x < SCREEN_WIDTH) {
25+
this->x += charWidth;
26+
this->charNumber += 1;
27+
}
28+
}
29+
30+
void Cursor::shiftUp() {
31+
this->y -= height;
32+
this->lineNumber -= 1;
33+
}
34+
35+
void Cursor::shiftDown() {
36+
this->y += height;
37+
this->lineNumber += 1;
38+
}
39+
40+
//getters
41+
int Cursor::getLineNumber(){
42+
return lineNumber;
43+
}
44+
45+
int Cursor::getCharNumber(){
46+
return charNumber;
47+
}

editor/Cursor.h

+27-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
1-
//
2-
// Created by op on 23/09/20.
3-
//
4-
5-
#ifndef LOOP_CURSOR_H
6-
#define LOOP_CURSOR_H
1+
#ifndef L00P_RECTANGLE_H
2+
#define L00P_RECTANGLE_H
73

4+
#include "Utility.h"
85

96
class Cursor {
7+
private:
8+
int x = OFFSET_X;
9+
int y = 0;
10+
int width = 2;
11+
int height;
12+
int charWidth = 4;
13+
int charNumber = 0;
14+
int lineNumber = 0;
15+
u32 color = 30;
16+
17+
public:
18+
Cursor(TTF_Font *font);
19+
20+
void fill(u32 *screen_pixels);
21+
22+
void shiftUp();
23+
void shiftDown();
24+
void shiftLeft();
25+
void shiftRight();
1026

27+
//getters
28+
int getLineNumber();
29+
int getCharNumber();
30+
int getLineHeight();
1131
};
1232

1333

14-
#endif //LOOP_CURSOR_H
34+
#endif //L00P_RECTANGLE_H

0 commit comments

Comments
 (0)