changed to use new BCharacterSet and BCharacterSetRoster from support kit. because libtextencoding.so is not finished yet it uses those sources directly instead of the library.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4092 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
a4b6e788fc
commit
46555d8f43
@ -1,18 +1,26 @@
|
|||||||
SubDir OBOS_TOP src apps stylededit ;
|
SubDir OBOS_TOP src apps stylededit ;
|
||||||
|
|
||||||
|
UsePrivateHeaders support ;
|
||||||
|
|
||||||
AddResources StyledEdit :
|
AddResources StyledEdit :
|
||||||
StyledEdit.rdef StyledEdit.icons.rdef StyledEdit.version.rdef
|
StyledEdit.rdef StyledEdit.icons.rdef StyledEdit.version.rdef
|
||||||
;
|
;
|
||||||
|
|
||||||
App StyledEdit :
|
App StyledEdit :
|
||||||
CharacterSet.cpp
|
|
||||||
ColorMenuItem.cpp
|
ColorMenuItem.cpp
|
||||||
FindWindow.cpp
|
FindWindow.cpp
|
||||||
ReplaceWindow.cpp
|
ReplaceWindow.cpp
|
||||||
StyledEditApp.cpp
|
StyledEditApp.cpp
|
||||||
StyledEditView.cpp
|
StyledEditView.cpp
|
||||||
StyledEditWindow.cpp
|
StyledEditWindow.cpp
|
||||||
|
# OBOS textencodings
|
||||||
|
CharacterSet.cpp
|
||||||
|
CharacterSetRoster.cpp
|
||||||
|
character_sets.cpp
|
||||||
;
|
;
|
||||||
|
|
||||||
LinkSharedOSLibs StyledEdit : be translation tracker textencoding ;
|
SEARCH on <src!apps!stylededit>CharacterSet.cpp += [ FDirName $(OBOS_TOP) src kits support ] ;
|
||||||
|
SEARCH on <src!apps!stylededit>CharacterSetRoster.cpp += [ FDirName $(OBOS_TOP) src kits support ] ;
|
||||||
|
SEARCH on <src!apps!stylededit>character_sets.cpp += [ FDirName $(OBOS_TOP) src kits support ] ;
|
||||||
|
|
||||||
|
LinkSharedOSLibs StyledEdit : be translation tracker textencoding ;
|
||||||
|
@ -2,11 +2,14 @@
|
|||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include "CharacterSet.h"
|
#include <CharacterSet.h>
|
||||||
|
#include <CharacterSetRoster.h>
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include "StyledEditApp.h"
|
#include "StyledEditApp.h"
|
||||||
#include "StyledEditWindow.h"
|
#include "StyledEditWindow.h"
|
||||||
|
|
||||||
|
using namespace BPrivate;
|
||||||
|
|
||||||
BRect windowRect(7,26,507,426);
|
BRect windowRect(7,26,507,426);
|
||||||
|
|
||||||
StyledEditApp * styled_edit_app;
|
StyledEditApp * styled_edit_app;
|
||||||
@ -24,12 +27,11 @@ StyledEditApp::StyledEditApp()
|
|||||||
fOpenPanelEncodingMenu->SetRadioMode(true);
|
fOpenPanelEncodingMenu->SetRadioMode(true);
|
||||||
|
|
||||||
status_t status = B_OK;
|
status_t status = B_OK;
|
||||||
CharacterSetRoster * roster = CharacterSetRoster::Roster(&status);
|
BCharacterSetRoster roster;
|
||||||
if (status == B_OK) {
|
BCharacterSet charset;
|
||||||
for (int index = 0; (index < roster->GetCharacterSetCount()) ; index++) {
|
while (roster.GetNextCharacterSet(&charset) == B_NO_ERROR) {
|
||||||
const CharacterSet * cs = roster->GetCharacterSet(index);
|
BString name(charset.GetPrintName());
|
||||||
BString name(cs->GetPrintName());
|
const char * mime = charset.GetMIMEName();
|
||||||
const char * mime = cs->GetMIMEName();
|
|
||||||
if (mime) {
|
if (mime) {
|
||||||
name.Append(" (");
|
name.Append(" (");
|
||||||
name.Append(mime);
|
name.Append(mime);
|
||||||
@ -38,11 +40,10 @@ StyledEditApp::StyledEditApp()
|
|||||||
BMenuItem * item = new BMenuItem(name.String(),new BMessage(OPEN_AS_ENCODING));
|
BMenuItem * item = new BMenuItem(name.String(),new BMessage(OPEN_AS_ENCODING));
|
||||||
item->SetTarget(this);
|
item->SetTarget(this);
|
||||||
fOpenPanelEncodingMenu->AddItem(item);
|
fOpenPanelEncodingMenu->AddItem(item);
|
||||||
if (index == fOpenAsEncoding) {
|
if (charset.GetFontID() == fOpenAsEncoding) {
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fWindowCount= 0;
|
fWindowCount= 0;
|
||||||
fNext_Untitled_Window= 1;
|
fNext_Untitled_Window= 1;
|
||||||
|
@ -5,11 +5,14 @@
|
|||||||
#include <TranslationUtils.h>
|
#include <TranslationUtils.h>
|
||||||
#include <Node.h>
|
#include <Node.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <CharacterSet.h>
|
||||||
|
#include <CharacterSetRoster.h>
|
||||||
|
#include <UTF8.h>
|
||||||
|
|
||||||
#include "StyledEditView.h"
|
#include "StyledEditView.h"
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include "CharacterSet.h"
|
|
||||||
#include "UTF8.h"
|
using namespace BPrivate;
|
||||||
|
|
||||||
StyledEditView::StyledEditView(BRect viewFrame, BRect textBounds, BHandler *handler)
|
StyledEditView::StyledEditView(BRect viewFrame, BRect textBounds, BHandler *handler)
|
||||||
: BTextView(viewFrame, "textview", textBounds,
|
: BTextView(viewFrame, "textview", textBounds,
|
||||||
@ -74,15 +77,10 @@ StyledEditView::GetStyledText(BPositionIO * stream)
|
|||||||
int32 encoding;
|
int32 encoding;
|
||||||
bytesRead = node->ReadAttr("be:encoding",0,0,&encoding,sizeof(encoding));
|
bytesRead = node->ReadAttr("be:encoding",0,0,&encoding,sizeof(encoding));
|
||||||
if (bytesRead > 0) {
|
if (bytesRead > 0) {
|
||||||
CharacterSetRoster * roster = CharacterSetRoster::Roster(&result);
|
|
||||||
if (result != B_OK) {
|
|
||||||
fSuppressChanges = false;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
if (encoding == 65535) {
|
if (encoding == 65535) {
|
||||||
fEncoding = 0;
|
fEncoding = 0;
|
||||||
} else {
|
} else {
|
||||||
const CharacterSet * cs = roster->FindCharacterSetByConversionID(encoding);
|
const BCharacterSet * cs = BCharacterSetRoster::GetCharacterSetByConversionID(encoding);
|
||||||
if (cs != 0) {
|
if (cs != 0) {
|
||||||
fEncoding = cs->GetFontID();
|
fEncoding = cs->GetFontID();
|
||||||
}
|
}
|
||||||
@ -114,9 +112,7 @@ StyledEditView::GetStyledText(BPositionIO * stream)
|
|||||||
if (fEncoding != 0) {
|
if (fEncoding != 0) {
|
||||||
int32 length = stream->Seek(0,SEEK_END);
|
int32 length = stream->Seek(0,SEEK_END);
|
||||||
text_run_array * run_array = RunArray(0,length);
|
text_run_array * run_array = RunArray(0,length);
|
||||||
CharacterSetRoster * roster = CharacterSetRoster::Roster(&result);
|
uint32 id = BCharacterSetRoster::GetCharacterSetByFontID(fEncoding)->GetConversionID();
|
||||||
if (result == B_OK) {
|
|
||||||
uint32 id = roster->FindCharacterSetByFontID(fEncoding)->GetConversionID();
|
|
||||||
SetText("");
|
SetText("");
|
||||||
char inBuffer[256];
|
char inBuffer[256];
|
||||||
off_t location = 0;
|
off_t location = 0;
|
||||||
@ -141,7 +137,6 @@ StyledEditView::GetStyledText(BPositionIO * stream)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
SetRunArray(0,length,run_array);
|
SetRunArray(0,length,run_array);
|
||||||
}
|
}
|
||||||
fSuppressChanges = false;
|
fSuppressChanges = false;
|
||||||
@ -168,11 +163,9 @@ StyledEditView::WriteStyledEditFile(BFile * file)
|
|||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
CharacterSetRoster * roster = CharacterSetRoster::Roster(&result);
|
const BCharacterSet * cs = BCharacterSetRoster::GetCharacterSetByFontID(fEncoding);
|
||||||
if (result != B_OK) {
|
if (cs != 0) {
|
||||||
return result;
|
uint32 id = cs->GetConversionID();
|
||||||
}
|
|
||||||
uint32 id = roster->FindCharacterSetByFontID(fEncoding)->GetConversionID();
|
|
||||||
const char * outText = Text();
|
const char * outText = Text();
|
||||||
int32 sourceLength = TextLength();
|
int32 sourceLength = TextLength();
|
||||||
int32 state = 0;
|
int32 state = 0;
|
||||||
@ -190,6 +183,7 @@ StyledEditView::WriteStyledEditFile(BFile * file)
|
|||||||
}
|
}
|
||||||
file->WriteAttr("be:encoding",B_INT32_TYPE,0,&id,sizeof(id));
|
file->WriteAttr("be:encoding",B_INT32_TYPE,0,&id,sizeof(id));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
alignment align = Alignment();
|
alignment align = Alignment();
|
||||||
file->WriteAttr("alignment",B_INT32_TYPE,0,&align,sizeof(align));
|
file->WriteAttr("alignment",B_INT32_TYPE,0,&align,sizeof(align));
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
#include <TranslationUtils.h>
|
#include <TranslationUtils.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
#include <CharacterSet.h>
|
||||||
|
#include <CharacterSetRoster.h>
|
||||||
|
|
||||||
//****** Application defined header files************/.
|
//****** Application defined header files************/.
|
||||||
#include "CharacterSet.h"
|
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include "ColorMenuItem.h"
|
#include "ColorMenuItem.h"
|
||||||
#include "FindWindow.h"
|
#include "FindWindow.h"
|
||||||
@ -26,6 +27,8 @@
|
|||||||
#include "StyledEditView.h"
|
#include "StyledEditView.h"
|
||||||
#include "StyledEditWindow.h"
|
#include "StyledEditWindow.h"
|
||||||
|
|
||||||
|
using namespace BPrivate;
|
||||||
|
|
||||||
StyledEditWindow::StyledEditWindow(BRect frame, int32 id, uint32 encoding)
|
StyledEditWindow::StyledEditWindow(BRect frame, int32 id, uint32 encoding)
|
||||||
: BWindow(frame,"untitled",B_DOCUMENT_WINDOW,0)
|
: BWindow(frame,"untitled",B_DOCUMENT_WINDOW,0)
|
||||||
{
|
{
|
||||||
@ -866,12 +869,12 @@ StyledEditWindow::SaveAs()
|
|||||||
fSavePanelEncodingMenu->SetRadioMode(true);
|
fSavePanelEncodingMenu->SetRadioMode(true);
|
||||||
|
|
||||||
status_t status = B_OK;
|
status_t status = B_OK;
|
||||||
CharacterSetRoster * roster = CharacterSetRoster::Roster(&status);
|
BCharacterSetRoster roster;
|
||||||
if (status == B_OK) {
|
BCharacterSet charset;
|
||||||
for (int index = 0; (index < roster->GetCharacterSetCount()) ; index++) {
|
int index = 0;
|
||||||
const CharacterSet * cs = roster->GetCharacterSet(index);
|
while (roster.GetNextCharacterSet(&charset) == B_NO_ERROR) {
|
||||||
BString name(cs->GetPrintName());
|
BString name(charset.GetPrintName());
|
||||||
const char * mime = cs->GetMIMEName();
|
const char * mime = charset.GetMIMEName();
|
||||||
if (mime) {
|
if (mime) {
|
||||||
name.Append(" (");
|
name.Append(" (");
|
||||||
name.Append(mime);
|
name.Append(mime);
|
||||||
@ -880,12 +883,11 @@ StyledEditWindow::SaveAs()
|
|||||||
BMenuItem * item = new BMenuItem(name.String(),new BMessage(SAVE_AS_ENCODING));
|
BMenuItem * item = new BMenuItem(name.String(),new BMessage(SAVE_AS_ENCODING));
|
||||||
item->SetTarget(this);
|
item->SetTarget(this);
|
||||||
fSavePanelEncodingMenu->AddItem(item);
|
fSavePanelEncodingMenu->AddItem(item);
|
||||||
if (index == fTextView->GetEncoding()) {
|
if (charset.GetFontID() == fTextView->GetEncoding()) {
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// its own scope allows the lock to be released before Show()
|
// its own scope allows the lock to be released before Show()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user