Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-03-01 02:33:35 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-03-01 02:33:35 +0300
commit6cc89b9d4e6ab17bea0631b1be800dd9a022db23 (patch)
tree356e3649b94ec7f5a144f1fa6304f5646c4b9bf1 /source/blender/blenkernel/intern/text.c
parent2469305376856e0f53b4ffdbe2bf2576fa25809c (diff)
2.5: Text Editor back.
There was very little structure in this code, using many globals and duplicated code. Now it should be better structured. Most things should work, the main parts that are not back yet are the python plugins and markers. Notes: * Blenfont is used for drawing the text, nicely anti-aliased. * A monospace truetype font was added, since that is needed for the text editor. It's Bitstream Vera Sans Mono. This is the default gnome terminal font, but it doesn't fit entirely well with the other font I think, can be changed easily of course. * Clipboard copy/cut/paste now always uses the system clipboard, the code for the own cut buffer was removed. * The interface buttons should support copy/cut/paste again now as well. * WM_clipboard_text_get/WM_clipboard_text_set were added to the windowmanager code. * Find panel is now a kind of second header, instead of a panel. This needs especially a way to start editing the text field immediately on open still. * Operators are independent of the actual space when possible, was a bit of puzzling but got it solved nice with notifiers, and some lazy init for syntax highlight in the drawing code. * RNA was created for the text editor space and used for buttons. * Operators: * New, Open, Reload, Save, Save As, Make Internal * Run Script, Refresh Pyconstraints * Copy, Cut, Paste * Convert Whitespace, Uncomment, Comment, Indent, Unindent * Line Break, Insert * Next Marker, Previous Marker, Clear All Markers, Mark All * Select Line, Select All * Jump, Move, Move Select, Delete, Toggle Overwrite * Scroll, Scroll Bar, Set Cursor, Line Number * Find and Replace, Find, Replace, Find Set Selected, Replace Set Selected * To 3D Object * Resolve Conflict
Diffstat (limited to 'source/blender/blenkernel/intern/text.c')
-rw-r--r--source/blender/blenkernel/intern/text.c122
1 files changed, 8 insertions, 114 deletions
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 999e1744ae6..47a33bdee66 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -65,9 +65,6 @@ A text should relate to a file as follows -
(Text *)->flags has the following bits
TXT_ISDIRTY - should always be set if the file in mem. differs from
the file on disk, or if there is no file on disk.
- TXT_ISTMP - should always be set if the (Text *)->name file has not
- been written before, and attempts to save should result
- in "Save over?"
TXT_ISMEM - should always be set if the Text has not been mapped to
a file, in which case (Text *)->name may be NULL or garbage.
TXT_ISEXT - should always be set if the Text is not to be written into
@@ -130,7 +127,6 @@ static void txt_delete_line(Text *text, TextLine *line);
/***/
-static char *txt_cut_buffer= NULL;
static unsigned char undoing;
/* allow to switch off undoing externally */
@@ -179,7 +175,7 @@ Text *add_empty_text(char *name)
ta->undo_buf= MEM_mallocN(ta->undo_len, "undo buf");
ta->nlines=1;
- ta->flags= TXT_ISDIRTY | TXT_ISTMP | TXT_ISMEM;
+ ta->flags= TXT_ISDIRTY | TXT_ISMEM;
ta->lines.first= ta->lines.last= NULL;
ta->markers.first= ta->markers.last= NULL;
@@ -257,8 +253,6 @@ int reopen_text(Text *text)
text->undo_len= TXT_INIT_UNDO;
text->undo_buf= MEM_mallocN(text->undo_len, "undo buf");
- text->flags= TXT_ISTMP;
-
fseek(fp, 0L, SEEK_END);
len= ftell(fp);
fseek(fp, 0L, SEEK_SET);
@@ -347,9 +341,6 @@ Text *add_text(char *file, const char *relpath)
ta->lines.first= ta->lines.last= NULL;
ta->markers.first= ta->markers.last= NULL;
ta->curl= ta->sell= NULL;
-
-/* ta->flags= TXT_ISTMP | TXT_ISEXT; */
- ta->flags= TXT_ISTMP;
fseek(fp, 0L, SEEK_END);
len= ftell(fp);
@@ -430,7 +421,7 @@ Text *copy_text(Text *ta)
tan->name= MEM_mallocN(strlen(ta->name)+1, "text_name");
strcpy(tan->name, ta->name);
- tan->flags = ta->flags | TXT_ISDIRTY | TXT_ISTMP;
+ tan->flags = ta->flags | TXT_ISDIRTY;
tan->lines.first= tan->lines.last= NULL;
tan->markers.first= tan->markers.last= NULL;
@@ -1056,11 +1047,6 @@ void txt_sel_line (Text *text)
/* Cut and paste functions */
/***************************/
-void txt_print_cutbuffer (void)
-{
- printf ("Cut buffer\n--\n%s\n--\n", txt_cut_buffer);
-}
-
char *txt_to_buf (Text *text)
{
int length;
@@ -1165,15 +1151,6 @@ int txt_find_string(Text *text, char *findstr, int wrap)
return 0;
}
-void txt_cut_sel (Text *text)
-{
- if (!G.background) /* Python uses txt_cut_sel, which it should not, working around for now */
- ; //XXX txt_copy_clipboard(text);
-
- txt_delete_sel(text);
- txt_make_dirty(text);
-}
-
char *txt_sel_to_buf (Text *text)
{
char *buf;
@@ -1251,85 +1228,6 @@ char *txt_sel_to_buf (Text *text)
return buf;
}
-void txt_copy_sel (Text *text)
-{
- int length=0;
- TextLine *tmp, *linef, *linel;
- int charf, charl;
-
- if (!text) return;
- if (!text->curl) return;
- if (!text->sell) return;
-
- if (!txt_has_sel(text)) return;
-
- if (txt_cut_buffer) MEM_freeN(txt_cut_buffer);
- txt_cut_buffer= NULL;
-
- if (text->curl==text->sell) {
- linef= linel= text->curl;
-
- if (text->curc < text->selc) {
- charf= text->curc;
- charl= text->selc;
- } else{
- charf= text->selc;
- charl= text->curc;
- }
- } else if (txt_get_span(text->curl, text->sell)<0) {
- linef= text->sell;
- linel= text->curl;
-
- charf= text->selc;
- charl= text->curc;
- } else {
- linef= text->curl;
- linel= text->sell;
-
- charf= text->curc;
- charl= text->selc;
- }
-
- if (linef == linel) {
- length= charl-charf;
-
- txt_cut_buffer= MEM_mallocN(length+1, "cut buffera");
-
- BLI_strncpy(txt_cut_buffer, linef->line + charf, length+1);
- } else {
- length+= linef->len - charf;
- length+= charl;
- length++; /* For the '\n' */
-
- tmp= linef->next;
- while (tmp && tmp!= linel) {
- length+= tmp->len+1;
- tmp= tmp->next;
- }
-
- txt_cut_buffer= MEM_mallocN(length+1, "cut bufferb");
-
- strncpy(txt_cut_buffer, linef->line+ charf, linef->len-charf);
- length= linef->len-charf;
-
- txt_cut_buffer[length++]='\n';
-
- tmp= linef->next;
- while (tmp && tmp!=linel) {
- strncpy(txt_cut_buffer+length, tmp->line, tmp->len);
- length+= tmp->len;
-
- txt_cut_buffer[length++]='\n';
-
- tmp= tmp->next;
- }
- strncpy(txt_cut_buffer+length, linel->line, charl);
- length+= charl;
-
- txt_cut_buffer[length]=0;
- }
-}
-
void txt_insert_buf(Text *text, char *in_buffer)
{
int i=0, l=0, j, u, len;
@@ -1380,16 +1278,6 @@ void txt_insert_buf(Text *text, char *in_buffer)
undoing= u;
}
-void txt_free_cut_buffer(void)
-{
- if (txt_cut_buffer) MEM_freeN(txt_cut_buffer);
-}
-
-void txt_paste(Text *text)
-{
- txt_insert_buf(text, txt_cut_buffer);
-}
-
/******************/
/* Undo functions */
/******************/
@@ -2394,6 +2282,12 @@ int txt_add_char (Text *text, char add)
return 1;
}
+void txt_delete_selected(Text *text)
+{
+ txt_delete_sel(text);
+ txt_make_dirty(text);
+}
+
int txt_replace_char (Text *text, char add)
{
char del;