Skip to content

Commit

Permalink
Fix Windows and GTK uiScintilla
Browse files Browse the repository at this point in the history
  • Loading branch information
petabyt committed Nov 30, 2024
1 parent 83326e4 commit dbbe5b0
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 180 deletions.
4 changes: 2 additions & 2 deletions extras/scintilla/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ ui_scintilla_win_x86_64.a: $(FILES)

install: ui_scintilla_win_x86_64.a
sudo cp ui_scintilla_win_x86_64.a $(LIB_DIR)/ui_scintilla.a
-mkdir $(INC_DIR)/ui
sudo cp ui_scintilla.h $(INC_DIR)/ui
sudo mkdir -p $(INC_DIR)/ui
sudo cp ui_scintilla.h $(INC_DIR)/ui/ui_scintilla.h

all: $(FILES)

Expand Down
63 changes: 0 additions & 63 deletions extras/scintilla/cross.mk

This file was deleted.

27 changes: 4 additions & 23 deletions extras/scintilla/gtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <stdio.h>
#include <ui.h>
#include <gtk/gtk.h>
#define GTK
#include <Scintilla.h>
#include <ScintillaTypes.h>
#include <ScintillaStructures.h>
Expand Down Expand Up @@ -30,31 +29,13 @@ _UI_EXTERN uiScintilla *uiNewScintilla() {
s->widget = scintilla_new();
s->sci = SCINTILLA(s->widget);

// scintilla_set_id(sci, 0);
// gtk_widget_set_usize(editor, 500, 300);

//#define SSM(m, w, l) scintilla_send_message(sci, m, w, l)
//
// SSM(SCI_STYLECLEARALL, 0, 0);
// SSM(SCI_SETLEXER, SCLEX_CPP, 0);
// SSM(SCI_SETKEYWORDS, 0, (sptr_t)"int char");
// SSM(SCI_STYLESETFORE, SCE_C_COMMENT, 0x008000);
// SSM(SCI_STYLESETFORE, SCE_C_COMMENTLINE, 0x008000);
// SSM(SCI_STYLESETFORE, SCE_C_NUMBER, 0x808000);
// SSM(SCI_STYLESETFORE, SCE_C_WORD, 0x800000);
// SSM(SCI_STYLESETFORE, SCE_C_STRING, 0x800080);
// SSM(SCI_STYLESETBOLD, SCE_C_OPERATOR, 1);
// SSM(SCI_INSERTTEXT, 0, (sptr_t)
// "int main(int argc, char **argv) {\n"
// " // Start up the gnome\n"
// " gnome_init(\"stest\", \"1.0\", argc, argv);\n}"
// );
//
// gtk_widget_grab_focus(GTK_WIDGET(editor));

return s;
}

uintptr_t uiScintillaSendMessage(uiScintilla *s, uint32_t code, uintptr_t w, uintptr_t l) {
return scintilla_object_send_message(s->sci, code, w, l);
}

#if 1
void uiScintillaGetRange(uiScintilla *s, int start, int end, char *text) {
struct Scintilla::TextRange tr;
Expand Down
1 change: 1 addition & 0 deletions extras/scintilla/ui_scintilla.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ _UI_EXTERN void uiScintillaAppend(uiScintilla *s, const char *text);
_UI_EXTERN int uiScintillaGetLength(uiScintilla *s);
_UI_EXTERN uiScintilla *uiNewScintilla();
_UI_EXTERN char *uiScintillaText(uiScintilla *s);
_UI_EXTERN uintptr_t uiScintillaSendMessage(uiScintilla *s, uint32_t code, uintptr_t w, uintptr_t l);

#ifdef __cplusplus
}
Expand Down
21 changes: 17 additions & 4 deletions extras/scintilla/win.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#include <windows.h>
#include <richedit.h>
#include <ui.h>
#include "Scintilla.h"
#include "ScintillaTypes.h"
#include "ScintillaWin.h"
#include <Scintilla.h>
#include <ScintillaTypes.h>
#include <ScintillaWin.h>

#include "../libui-dev/include/ui_windows.h"
#include "../../include/ui_windows.h"
extern HWND utilWindow;
extern HINSTANCE hInstance;
extern void uiprivDestroyTooltip(uiControl* c);
Expand Down Expand Up @@ -51,11 +51,24 @@ _UI_EXTERN uiScintilla *uiNewScintilla() {

SendMessage(s->hwnd, SCI_STYLESETFONT, 0, reinterpret_cast<LPARAM>("Cascadia Mono"));

SendMessage(s->hwnd, SCI_STYLESETSIZE, 0, 10);

SendMessage(s->hwnd, SCI_STYLESETFORE, STYLE_DEFAULT, 0x121212);
SendMessage(s->hwnd, SCI_STYLESETBACK, STYLE_DEFAULT, 0x121212);
SendMessage(s->hwnd, SCI_SETELEMENTCOLOUR, SC_ELEMENT_CARET, 0xff0000ff);
SendMessage(s->hwnd, SCI_SETELEMENTCOLOUR, SC_ELEMENT_WHITE_SPACE, 0xff0000ff);
SendMessage(s->hwnd, SCI_SETELEMENTCOLOUR, SC_ELEMENT_WHITE_SPACE_BACK, 0xff0000ff);


SendMessage(s->hwnd, SCI_STYLESETSIZE, 0, 10);

return s;
}

uintptr_t uiScintillaSendMessage(uiScintilla *s, uint32_t code, uintptr_t w, uintptr_t l) {
return SendMessage(s->hwnd, code, w, l);
}

void uiScintillaGetRange(uiScintilla *s, int start, int end, char *text) {
TEXTRANGE tr;
tr.chrg.cpMin = start;
Expand Down
44 changes: 0 additions & 44 deletions extras/scintilla/win.txt

This file was deleted.

44 changes: 0 additions & 44 deletions extras/scintilla/x.c

This file was deleted.

0 comments on commit dbbe5b0

Please sign in to comment.