🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.interviews
Article #39

3.1 + 2.6

#39
From: Frank Zenner
Date: Sat, 31 Oct 1992 16:50
153 lines
4079 bytes
I want to use the 2.6 texteditor together with 3.1 elements.
Has anybody tried this succesfully ?

I came to this point: I can map the texteditor but
if I try to do the event handling, i get a segmentation fault.

Thanks for the time. I appreciate every hint.

The program has some out-commented sections for testing purposes.

#include <IV-2_6/InterViews/textbuffer.h>
#include <IV-2_6/InterViews/texteditor.h>
#include <IV-2_6/InterViews/frame.h>
#include <IV-2_6/InterViews/scene.h>
#include <IV-2_6/InterViews/world.h>
#include <IV-2_6/InterViews/sensor.h>
#include <InterViews/event.h>

#include <IV-look/kit.h>
#include <InterViews/background.h>
#include <InterViews/character.h>
#include <InterViews/layout.h>
#include <InterViews/session.h>
#include <InterViews/window.h>


#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>


static PropertyData properties[] = {
    { nil }
};

static OptionDesc options[] = {
    { nil }
};


class TextEd: public MonoScene {
  public:
    TextEd();
    void TextEd::InsertChar (char c);
    TextEditor* te;
    virtual void Handle(Event&);
};

TextEd::TextEd() {
   if (input != nil) {
       input->Unreference();
   }
   input = allEvents;
   input->Reference();  /* this is the command, where the second (3.1) crashes */
   te = new TextEditor("te", 25, 44, 4, Reversed);
   Insert(te);
   te->Edit(new TextBuffer("123\n456", 6, 256));
};

void TextEd::Handle (Event& e) {
  int i=1; 
  int j=0;
  fprintf(stderr,"\nHallo");  // wird nicht ausgefuehrt
    
    if (e.eventType == KeyEvent) {
        if (e.len != 0) {
            char c = e.keystring[0];

            switch (c) {
            case '\010':
            case '\177':
                if (te->Dot() != te->Mark()) {
                    te->DeleteSelection();
                } else {
                    te->DeleteText(-1);
                }
                break;
            case '\015':
                InsertChar('\n');
                break;
            default:
                if (!iscntrl(c)) {
                    InsertChar(c);
                }
                break;
            }
        }

    }  else if (e.eventType == DownEvent) {
        GetRelative(e.x, e.y, te);
        te->Select(te->Locate(e.x, e.y));
        do {
            te->ScrollToView(e.x, e.y);
            te->SelectMore(te->Locate(e.x, e.y));
            Poll(e);
            GetRelative(e.x, e.y, te);
        } while (e.leftmouse);
      }
 
};

void TextEd::InsertChar (char c) {
    te->DeleteSelection();
    te->InsertText(&c, 1);
    te->ScrollToSelection();
};

int main(int argc, char** argv){

/* ******* first body ******** */
  World* w = new World("/****/", argc, argv, options, properties); 
    
  TextEd* myTextEd= new TextEd();

  w->InsertApplication(myTextEd);
  w->Run();
  delete w;
/* ************************** */  


/* second body (don't work) ************************ 

  Session* session = new Session("Test1", argc, argv);
  WidgetKit& kit = *WidgetKit::instance();
  Style* style = session->style();
  const Font* f = kit.font();
  const Color* fg = kit.foreground();
  const LayoutKit& layout = *LayoutKit::instance();

  TextEd* myTextEd= new TextEd();


  session->run_window(
    new ApplicationWindow(

//    new Background(
//      layout.hbox(
//         kit.label("hi mom!"),
//      ),
//      kit.background()
//    )

      myTextEd
    )
  );
  
 ****************************/


}
Technical Details
Message-ID: <1cudgpINNsh@chabrol.dfki.uni-sb.de>
Path: arc1-ca.pugleaf.net!sparky!uunet!dtix!darwin.sura.net!jvnc.net!gmd.de!Germany.EU.net!sbsvax!hydra!dfki.uni-sb.de!zenner

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!dtix!darwin.sura.net!jvnc.net!gmd.de!Germany.EU.net!sbsvax!hydra!dfki.uni-sb.de!zenner
From: zenner@dfki.uni-sb.de (Frank Zenner)
Newsgroups: comp.windows.interviews
Subject: 3.1 + 2.6
Message-ID: <1cudgpINNsh@chabrol.dfki.uni-sb.de>
Date: 31 Oct 92 16:50:33 GMT
Sender: gs-soft@gs-news.dfki.uni-sb.de
Organization: DFKI - German Research Center for AI
Lines: 153
NNTP-Posting-Host: gs-elc7.dfki.uni-sb.de