~kiwec/ke

5bc8d682853b8119d133d6592d4c6d5e4a434d12 — Wolf Clément 3 years ago 0c87482
Fix compiler flags
3 files changed, 10 insertions(+), 16 deletions(-)

M Makefile
M src/Buffer.cpp
M src/Editor.cpp
M Makefile => Makefile +7 -5
@@ 10,26 10,28 @@ LDFLAGS  = -ltermbox -lstdc++ -lm
TARGET   = ke

$(TARGET): $(OBJ)
	$(CXX) -o $@ $^ $(LDFLAGS)
	$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)

-include $(DEP)
-include $(TDEP)

%.d: %.cpp
	@$(CXX) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
	@$(CXX) $(CXXFLAGS) $< -MM -MT $(@:.d=.o) >$@

.PHONY: clean
clean:
	rm -f $(OBJ) $(DEP) ke

.PHONY: debug
debug: CXXFLAGS += -Wall -Wextra -g -O0
debug: CXXFLAGS += -Wall -Wextra -g
debug: LDFLAGS += -O0
debug: $(TARGET)

.PHONE: tests
tests: CXXFLAGS += -g -O0
tests: CXXFLAGS += -g
tests: LDFLAGS += -O0
tests: $(filter-out src/main.o, $(OBJ)) $(TOBJ)
	$(CXX) -o $@ $^ $(LDFLAGS) && ./tests
	$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) && ./tests

.PHONY: install
install: $(TARGET)

M src/Buffer.cpp => src/Buffer.cpp +1 -11
@@ 279,7 279,6 @@ bool Buffer::handle_mouse(tb_event* ev) {

void Buffer::insert(const wchar_t c, bool log_events) {
	if(c == L'\n') {
		bool at_end = m_relative_position == current_line().length();
		int next_indent = current_line().get_next_indentation();
		current_line().insert(L'\n', m_relative_position);
		move_down();


@@ 342,16 341,7 @@ void Buffer::screen_to(uint screen_x, uint screen_y) {
	move_to(m_first_visible_line_nb + screen_y);
	scroll(old_y);

	uint offset = 0;
	auto old_x = m_relative_position;
	for(m_relative_position = 0; m_relative_position < current_line().length() && offset < m_relative_position; m_relative_position++) {
		if(current_line()[m_relative_position] == '\t') {
			offset += 4;
		} else {
			offset++;
		}
	}
	m_absolute_position += m_relative_position - old_x;
	// TODO set screen_x
}

void Buffer::scroll(uint old_current_line_nb) {

M src/Editor.cpp => src/Editor.cpp +2 -0
@@ 44,9 44,11 @@ bool Editor::handle_key(tb_event* ev) {
		});
		return true;
	case TB_KEY_CTRL_Q:
#ifdef _DEBUG
		// Debug : dump text
		tb_shutdown();
		wprintf(&m_buf->m_text[0]);
#endif

		exit(0);
		return true;