|
|
1.1 ! root 1: /* ! 2: ScrollViewExtras.m: ! 3: You may freely copy, distribute, and reuse the code in this example. ! 4: NeXT disclaims any warranty of any kind, expressed or implied, as to its fitness for any ! 5: particular use. ! 6: ! 7: Scrollview methods to display/print text ! 8: Written by Jack Greenfield ! 9: */ ! 10: ! 11: #import "ScrollViewExtras.h" ! 12: #import <appkit/appkit.h> ! 13: ! 14: @implementation ScrollView(ScrollViewExtras) ! 15: ! 16: - sprintf:(const char *)format, ... ! 17: { ! 18: int length; ! 19: static char buffer[65536]; ! 20: va_list arguments; ! 21: ! 22: if ([window isVisible]) ! 23: { ! 24: va_start(arguments, format); ! 25: vsprintf(buffer, format, arguments); ! 26: va_end(arguments); ! 27: ! 28: length = [[self docView] textLength]; ! 29: [[self docView] setSel:length :length]; ! 30: [[self docView] replaceSel:buffer]; ! 31: [[self docView] scrollSelToVisible]; ! 32: } ! 33: ! 34: return self; ! 35: } ! 36: ! 37: - vsprintf:(const char *)format arguments:(va_list)arguments ! 38: { ! 39: int length; ! 40: static char buffer[65536]; ! 41: ! 42: if ([window isVisible]) ! 43: { ! 44: vsprintf(buffer, format, arguments); ! 45: length = [[self docView] textLength]; ! 46: [[self docView] setSel:length :length]; ! 47: [[self docView] replaceSel:buffer]; ! 48: [[self docView] scrollSelToVisible]; ! 49: } ! 50: ! 51: return self; ! 52: } ! 53: ! 54: - clear:sender ! 55: { ! 56: int length; ! 57: ! 58: if ([window isVisible]) ! 59: { ! 60: length = [[self docView] textLength]; ! 61: [[self docView] setSel:0 :length]; ! 62: [[self docView] replaceSel:""]; ! 63: [[self docView] scrollSelToVisible]; ! 64: } ! 65: ! 66: return self; ! 67: } ! 68: ! 69: - print:sender ! 70: { ! 71: if ([window isVisible]) ! 72: [[self docView] printPSCode:sender]; ! 73: ! 74: return self; ! 75: } ! 76: ! 77: - printFrom:sender ! 78: { ! 79: return [self sprintf:"%s\n", [sender stringValue]]; ! 80: } ! 81: ! 82: /* Window Delegate method -- constrain window resizing */ ! 83: ! 84: - windowWillResize:sender toSize:(NXSize *)frameSize ! 85: { ! 86: if (frameSize->height < 230) frameSize->height = 230; ! 87: return self; ! 88: } ! 89: ! 90: @end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.