gCAD3D 2.40
gui_gtk2/gtk_ed1.c File Reference

texteditor More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include "../ut/ut_umem.h"
#include "../ut/ut_mem.h"
#include "../gui/gui_types.h"
#include "../gui/gui_base.h"
#include "../gui_gtk2/gtk_base.h"
#include "../gui_gtk2/gtk_ed1.h"


int GUI_edi_getModif (MemObj *mo)
long GUI_edi_getEof (MemObj *mo)
long GUI_edi_getLnMax (MemObj *mo)
int GUI_ed1_cb3 (GtkTextBuffer *textbuffer, GtkClipboard *arg1, MemObj mo)
int GUI_ed1_cb2 (void *parent, void *iter, void *mark, MemObj mo)
int GUI_ed1_cb1 (void *parent, void *event, MemObj mo)
MemObj GUI_edi__ (MemObj *o_par, void *funcnam, int mode, char *opts)
int GUI_edi_InsFile (MemObj *mo, char *fnam)
int GUI_edi_Insert (MemObj *mo, long cpos, char *txbuf, long txlen)
int GUI_edi_Write (MemObj *mo, char *txbuf, long *txlen, long maxlen)
int GUI_edi_Read (char *txbuf, long *txlen, long p1, long p2, MemObj *mo)
int GUI_edi_mod_ln (MemObj *mo, long lNr, char *newLn)
long GUI_edi_RdLn (char *sOut, int sSiz, long lNr, MemObj *mo)
int GUI_edi_Rd2it (char *txbuf, long txlen, GtkTextIter *it1, GtkTextIter *it2)
char GUI_edi_RdChr (MemObj *mo, int offset)
long GUI_edi_getCpos (MemObj *mo)
int GUI_edi_setCpos (MemObj *mo, long cpos)
long GUI_edi_getLsta (MemObj *mo, long lNr)
long GUI_edi_getLnr (MemObj *mo)
int GUI_edi_setLnr (MemObj *mo, long lNr)
int GUI_edi_scroll_s (MemObj *mo)
void GUI_edi_Focus (MemObj *mo)
int GUI_edi_sel__ (MemObj *mo, long von, long bis)
int GUI_edi_sel_get (long *p1, long *p2, MemObj *mo)
int GUI_edi_sel_wrf (MemObj *mo, char *fnam)
int GUI_edi_sel_ln (MemObj *mo, long lNr)
int GUI_edi_sel_del (MemObj *mo)
int GUI_edi_del (MemObj *mo, long von, long bis)
int GUI_ed1_decode (MemObj *mo)


static MemObj wEd
static GtkWidget * GUI_ed1_view
static GtkTextBuffer * GUI_ed1_buff
static Obj_gui1GUI_ed1_ActObj
static long GUI_ed1_cPos
static int GUI_ed1_stat =0
static char * GUI_ed1_lcSet

Detailed Description


GUI_edi__ create editor-window
GUI_edi_Insert insert text
GUI_edi_InsFile insert file at curPos, make text selected
GUI_edi_Write write memSpc -> editor
GUI_edi_Read get text between 2 positions
GUI_edi_RdChr get char near charPos
GUI_edi_RdLn get line (copy)
GUI_edi_mod_ln modify line
GUI_edi_del delete text between 2 positions
GUI_edi_getEof get FileSize (total-chars-nr, EOF-Position)
GUI_edi_getLnMax get total-lines-nr
GUI_edi_getLnr get LineNr of act.Curpos
GUI_edi_getCpos get Cursorposition as charOffset
GUI_edi_setCpos set to curPos and view text at curPos
GUI_edi_getLsta get startPos of Line
GUI_edi_sel__ select from-charOffset to-charOffset
GUI_edi_sel_wrf write selected -> file
GUI_edi_sel_ln select line
GUI_edi_sel_del delete selected text
GUI_edi_scroll_s scroll to act.charOffset (= selected)
GUI_edi_Focus set focus to EditWindow
GUI_edi_getModif check if edit-buffer is modfied

Function Documentation

int GUI_edi_getModif ( MemObj mo)

GUI_edi_getModif check if edit-buffer is modfied if buffer is modied: save; this call resets the state. returns 1=modified; 0=unmodified.

long GUI_edi_getEof ( MemObj mo)

GUI_edi_getEof get total nr of chars (not bytes)

gtk_text_buffer_get_char_count get nr of chars, not nr of bytes !

long GUI_edi_getLnMax ( MemObj mo)

GUI_edi_getLnMax get total-lines-nr

int GUI_ed1_cb3 ( GtkTextBuffer *  textbuffer,
GtkClipboard *  arg1,
MemObj  mo 
int GUI_ed1_cb2 ( void *  parent,
void *  iter,
void *  mark,
MemObj  mo 
* INTERNAL 'mark-set'-callback
int GUI_ed1_cb1 ( void *  parent,
void *  event,
MemObj  mo 
* returns 0=event TYP_EventEnter|TYP_EventRelease (keypress/release)
* 1=keyvalue
* 2=modifier
MemObj GUI_edi__ ( MemObj o_par,
void *  funcnam,
int  mode,
char *  opts 
* o_par parentBox
* funcnam callback-function for Keypress & FocusIn-Events (none: NULL)
* mode 0 = do not wrap lines; 1=yes, wrap lines
* opts options; (HorSiz,VertSiz)
* HorSiz,VertSiz: size in characters; default is automatic size.
* negative values: size in pixels.
* 'e' = expand widget; default is fixed size.
* Examples: "" or "10" or "10e,e"
* "10e,e" horiz. size 10 chars, hor. and vert. expandable.
* prototyp funcnam:
* int funcnam (MemObj *mo, void **data);
* // data=table of 3 pointers;
* GUI_DATA_EVENT =*(int*)data[0]=TYP_EventEnter
* GUI_DATA_L1 =*(long*)data[1]=act.cursorPosition
* GUI_DATA_L2 =*(long*)data[2]=act.lineNr.
* GUI_DATA_I1 =*(int*)data[1]=keyvalue; eg 'a'
* GUI_DATA_I2 =*(int*)data[2]=state of modifierkeys;
* &1=shift; &4=ctrl; &8=alt.
* Example without callback-function:
* ed1 = GUI_edi__ (&box1, NULL, "");
* Example with callback-function:
* ed2 = GUI_edi__ (&box1, ed1_cb, "50,40");
* ..
* int ed1_cb (MemObj *mo, void **data) {
* printf(" event=%d typ=%d\n",GUI_DATA_EVENT,GUI_OBJ_TYP(mo));
* printf(" key=%d modi=%d\n",GUI_DATA_I1,GUI_DATA_I2);
* }
int GUI_edi_InsFile ( MemObj mo,
char *  fnam 

GUI_edi_InsFile insert file at curPos, make text selected

int GUI_edi_Insert ( MemObj mo,
long  cpos,
char *  txbuf,
long  txlen 
* text einfuegen
* cpos zB von GUI_edi_getCpos
int GUI_edi_Write ( MemObj mo,
char *  txbuf,
long *  txlen,
long  maxlen 
* das gesamte Editfenster neu schreiben (txbuf(=mem) -> Window).
* ATTENTION: GUI_edi_Write can modify txbuf (changes into UTF8)
* Input:
* txbuf NULL-terminated
* maxlen
* Modif.:
* 2013-04-03 do not set cursor at eof.
int GUI_edi_Read ( char *  txbuf,
long *  txlen,
long  p1,
long  p2,
MemObj mo 
* get text between 2 positions
* p1, p2 character-offset, not byte offsets !
* get whole window with: p1=0L, p2=-1L
* Input:
* txlen size of txbuf
int GUI_edi_mod_ln ( MemObj mo,
long  lNr,
char *  newLn 

change line lNr into <newLn>

long GUI_edi_RdLn ( char *  sOut,
int  sSiz,
long  lNr,
MemObj mo 
* GUI_edi_RdLn get line (copy)
* RetCod: size of line or -1 (EOF)
int GUI_edi_Rd2it ( char *  txbuf,
long  txlen,
GtkTextIter *  it1,
GtkTextIter *  it2 
* get text between 2 iters INTERNAL
* p1, p2 character-offset, not byte offsets !
* get whole window with: p1=0L, p2=-1L
* Input:
* txlen size of txbuf
char GUI_edi_RdChr ( MemObj mo,
int  offset 
* read char near cursor;
* offset 0 = char right of cursor
* offset -1 = char left of cursor
* returns '\0' for out-of-file-positions.
* returns -1 for a multibyte-character
long GUI_edi_getCpos ( MemObj mo)
* get cursorposition as offset from start-of-file.
* 0=startpos; Linedelimiters '\n' is one char.
* cpos -> Zeilennummer: UTF_GetLnrPos
int GUI_edi_setCpos ( MemObj mo,
long  cpos 
* set to curPos and view text at curPos
* cpos -1L is end of file
long GUI_edi_getLsta ( MemObj mo,
long  lNr 

get startPos of Line; -1=line does not exist.

long GUI_edi_getLnr ( MemObj mo)
* GUI_edi_getLnr get LineNr of act.Curpos
* First line = 1 !
int GUI_edi_setLnr ( MemObj mo,
long  lNr 
int GUI_edi_scroll_s ( MemObj mo)

scroll to active insert-mark makes unselect ?

void GUI_edi_Focus ( MemObj mo)

den Focus auf EditWindow

int GUI_edi_sel__ ( MemObj mo,
long  von,
long  bis 
* select_region from-curPos to-curPos
* if(from-curPos < 0) - unsect all !
int GUI_edi_sel_get ( long *  p1,
long *  p2,
MemObj mo 
* write selected -> file
* txlen input = size of txbuf; Output = nr of characters read
int GUI_edi_sel_wrf ( MemObj mo,
char *  fnam 
* GUI_edi_sel_wrf write selected -> file
* returns nr of chars
int GUI_edi_sel_ln ( MemObj mo,
long  lNr 
* GUI_edi_sel_ln select Line, set Curpos to Line.
* Erste Zeile ist 1
* rc -1: lNr does not exist
* ACHTUNG: die ZeilenStart/Endposition wird aus dem mem gelesen !!!!
int GUI_edi_sel_del ( MemObj mo)

GUI_edi_sel_del delete selected text

int GUI_edi_del ( MemObj mo,
long  von,
long  bis 

GUI_edi_del delete from-curPos to-curPos

int GUI_ed1_decode ( MemObj mo)

Variable Documentation

MemObj wEd
GtkWidget* GUI_ed1_view
GtkTextBuffer* GUI_ed1_buff
Obj_gui1* GUI_ed1_ActObj
long GUI_ed1_cPos
int GUI_ed1_stat =0
char* GUI_ed1_lcSet